| 1 |
// RUN: %clang_cc1 -ast-dump -std=c99 %s | FileCheck %s |
| 2 |
|
| 3 |
void variadic(int i, ...); |
| 4 |
|
| 5 |
void func(void) { |
| 6 |
// CHECK: FunctionDecl {{.*}} func 'void (void)' |
| 7 |
|
| 8 |
// Show that we correctly convert between two complex domains. |
| 9 |
_Complex float cf = 1.0f; |
| 10 |
_Complex double cd; |
| 11 |
|
| 12 |
cd = cf; |
| 13 |
// CHECK: BinaryOperator {{.*}} '_Complex double' '=' |
| 14 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'cd' |
| 15 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex double' <FloatingComplexCast> |
| 16 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex float' <LValueToRValue> |
| 17 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'cf' |
| 18 |
|
| 19 |
cf = cd; |
| 20 |
// CHECK: BinaryOperator {{.*}} '_Complex float' '=' |
| 21 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'cf' |
| 22 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex float' <FloatingComplexCast> |
| 23 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex double' <LValueToRValue> |
| 24 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'cd' |
| 25 |
|
| 26 |
// Show that we correctly convert to the common type of a complex and real. |
| 27 |
// This should convert the _Complex float to a _Complex double ("without |
| 28 |
// change of domain" c.f. C99 6.3.1.8p1). |
| 29 |
(void)(cf + 1.0); |
| 30 |
// CHECK: BinaryOperator {{.*}} '_Complex double' '+' |
| 31 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex double' <FloatingComplexCast> |
| 32 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex float' <LValueToRValue> |
| 33 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'cf' |
| 34 |
// CHECK-NEXT: FloatingLiteral {{.*}} 'double' 1.0 |
| 35 |
|
| 36 |
// This should convert the float constant to double, then produce a |
| 37 |
// _Complex double. |
| 38 |
(void)(cd + 1.0f); |
| 39 |
// CHECK: BinaryOperator {{.*}} '_Complex double' '+' |
| 40 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex double' <LValueToRValue> |
| 41 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'cd' |
| 42 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'double' <FloatingCast> |
| 43 |
// CHECK-NEXT: FloatingLiteral {{.*}} 'float' 1.0 |
| 44 |
|
| 45 |
// This should convert the int constant to float, then produce a |
| 46 |
// _Complex float. |
| 47 |
(void)(cf + 1); |
| 48 |
// CHECK: BinaryOperator {{.*}} '_Complex float' '+' |
| 49 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex float' <LValueToRValue> |
| 50 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'cf' |
| 51 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float' <IntegralToFloating> |
| 52 |
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 |
| 53 |
|
| 54 |
// Show that we do not promote a _Complex float to _Complex double as part of |
| 55 |
// the default argument promotions when passing to a variadic function. |
| 56 |
variadic(1, cf); |
| 57 |
// CHECK: CallExpr |
| 58 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} <FunctionToPointerDecay> |
| 59 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'variadic' |
| 60 |
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 |
| 61 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} '_Complex float' <LValueToRValue> |
| 62 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'cf' |
| 63 |
} |
| 64 |
|