]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/torture/floatn-builtin.h
c562812d1d014fe698949e80f2cae91fb1f2839a
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / torture / floatn-builtin.h
1 /* Tests for _FloatN / _FloatNx types: compile and execution tests for
2 built-in functions. Before including this file, define WIDTH as
3 the value N; define EXT to 1 for _FloatNx and 0 for _FloatN. */
4
5 #define CONCATX(X, Y) X ## Y
6 #define CONCAT(X, Y) CONCATX (X, Y)
7 #define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z)
8 #define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z)
9
10 #if EXT
11 # define TYPE CONCAT3 (_Float, WIDTH, x)
12 # define CST(C) CONCAT4 (C, f, WIDTH, x)
13 # define FN(F) CONCAT4 (F, f, WIDTH, x)
14 #else
15 # define TYPE CONCAT (_Float, WIDTH)
16 # define CST(C) CONCAT3 (C, f, WIDTH)
17 # define FN(F) CONCAT3 (F, f, WIDTH)
18 #endif
19
20 extern void exit (int);
21 extern void abort (void);
22
23 extern TYPE test_type;
24 extern __typeof (FN (__builtin_inf) ()) test_type;
25 extern __typeof (FN (__builtin_huge_val) ()) test_type;
26 extern __typeof (FN (__builtin_nan) ("")) test_type;
27 extern __typeof (FN (__builtin_nans) ("")) test_type;
28 extern __typeof (FN (__builtin_fabs) (0)) test_type;
29 extern __typeof (FN (__builtin_copysign) (0, 0)) test_type;
30
31 volatile TYPE inf_cst = FN (__builtin_inf) ();
32 volatile TYPE huge_val_cst = FN (__builtin_huge_val) ();
33 volatile TYPE nan_cst = FN (__builtin_nan) ("");
34 volatile TYPE nans_cst = FN (__builtin_nans) ("");
35 volatile TYPE neg0 = -CST (0.0), neg1 = -CST (1.0), one = 1.0;
36
37 int
38 main (void)
39 {
40 volatile TYPE r;
41 if (!__builtin_isinf (inf_cst))
42 abort ();
43 if (!__builtin_isinf (huge_val_cst))
44 abort ();
45 if (inf_cst != huge_val_cst)
46 abort ();
47 if (!__builtin_isnan (nan_cst))
48 abort ();
49 if (!__builtin_isnan (nans_cst))
50 abort ();
51 r = FN (__builtin_fabs) (neg1);
52 if (r != CST (1.0))
53 abort ();
54 r = FN (__builtin_copysign) (one, neg0);
55 if (r != neg1)
56 abort ();
57 r = FN (__builtin_copysign) (inf_cst, neg1);
58 if (r != -huge_val_cst)
59 abort ();
60 r = FN (__builtin_copysign) (-inf_cst, one);
61 if (r != huge_val_cst)
62 abort ();
63 exit (0);
64 }