1 /* Test for builtin conj, creal, cimag. */
2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
4 extern float _Complex conjf (float _Complex);
5 extern double _Complex conj (double _Complex);
6 extern long double _Complex conjl (long double _Complex);
8 extern float crealf (float _Complex);
9 extern double creal (double _Complex);
10 extern long double creall (long double _Complex);
12 extern float cimagf (float _Complex);
13 extern double cimag (double _Complex);
14 extern long double cimagl (long double _Complex);
16 extern void abort (void);
17 extern void exit (int);
19 extern void link_failure (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 (conjf (fc) != 1.0F - 2.0iF)
32 if (__builtin_conjf (fc) != 1.0F - 2.0iF)
34 if (conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)
36 if (__builtin_conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)
38 if (crealf (fc) != 1.0F)
40 if (__builtin_crealf (fc) != 1.0F)
42 if (crealf (1.0F + 2.0iF) != 1.0F)
44 if (__builtin_crealf (1.0F + 2.0iF) != 1.0F)
46 if (cimagf (fc) != 2.0F)
48 if (__builtin_cimagf (fc) != 2.0F)
50 if (cimagf (1.0F + 2.0iF) != 2.0F)
52 if (__builtin_cimagf (1.0F + 2.0iF) != 2.0F)
55 if (conj (dc) != 1.0 - 2.0i)
57 if (__builtin_conj (dc) != 1.0 - 2.0i)
59 if (conj (1.0 + 2.0i) != 1.0 - 2.0i)
61 if (__builtin_conj (1.0 + 2.0i) != 1.0 - 2.0i)
63 if (creal (dc) != 1.0)
65 if (__builtin_creal (dc) != 1.0)
67 if (creal (1.0 + 2.0i) != 1.0)
69 if (__builtin_creal (1.0 + 2.0i) != 1.0)
71 if (cimag (dc) != 2.0)
73 if (__builtin_cimag (dc) != 2.0)
75 if (cimag (1.0 + 2.0i) != 2.0)
77 if (__builtin_cimag (1.0 + 2.0i) != 2.0)
79 /* Test long doubles. */
80 if (conjl (ldc) != 1.0L - 2.0iL)
82 if (__builtin_conjl (ldc) != 1.0L - 2.0iL)
84 if (conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)
86 if (__builtin_conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)
88 if (creall (ldc) != 1.0L)
90 if (__builtin_creall (ldc) != 1.0L)
92 if (creall (1.0L + 2.0iL) != 1.0L)
94 if (__builtin_creall (1.0L + 2.0iL) != 1.0L)
96 if (cimagl (ldc) != 2.0L)
98 if (__builtin_cimagl (ldc) != 2.0L)
100 if (cimagl (1.0L + 2.0iL) != 2.0L)
102 if (__builtin_cimagl (1.0L + 2.0iL) != 2.0L)
107 /* All the above cases should have been optimized to something else,
108 even if not optimizing (unless -fno-builtin was specified). So any
109 remaining calls to the original functions should abort. */
111 static float _Complex
112 conjf (float _Complex z)
117 static double _Complex
118 conj (double _Complex z)
123 static long double _Complex
124 conjl (long double _Complex z)
130 crealf (float _Complex z)
136 creal (double _Complex z)
142 creall (long double _Complex z)
148 cimagf (float _Complex z)
154 cimag (double _Complex z)
160 cimagl (long double _Complex z)
165 /* When optimizing, all the constant cases should have been
166 constant folded, so no calls to link_failure should remain. In any case,
167 link_failure should not be called. */