Add _FloatN, _FloatNx tests for __builtin_fpclassify.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / builtin-fp-int-inexact.c
blob80458fa62749947e67014a12ad3c8e1229b6be3a
1 /* Test -fno-fp-int-builtin-inexact. */
2 /* { dg-do run } */
3 /* { dg-options "-fno-fp-int-builtin-inexact" } */
4 /* { dg-add-options c99_runtime } */
5 /* { dg-require-effective-target fenv_exceptions } */
7 #include <fenv.h>
9 /* Define functions locally to ensure that if the calls are not
10 expanded inline, failures do not occur because of libm raising
11 "inexact". */
13 #define LOCAL_FN(NAME, TYPE) \
14 __attribute__ ((noinline, noclone)) TYPE \
15 NAME (TYPE x) \
16 { \
17 return x; \
20 #define LOCAL_FNS(NAME) \
21 LOCAL_FN (NAME, double) \
22 LOCAL_FN (NAME ## f, float) \
23 LOCAL_FN (NAME ## l, long double)
25 LOCAL_FNS (ceil)
26 LOCAL_FNS (floor)
27 LOCAL_FNS (round)
28 LOCAL_FNS (trunc)
30 extern void abort (void);
31 extern void exit (int);
33 #define TEST(FN, TYPE) \
34 do \
35 { \
36 volatile TYPE a = 1.5, b; \
37 b = FN (a); \
38 if (fetestexcept (FE_INEXACT)) \
39 abort (); \
40 } \
41 while (0)
43 #define FN_TESTS(FN) \
44 do \
45 { \
46 TEST (__builtin_ ## FN, double); \
47 TEST (__builtin_ ## FN ## f, float); \
48 TEST (__builtin_ ## FN ## l, long double); \
49 } \
50 while (0)
52 static void
53 main_test (void)
55 FN_TESTS (ceil);
56 FN_TESTS (floor);
57 FN_TESTS (round);
58 FN_TESTS (trunc);
61 /* This file may be included by architecture-specific tests. */
63 #ifndef ARCH_MAIN
65 int
66 main (void)
68 main_test ();
69 exit (0);
72 #endif