1 /* Tests for _FloatN / _FloatNx types: compile and execution tests for
2 valid code with complex arithmetic. Before including this file,
3 define WIDTH as the value N; define EXT to 1 for _FloatNx and 0 for
6 #define CONCATX(X, Y) X ## Y
7 #define CONCAT(X, Y) CONCATX (X, Y)
8 #define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z)
9 #define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z)
12 # define TYPE CONCAT3 (_Float, WIDTH, x)
13 # define CST(C) CONCAT4 (C, f, WIDTH, x)
14 # define CSTI(C) CONCAT4 (C, if, WIDTH, x)
15 # define CSTI2(C) CONCAT4 (C, F, WIDTH, xi)
17 # define TYPE CONCAT (_Float, WIDTH)
18 # define CST(C) CONCAT3 (C, f, WIDTH)
19 # define CSTI(C) CONCAT3 (C, if, WIDTH)
20 # define CSTI2(C) CONCAT4 (C, F, WIDTH, i)
23 extern void exit (int);
24 extern void abort (void);
26 volatile TYPE a
= CST (1.0);
27 volatile _Complex TYPE b
= CST (2.0) + CSTI (3.0);
28 volatile _Complex TYPE c
= CST (2.0) + CSTI2 (3.0);
29 volatile _Complex TYPE d
= __builtin_complex (CST (2.0), CST (3.0));
32 fn (_Complex TYPE arg
)
40 volatile _Complex TYPE r
;
46 if (__real__ r
!= CST (3.0) || __imag__ r
!= CST (3.0))
49 if (__real__ r
!= CST (5.0) || __imag__ r
!= CST (6.0))
52 if (__real__ r
!= CST (4.0) || __imag__ r
!= CST (6.0))
55 if (__real__ r
!= CST (2.0) || __imag__ r
!= CST (3.0))
58 if (__real__ r
!= CST (4.0) || __imag__ r
!= CST (6.0))
61 if (__real__ r
!= CST (2.0) || __imag__ r
!= CST (3.0))
64 if (__real__ r
!= -CST (5.0) || __imag__ r
!= CST (12.0))
66 /* Division may not be exact, so round result before comparing. */
68 r
+= __builtin_complex (CST (100.0), CST (100.0));
69 r
-= __builtin_complex (CST (100.0), CST (100.0));
73 if (__real__ r
!= CST (0.5) || __imag__ r
!= CST (0.75))