match: Optimize `max(a,b) == 0` to `(a|b) == 0` for unsigned [PR115275]
[official-gcc.git] / gcc / testsuite / gcc.dg / builtin-tgmath-2.c
blobc4140cc2bd5a2cefb9234dc87f407fbff723c6c6
1 /* Test __builtin_tgmath: valid uses, _FloatN types. */
2 /* { dg-do run } */
3 /* { dg-options "" } */
4 /* { dg-add-options float32 } */
5 /* { dg-require-effective-target float32_runtime } */
7 extern void abort (void);
8 extern void exit (int);
10 #define CHECK_CALL(C, E, V) \
11 do \
12 { \
13 if ((C) != (E)) \
14 abort (); \
15 extern __typeof (C) V; \
16 } \
17 while (0)
19 extern float var_f;
20 extern double var_d;
21 extern long double var_ld;
22 extern _Float32 var_f32;
24 float t1f (float x) { return x + 1; }
25 double t1d (double x) { return x + 2; }
26 long double t1l (long double x) { return x + 3; }
27 _Float32 t1f32 (_Float32 x) { return x + 4; }
29 #define t1v(x) __builtin_tgmath (t1f, t1d, t1l, t1f32, x)
31 static void
32 test_1 (void)
34 float f = 1;
35 double d = 2;
36 long double ld = 3;
37 _Float32 f32 = 4;
38 int i = 5;
39 CHECK_CALL (t1v (f), 2, var_f);
40 CHECK_CALL (t1v (d), 4, var_d);
41 CHECK_CALL (t1v (ld), 6, var_ld);
42 CHECK_CALL (t1v (f32), 8, var_f32);
43 CHECK_CALL (t1v (i), 7, var_d);
46 int
47 main (void)
49 test_1 ();
50 exit (0);