1 // RUN: %clang_cc1 %s -O1 -emit-llvm -o - | FileCheck %s
3 /* Test for builtin conj, creal, cimag. */
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
6 extern float _Complex
conjf (float _Complex
);
7 extern double _Complex
conj (double _Complex
);
8 extern long double _Complex
conjl (long double _Complex
);
10 extern float crealf (float _Complex
);
11 extern double creal (double _Complex
);
12 extern long double creall (long double _Complex
);
14 extern float cimagf (float _Complex
);
15 extern double cimag (double _Complex
);
16 extern long double cimagl (long double _Complex
);
18 extern void abort (void);
19 extern void link_error (void);
24 /* For each type, test both runtime and compile time (constant folding)
26 volatile float _Complex fc
= 1.0F
+ 2.0iF
;
27 volatile double _Complex dc
= 1.0 + 2.0i
;
28 volatile long double _Complex ldc
= 1.0L + 2.0iL
;
30 if (__builtin_conjf (fc
) != 1.0F
- 2.0iF
)
32 if (__builtin_conjf (1.0F
+ 2.0iF
) != 1.0F
- 2.0iF
)
34 if (__builtin_crealf (fc
) != 1.0F
)
36 if (__builtin_crealf (1.0F
+ 2.0iF
) != 1.0F
)
38 if (__builtin_cimagf (fc
) != 2.0F
)
40 if (__builtin_cimagf (1.0F
+ 2.0iF
) != 2.0F
)
43 if (__builtin_conj (dc
) != 1.0 - 2.0i
)
45 if (__builtin_conj (1.0 + 2.0i
) != 1.0 - 2.0i
)
47 if (__builtin_creal (dc
) != 1.0)
49 if (__builtin_creal (1.0 + 2.0i
) != 1.0)
51 if (__builtin_cimag (dc
) != 2.0)
53 if (__builtin_cimag (1.0 + 2.0i
) != 2.0)
55 /* Test long doubles. */
56 if (__builtin_conjl (ldc
) != 1.0L - 2.0iL
)
58 if (__builtin_conjl (1.0L + 2.0iL
) != 1.0L - 2.0iL
)
60 if (__builtin_creall (ldc
) != 1.0L)
62 if (__builtin_creall (1.0L + 2.0iL
) != 1.0L)
64 if (__builtin_cimagl (ldc
) != 2.0L)
66 if (__builtin_cimagl (1.0L + 2.0iL
) != 2.0L)
70 // CHECK-NOT: link_error