2013-10-21 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / builtin-isinf_sign-1.c
blob6dc2326ede072867bbd7e6267a3eb31bb12413e4
1 /* Copyright (C) 2008 Free Software Foundation.
3 Verify that __builtin_isinf_sign folds correctly.
5 Origin: Kaveh R. Ghazi, May 17, 2008. */
7 /* { dg-do link } */
9 /* All references to link_error should go away at compile-time. */
10 extern void link_error(int);
12 void __attribute__ ((__noinline__))
13 foo (float f, double d, long double ld)
15 /* Test the generic expansion of isinf_sign. */
17 if (__builtin_isinf_sign(f)
18 != (__builtin_isinf(f) ? (__builtin_signbitf(f) ? -1 : 1) : 0))
19 link_error (__LINE__);
20 if (__builtin_isinf_sign(d)
21 != (__builtin_isinf(d) ? (__builtin_signbit(d) ? -1 : 1) : 0))
22 link_error (__LINE__);
23 if (__builtin_isinf_sign(ld)
24 != (__builtin_isinf(ld) ? (__builtin_signbitl(ld) ? -1 : 1) : 0))
25 link_error (__LINE__);
27 /* In boolean contexts, GCC will fold the inner conditional
28 expression to 1. So isinf_sign folds to plain isinf. */
30 if ((_Bool)__builtin_isinf_sign(f) != (__builtin_isinf(f) != 0))
31 link_error (__LINE__);
32 if ((_Bool)__builtin_isinf_sign(d) != (__builtin_isinf(d) != 0))
33 link_error (__LINE__);
34 if ((_Bool)__builtin_isinf_sign(ld) != (__builtin_isinf(ld) != 0))
35 link_error (__LINE__);
37 if ((__builtin_isinf_sign(f) != 0) != (__builtin_isinf(f) != 0))
38 link_error (__LINE__);
39 if ((__builtin_isinf_sign(d) != 0) != (__builtin_isinf(d) != 0))
40 link_error (__LINE__);
41 if ((__builtin_isinf_sign(ld) != 0) != (__builtin_isinf(ld) != 0))
42 link_error (__LINE__);
44 if ((__builtin_isinf_sign(f) ? 5 : 6) != (__builtin_isinf(f) ? 5 : 6))
45 link_error (__LINE__);
46 if ((__builtin_isinf_sign(d) ? 5 : 6) != (__builtin_isinf(d) ? 5 : 6))
47 link_error (__LINE__);
48 if ((__builtin_isinf_sign(ld) ? 5 : 6) != (__builtin_isinf(ld) ? 5 : 6))
49 link_error (__LINE__);
52 int main (void)
54 foo (1, 2, 3);
55 return 0;