Debian Codegraph @

gcc/testsuite/c-c++-common/torture/complex-alias-1.c

raw
1 /* Accesses to complex numbers were sometimes marked as scalar and
2 sometimes as struct accesses. */
3 /* { dg-do run } */
4 /* { dg-options "-std=c99" { target c } } */
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 extern void abort (void);
10 #ifdef __cplusplus
11 }
12 #endif
13 static double _Complex *fp_cxd(double _Complex *cx) {
14 return cx;
15 }
16
17 int main( ) {
18 double _Complex cx = 4.0 + 3.0*(__extension__ 1.0iF);
19 double _Complex cx43 = 4.0 + 3.0*(__extension__ 1.0iF);
20 double _Complex cx11 = 1.0 + 1.0*(__extension__ 1.0iF);
21
22 *fp_cxd(&cx) *= cx11;
23 *fp_cxd(&cx) /= cx11;
24
25 double r_cx = __real__(cx);
26 double i_cx = __imag__(cx);
27 double r_cx43 = __real__(cx43);
28 double i_cx43 = __imag__(cx43);
29
30 if( (r_cx == r_cx43) && (i_cx == i_cx43) ) {
31 return 0;
32 } else {
33 abort ();
34 }
35 }