d_c99_complex_split.c revision 1.11 1 /* $NetBSD: d_c99_complex_split.c,v 1.11 2022/06/22 19:23:18 rillig Exp $ */
2 # 3 "d_c99_complex_split.c"
3
4 /*
5 * Checks that the real and imaginary parts of a complex number can be
6 * accessed (since C99).
7 */
8
9 int
10 b(double a)
11 {
12 return a == 0;
13 }
14
15 void
16 a(void)
17 {
18 double _Complex z = 0;
19 if (b(__real__ z) && b(__imag__ z))
20 return;
21 }
22
23 void sink(double _Complex);
24
25 /*
26 * Before tree.c 1.275 from 2021-04-09, lint wrongly warned that when
27 * '__real__ c' was assigned, 'c may be used before set'.
28 *
29 * As of 2021-04-09, support for _Complex is still very incomplete, see
30 * build_real_imag for details. For example, lint does not know that after
31 * the assignment to '__real__ c', the variable is partially initialized.
32 */
33 void
34 set_complex_complete(double re, double im)
35 {
36 double _Complex c;
37
38 __real__ c = re;
39 __imag__ c = im;
40 sink(c);
41 }
42
43 /*
44 * Before tree.c 1.275 from 2021-04-09, lint wrongly warned that when
45 * '__real__ c' was assigned, 'c may be used before set [158]'.
46 *
47 * As of 2021-04-09, support for _Complex is still very incomplete, see
48 * build_real_imag for details.
49 */
50 void
51 set_complex_only_real(double re)
52 {
53 double _Complex c;
54
55 __real__ c = re;
56 /* __imag__ c is left uninitialized */
57 sink(c); /* XXX: may be used before set */
58 }
59
60 /*
61 * Before tree.c 1.275 from 2021-04-09, lint wrongly warned that when
62 * '__imag__ c' was assigned, 'c may be used before set [158]'.
63 *
64 * As of 2021-04-09, support for _Complex is still very incomplete, see
65 * build_real_imag for details.
66 */
67 void
68 set_complex_only_imag(double im)
69 {
70 double _Complex c;
71
72 /* __real__ c is left uninitialized */
73 __imag__ c = im;
74 sink(c); /* XXX: may be used before set */
75 }
76
77 /* Just to keep the .exp file alive. */
78 void
79 trigger_warning(double _Complex c)
80 {
81 c += 1.0;
82 /* expect+1: error: operands of '|' have incompatible types 'double _Complex' and 'double _Complex' [107] */
83 return c | c;
84 }
85
86 void
87 precedence_cast_expression(void)
88 {
89 double _Complex z = 0;
90 if (b(__real__(double _Complex)z) && b(__imag__(double _Complex)z))
91 return;
92 if (b(__real__(z)) && b(__imag__(z)))
93 return;
94 }
95