Clang Project

clang_source_code/test/AST/c-casts.c
1// RUN: %clang_cc1 -w -ast-dump %s | FileCheck %s
2
3// The cast construction code both for implicit and c-style casts is very
4// different in C vs C++. This file is intended to test the C behavior.
5
6// TODO: add tests covering the rest of the code in
7// Sema::CheckAssignmentConstraints and Sema::PrepareScalarCast
8
9// CHECK-LABEL: FunctionDecl {{.*}} cast_cvr_pointer
10void cast_cvr_pointer(char volatile * __restrict * const * p) {
11  char*** x;
12  // CHECK: ImplicitCastExpr {{.*}} 'char ***' <NoOp>
13  x = p;
14  // CHECK: CStyleCastExpr {{.*}} 'char ***' <NoOp>
15  x = (char***)p;
16}
17
18// CHECK-LABEL: FunctionDecl {{.*}} cast_pointer_type
19void cast_pointer_type(char *p) {
20  void *x;
21  // CHECK: ImplicitCastExpr {{.*}} 'void *' <BitCast>
22  x = p;
23  // CHECK: CStyleCastExpr {{.*}} 'void *' <BitCast>
24  x = (void*)p;
25}
26