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