annotate gcc/testsuite/g++.dg/plugin/diagnostic-test-expressions-1.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* { dg-do compile } */
kono
parents:
diff changeset
2 /* { dg-options "-O -fdiagnostics-show-caret -fpermissive" } */
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 /* This is a collection of unittests to verify that we're correctly
kono
parents:
diff changeset
5 capturing the source code ranges of various kinds of expression.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 It uses the various "diagnostic_test_*_expression_range_plugin"
kono
parents:
diff changeset
8 plugins which handles "__emit_expression_range" by generating a warning
kono
parents:
diff changeset
9 at the given source range of the input argument. Each of the
kono
parents:
diff changeset
10 different plugins do this at a different phase of the internal
kono
parents:
diff changeset
11 representation (tree, gimple, etc), so we can verify that the
kono
parents:
diff changeset
12 source code range information is valid at each phase.
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 We want to accept an expression of any type. We use variadic arguments.
kono
parents:
diff changeset
15 For compatibility with the C tests we have a dummy argument, since
kono
parents:
diff changeset
16 C requires at least one argument before the ellipsis. */
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 extern void __emit_expression_range (int dummy, ...);
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 int global;
kono
parents:
diff changeset
21
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
22 void test_global (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
23 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
24 __emit_expression_range (0, global); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
25 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
26 __emit_expression_range (0, global);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
27 ^~~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
28 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
29 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
30
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
31 void test_param (int param)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
32 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
33 __emit_expression_range (0, param); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
34 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
35 __emit_expression_range (0, param);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
36 ^~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
37 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
38 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
39
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
40 void test_local (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
41 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
42 int local = 5;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
43
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
44 __emit_expression_range (0, local); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
45 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
46 __emit_expression_range (0, local);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
47 ^~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
48 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
49 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
50
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
51 void test_integer_constants (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
52 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
53 __emit_expression_range (0, 1234); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
54 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
55 __emit_expression_range (0, 1234);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
56 ^~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
57 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
58
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
59 /* Ensure that zero works. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
60
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
61 __emit_expression_range (0, 0); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
62 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
63 __emit_expression_range (0, 0);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
64 ^
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
65 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
66 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
67
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
68 void test_character_constants (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
69 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
70 __emit_expression_range (0, 'a'); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
71 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
72 __emit_expression_range (0, 'a');
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
73 ^~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
74 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
75 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
76
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
77 void test_floating_constants (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
78 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
79 __emit_expression_range (0, 98.6); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
80 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
81 __emit_expression_range (0, 98.6);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
82 ^~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
83 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
84
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
85 __emit_expression_range (0, .6); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
86 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
87 __emit_expression_range (0, .6);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
88 ^~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
89 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
90
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
91 __emit_expression_range (0, 98.); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
92 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
93 __emit_expression_range (0, 98.);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
94 ^~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
95 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
96
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
97 __emit_expression_range (0, 6.022140857e23 ); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
98 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
99 __emit_expression_range (0, 6.022140857e23 );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
100 ^~~~~~~~~~~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
101 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
102
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
103 __emit_expression_range (0, 98.6f ); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
104 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
105 __emit_expression_range (0, 98.6f );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
106 ^~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
107 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
108
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
109 __emit_expression_range (0, 6.022140857e23l ); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
110 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
111 __emit_expression_range (0, 6.022140857e23l );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
112 ^~~~~~~~~~~~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
113 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
114 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
115
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
116 enum test_enum {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
117 TEST_ENUM_VALUE
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
118 };
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
119
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
120 void test_enumeration_constant (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
121 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
122 __emit_expression_range (0, TEST_ENUM_VALUE ); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
123 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
124 __emit_expression_range (0, TEST_ENUM_VALUE );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
125 ^~~~~~~~~~~~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
126 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
127 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
128
111
kono
parents:
diff changeset
129 void test_parentheses (int a, int b)
kono
parents:
diff changeset
130 {
kono
parents:
diff changeset
131 __emit_expression_range (0, (a + b) ); /* { dg-warning "range" } */
kono
parents:
diff changeset
132 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
133 __emit_expression_range (0, (a + b) );
kono
parents:
diff changeset
134 ~~~^~~~
kono
parents:
diff changeset
135 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 __emit_expression_range (0, (a + b) * (a - b) ); /* { dg-warning "range" } */
kono
parents:
diff changeset
138 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
139 __emit_expression_range (0, (a + b) * (a - b) );
kono
parents:
diff changeset
140 ~~~~~~~~^~~~~~~~~
kono
parents:
diff changeset
141 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 __emit_expression_range (0, !(a && b) ); /* { dg-warning "range" } */
kono
parents:
diff changeset
144 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
145 __emit_expression_range (0, !(a && b) );
kono
parents:
diff changeset
146 ^~~~~~~~~
kono
parents:
diff changeset
147 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
148 }
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 /* Postfix expressions. ************************************************/
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 void test_array_reference (int *arr)
kono
parents:
diff changeset
153 {
kono
parents:
diff changeset
154 __emit_expression_range (0, arr[100] ); /* { dg-warning "range" } */
kono
parents:
diff changeset
155 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
156 __emit_expression_range (0, arr[100] );
kono
parents:
diff changeset
157 ~~~~~~~^
kono
parents:
diff changeset
158 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
159 }
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 int test_function_call (int p, int q, int r)
kono
parents:
diff changeset
162 {
kono
parents:
diff changeset
163 __emit_expression_range (0, test_function_call (p, q, r) ); /* { dg-warning "range" } */
kono
parents:
diff changeset
164 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
165 __emit_expression_range (0, test_function_call (p, q, r) );
kono
parents:
diff changeset
166 ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
kono
parents:
diff changeset
167 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
168 return 0;
kono
parents:
diff changeset
169 }
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 struct test_struct
kono
parents:
diff changeset
172 {
kono
parents:
diff changeset
173 int field;
kono
parents:
diff changeset
174 };
kono
parents:
diff changeset
175
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176 void test_structure_references (struct test_struct *ptr)
111
kono
parents:
diff changeset
177 {
kono
parents:
diff changeset
178 struct test_struct local;
kono
parents:
diff changeset
179 local.field = 42;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 __emit_expression_range (0, local.field ); /* { dg-warning "range" } */
kono
parents:
diff changeset
182 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
183 __emit_expression_range (0, local.field );
kono
parents:
diff changeset
184 ~~~~~~^~~~~
kono
parents:
diff changeset
185 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 __emit_expression_range (0, ptr->field ); /* { dg-warning "range" } */
kono
parents:
diff changeset
188 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
189 __emit_expression_range (0, ptr->field );
kono
parents:
diff changeset
190 ~~~~~^~~~~
kono
parents:
diff changeset
191 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
192 }
kono
parents:
diff changeset
193
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
194 void test_postfix_incdec (int i)
111
kono
parents:
diff changeset
195 {
kono
parents:
diff changeset
196 __emit_expression_range (0, i++ ); /* { dg-warning "range" } */
kono
parents:
diff changeset
197 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
198 __emit_expression_range (0, i++ );
kono
parents:
diff changeset
199 ~^~
kono
parents:
diff changeset
200 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 __emit_expression_range (0, i-- ); /* { dg-warning "range" } */
kono
parents:
diff changeset
203 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
204 __emit_expression_range (0, i-- );
kono
parents:
diff changeset
205 ~^~
kono
parents:
diff changeset
206 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
207 }
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 /* Unary operators. ****************************************************/
kono
parents:
diff changeset
210
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
211 void test_sizeof (int i)
111
kono
parents:
diff changeset
212 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
213 __emit_expression_range (0, sizeof i ); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
214 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
215 __emit_expression_range (0, sizeof i );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
216 ^~~~~~~~
111
kono
parents:
diff changeset
217 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
218
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
219 __emit_expression_range (0, sizeof (char) ); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
220 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
221 __emit_expression_range (0, sizeof (char) );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
222 ^~~~~~~~~~~~~
111
kono
parents:
diff changeset
223 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
224 }
kono
parents:
diff changeset
225
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
226 void test_alignof (int i)
111
kono
parents:
diff changeset
227 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
228 __emit_expression_range (0, alignof(int)); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
229 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
230 __emit_expression_range (0, alignof(int));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
231 ^~~~~~~~~~~~
111
kono
parents:
diff changeset
232 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
233
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
234 __emit_expression_range (0, __alignof__(int)); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
235 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
236 __emit_expression_range (0, __alignof__(int));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
237 ^~~~~~~~~~~~~~~~
111
kono
parents:
diff changeset
238 { dg-end-multiline-output "" } */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
239 __emit_expression_range (0, __alignof__ i); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
240 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
241 __emit_expression_range (0, __alignof__ i);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
242 ^~~~~~~~~~~~~
111
kono
parents:
diff changeset
243 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
244 }
kono
parents:
diff changeset
245
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
246 void test_prefix_incdec (int i)
111
kono
parents:
diff changeset
247 {
kono
parents:
diff changeset
248 __emit_expression_range (0, ++i ); /* { dg-warning "range" } */
kono
parents:
diff changeset
249 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
250 __emit_expression_range (0, ++i );
kono
parents:
diff changeset
251 ^~~
kono
parents:
diff changeset
252 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 __emit_expression_range (0, --i ); /* { dg-warning "range" } */
kono
parents:
diff changeset
255 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
256 __emit_expression_range (0, --i );
kono
parents:
diff changeset
257 ^~~
kono
parents:
diff changeset
258 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
259 }
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 void test_address_operator (void)
kono
parents:
diff changeset
262 {
kono
parents:
diff changeset
263 __emit_expression_range (0, &global ); /* { dg-warning "range" } */
kono
parents:
diff changeset
264 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
265 __emit_expression_range (0, &global );
kono
parents:
diff changeset
266 ^~~~~~~
kono
parents:
diff changeset
267 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
268 }
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 void test_indirection (int *ptr)
kono
parents:
diff changeset
271 {
kono
parents:
diff changeset
272 __emit_expression_range (0, *ptr ); /* { dg-warning "range" } */
kono
parents:
diff changeset
273 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
274 __emit_expression_range (0, *ptr );
kono
parents:
diff changeset
275 ^~~~
kono
parents:
diff changeset
276 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
277 }
kono
parents:
diff changeset
278
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
279 void test_unary_plus (int i)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
280 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
281 __emit_expression_range (0, +i ); /* { dg-warning "range" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
282 /* { dg-begin-multiline-output "" }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
283 __emit_expression_range (0, +i );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
284 ^~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
285 { dg-end-multiline-output "" } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
286 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
287
111
kono
parents:
diff changeset
288 void test_unary_minus (int i)
kono
parents:
diff changeset
289 {
kono
parents:
diff changeset
290 __emit_expression_range (0, -i ); /* { dg-warning "range" } */
kono
parents:
diff changeset
291 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
292 __emit_expression_range (0, -i );
kono
parents:
diff changeset
293 ^~
kono
parents:
diff changeset
294 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
295 }
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 void test_ones_complement (int i)
kono
parents:
diff changeset
298 {
kono
parents:
diff changeset
299 __emit_expression_range (0, ~i ); /* { dg-warning "range" } */
kono
parents:
diff changeset
300 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
301 __emit_expression_range (0, ~i );
kono
parents:
diff changeset
302 ^~
kono
parents:
diff changeset
303 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
304 }
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 void test_logical_negation (int flag)
kono
parents:
diff changeset
307 {
kono
parents:
diff changeset
308 __emit_expression_range (0, !flag ); /* { dg-warning "range" } */
kono
parents:
diff changeset
309 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
310 __emit_expression_range (0, !flag );
kono
parents:
diff changeset
311 ^~~~~
kono
parents:
diff changeset
312 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
313 }
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 /* Casts. ****************************************************/
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 void test_cast (void *ptr)
kono
parents:
diff changeset
318 {
kono
parents:
diff changeset
319 __emit_expression_range (0, (int *)ptr ); /* { dg-warning "range" } */
kono
parents:
diff changeset
320 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
321 __emit_expression_range (0, (int *)ptr );
kono
parents:
diff changeset
322 ^~~~~~~~~~
kono
parents:
diff changeset
323 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 __emit_expression_range (0, *(int *)0xdeadbeef ); /* { dg-warning "range" } */
kono
parents:
diff changeset
326 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
327 __emit_expression_range (0, *(int *)0xdeadbeef );
kono
parents:
diff changeset
328 ^~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
329 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 }
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 /* Binary operators. *******************************************/
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 void test_multiplicative_operators (int lhs, int rhs)
kono
parents:
diff changeset
336 {
kono
parents:
diff changeset
337 __emit_expression_range (0, lhs * rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
338 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
339 __emit_expression_range (0, lhs * rhs );
kono
parents:
diff changeset
340 ~~~~^~~~~
kono
parents:
diff changeset
341 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 __emit_expression_range (0, lhs / rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
344 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
345 __emit_expression_range (0, lhs / rhs );
kono
parents:
diff changeset
346 ~~~~^~~~~
kono
parents:
diff changeset
347 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 __emit_expression_range (0, lhs % rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
350 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
351 __emit_expression_range (0, lhs % rhs );
kono
parents:
diff changeset
352 ~~~~^~~~~
kono
parents:
diff changeset
353 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
354 }
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 void test_additive_operators (int lhs, int rhs)
kono
parents:
diff changeset
357 {
kono
parents:
diff changeset
358 __emit_expression_range (0, lhs + rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
359 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
360 __emit_expression_range (0, lhs + rhs );
kono
parents:
diff changeset
361 ~~~~^~~~~
kono
parents:
diff changeset
362 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 __emit_expression_range (0, lhs - rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
365 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
366 __emit_expression_range (0, lhs - rhs );
kono
parents:
diff changeset
367 ~~~~^~~~~
kono
parents:
diff changeset
368 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
369 }
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 void test_shift_operators (int lhs, int rhs)
kono
parents:
diff changeset
372 {
kono
parents:
diff changeset
373 __emit_expression_range (0, lhs << rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
374 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
375 __emit_expression_range (0, lhs << rhs );
kono
parents:
diff changeset
376 ~~~~^~~~~~
kono
parents:
diff changeset
377 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 __emit_expression_range (0, lhs >> rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
380 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
381 __emit_expression_range (0, lhs >> rhs );
kono
parents:
diff changeset
382 ~~~~^~~~~~
kono
parents:
diff changeset
383 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
384 }
kono
parents:
diff changeset
385
kono
parents:
diff changeset
386 void test_relational_operators (int lhs, int rhs)
kono
parents:
diff changeset
387 {
kono
parents:
diff changeset
388 __emit_expression_range (0, lhs < rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
389 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
390 __emit_expression_range (0, lhs < rhs );
kono
parents:
diff changeset
391 ~~~~^~~~~
kono
parents:
diff changeset
392 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 __emit_expression_range (0, lhs > rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
395 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
396 __emit_expression_range (0, lhs > rhs );
kono
parents:
diff changeset
397 ~~~~^~~~~
kono
parents:
diff changeset
398 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 __emit_expression_range (0, lhs <= rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
401 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
402 __emit_expression_range (0, lhs <= rhs );
kono
parents:
diff changeset
403 ~~~~^~~~~~
kono
parents:
diff changeset
404 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 __emit_expression_range (0, lhs >= rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
407 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
408 __emit_expression_range (0, lhs >= rhs );
kono
parents:
diff changeset
409 ~~~~^~~~~~
kono
parents:
diff changeset
410 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
411 }
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 void test_equality_operators (int lhs, int rhs)
kono
parents:
diff changeset
414 {
kono
parents:
diff changeset
415 __emit_expression_range (0, lhs == rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
416 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
417 __emit_expression_range (0, lhs == rhs );
kono
parents:
diff changeset
418 ~~~~^~~~~~
kono
parents:
diff changeset
419 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
420
kono
parents:
diff changeset
421 __emit_expression_range (0, lhs != rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
422 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
423 __emit_expression_range (0, lhs != rhs );
kono
parents:
diff changeset
424 ~~~~^~~~~~
kono
parents:
diff changeset
425 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
426 }
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 void test_bitwise_binary_operators (int lhs, int rhs)
kono
parents:
diff changeset
429 {
kono
parents:
diff changeset
430 __emit_expression_range (0, lhs & rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
431 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
432 __emit_expression_range (0, lhs & rhs );
kono
parents:
diff changeset
433 ~~~~^~~~~
kono
parents:
diff changeset
434 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436 __emit_expression_range (0, lhs ^ rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
437 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
438 __emit_expression_range (0, lhs ^ rhs );
kono
parents:
diff changeset
439 ~~~~^~~~~
kono
parents:
diff changeset
440 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 __emit_expression_range (0, lhs | rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
443 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
444 __emit_expression_range (0, lhs | rhs );
kono
parents:
diff changeset
445 ~~~~^~~~~
kono
parents:
diff changeset
446 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
447 }
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 void test_logical_operators (int lhs, int rhs)
kono
parents:
diff changeset
450 {
kono
parents:
diff changeset
451 __emit_expression_range (0, lhs && rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
452 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
453 __emit_expression_range (0, lhs && rhs );
kono
parents:
diff changeset
454 ~~~~^~~~~~
kono
parents:
diff changeset
455 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
456
kono
parents:
diff changeset
457 __emit_expression_range (0, lhs || rhs ); /* { dg-warning "range" } */
kono
parents:
diff changeset
458 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
459 __emit_expression_range (0, lhs || rhs );
kono
parents:
diff changeset
460 ~~~~^~~~~~
kono
parents:
diff changeset
461 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
462 }
kono
parents:
diff changeset
463
kono
parents:
diff changeset
464 /* Conditional operator. *******************************************/
kono
parents:
diff changeset
465
kono
parents:
diff changeset
466 void test_conditional_operators (int flag, int on_true, int on_false)
kono
parents:
diff changeset
467 {
kono
parents:
diff changeset
468 __emit_expression_range (0, flag ? on_true : on_false ); /* { dg-warning "range" } */
kono
parents:
diff changeset
469 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
470 __emit_expression_range (0, flag ? on_true : on_false );
kono
parents:
diff changeset
471 ~~~~~^~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
472 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
473 }
kono
parents:
diff changeset
474
kono
parents:
diff changeset
475 /* Assignment expressions. *******************************************/
kono
parents:
diff changeset
476
kono
parents:
diff changeset
477 void test_assignment_expressions (int dest, int other)
kono
parents:
diff changeset
478 {
kono
parents:
diff changeset
479 __emit_expression_range (0, dest = other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
480 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
481 __emit_expression_range (0, dest = other );
kono
parents:
diff changeset
482 ~~~~~^~~~~~~
kono
parents:
diff changeset
483 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
484
kono
parents:
diff changeset
485 __emit_expression_range (0, dest *= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
486 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
487 __emit_expression_range (0, dest *= other );
kono
parents:
diff changeset
488 ~~~~~^~~~~~~~
kono
parents:
diff changeset
489 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
490
kono
parents:
diff changeset
491 __emit_expression_range (0, dest /= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
492 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
493 __emit_expression_range (0, dest /= other );
kono
parents:
diff changeset
494 ~~~~~^~~~~~~~
kono
parents:
diff changeset
495 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
496
kono
parents:
diff changeset
497 __emit_expression_range (0, dest %= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
498 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
499 __emit_expression_range (0, dest %= other );
kono
parents:
diff changeset
500 ~~~~~^~~~~~~~
kono
parents:
diff changeset
501 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
502
kono
parents:
diff changeset
503 __emit_expression_range (0, dest += other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
504 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
505 __emit_expression_range (0, dest += other );
kono
parents:
diff changeset
506 ~~~~~^~~~~~~~
kono
parents:
diff changeset
507 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 __emit_expression_range (0, dest -= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
510 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
511 __emit_expression_range (0, dest -= other );
kono
parents:
diff changeset
512 ~~~~~^~~~~~~~
kono
parents:
diff changeset
513 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515 __emit_expression_range (0, dest <<= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
516 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
517 __emit_expression_range (0, dest <<= other );
kono
parents:
diff changeset
518 ~~~~~^~~~~~~~~
kono
parents:
diff changeset
519 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
520
kono
parents:
diff changeset
521 __emit_expression_range (0, dest >>= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
522 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
523 __emit_expression_range (0, dest >>= other );
kono
parents:
diff changeset
524 ~~~~~^~~~~~~~~
kono
parents:
diff changeset
525 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
526
kono
parents:
diff changeset
527 __emit_expression_range (0, dest &= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
528 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
529 __emit_expression_range (0, dest &= other );
kono
parents:
diff changeset
530 ~~~~~^~~~~~~~
kono
parents:
diff changeset
531 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
532
kono
parents:
diff changeset
533 __emit_expression_range (0, dest ^= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
534 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
535 __emit_expression_range (0, dest ^= other );
kono
parents:
diff changeset
536 ~~~~~^~~~~~~~
kono
parents:
diff changeset
537 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
538
kono
parents:
diff changeset
539 __emit_expression_range (0, dest |= other ); /* { dg-warning "range" } */
kono
parents:
diff changeset
540 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
541 __emit_expression_range (0, dest |= other );
kono
parents:
diff changeset
542 ~~~~~^~~~~~~~
kono
parents:
diff changeset
543 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
544 }
kono
parents:
diff changeset
545
kono
parents:
diff changeset
546 /* Comma operator. *******************************************/
kono
parents:
diff changeset
547
kono
parents:
diff changeset
548 void test_comma_operator (int a, int b)
kono
parents:
diff changeset
549 {
kono
parents:
diff changeset
550 __emit_expression_range (0, (a++, a + b) ); /* { dg-warning "range" } */
kono
parents:
diff changeset
551 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
552 __emit_expression_range (0, (a++, a + b) );
kono
parents:
diff changeset
553 ~~~~^~~~~~~~
kono
parents:
diff changeset
554 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
555 }
kono
parents:
diff changeset
556
kono
parents:
diff changeset
557 /* Literals. **************************************************/
kono
parents:
diff changeset
558
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
559 void test_string_literals ()
111
kono
parents:
diff changeset
560 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
561 __emit_expression_range (0, "0123456789"); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
562 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
563 __emit_expression_range (0, "0123456789");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
564 ^~~~~~~~~~~~
111
kono
parents:
diff changeset
565 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
566
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
567 __emit_expression_range (0, "foo" "bar" ); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
568 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
569 __emit_expression_range (0, "foo" "bar" );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
570 ^~~~~~~~~~~
111
kono
parents:
diff changeset
571 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
572 }
kono
parents:
diff changeset
573
kono
parents:
diff changeset
574 void test_numeric_literals (int i)
kono
parents:
diff changeset
575 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
576 __emit_expression_range (0, 42 ); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
577 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
578 __emit_expression_range (0, 42 );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
579 ^~
111
kono
parents:
diff changeset
580 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
581
kono
parents:
diff changeset
582 /* Verify locations of negative literals (via folding of
kono
parents:
diff changeset
583 unary negation). */
kono
parents:
diff changeset
584
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
585 __emit_expression_range (0, -42 ); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
586 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
587 __emit_expression_range (0, -42 );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
588 ^~~
111
kono
parents:
diff changeset
589 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
590
kono
parents:
diff changeset
591 __emit_expression_range (0, i ? 0 : -1 ); /* { dg-warning "range" } */
kono
parents:
diff changeset
592 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
593 __emit_expression_range (0, i ? 0 : -1 );
kono
parents:
diff changeset
594 ~~^~~~~~~~
kono
parents:
diff changeset
595 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
596 }
kono
parents:
diff changeset
597
kono
parents:
diff changeset
598 /* Braced initializers. ***************************************/
kono
parents:
diff changeset
599
kono
parents:
diff changeset
600 /* We can't test the ranges of these directly, since the underlying
kono
parents:
diff changeset
601 tree nodes don't retain a location. However, we can test that they
kono
parents:
diff changeset
602 have ranges during parsing by building compound expressions using
kono
parents:
diff changeset
603 them, and verifying the ranges of the compound expressions. */
kono
parents:
diff changeset
604
kono
parents:
diff changeset
605 #define vector(elcount, type) \
kono
parents:
diff changeset
606 __attribute__((vector_size((elcount)*sizeof(type)))) type
kono
parents:
diff changeset
607
kono
parents:
diff changeset
608 void test_braced_init (void)
kono
parents:
diff changeset
609 {
kono
parents:
diff changeset
610 /* Verify start of range. */
kono
parents:
diff changeset
611 __emit_expression_range (0, (vector(4, float)){2., 2., 2., 2.} + 1); /* { dg-warning "range" } */
kono
parents:
diff changeset
612 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
613 __emit_expression_range (0, (vector(4, float)){2., 2., 2., 2.} + 1);
kono
parents:
diff changeset
614 ~~~~~~~~~~~~~~~~~^~~
kono
parents:
diff changeset
615 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
616
kono
parents:
diff changeset
617 /* Verify end of range. */
kono
parents:
diff changeset
618 __emit_expression_range (0, 1 + (vector(4, float)){2., 2., 2., 2.}); /* { dg-warning "range" } */
kono
parents:
diff changeset
619 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
620 __emit_expression_range (0, 1 + (vector(4, float)){2., 2., 2., 2.});
kono
parents:
diff changeset
621 ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
622 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
623 }
kono
parents:
diff changeset
624
kono
parents:
diff changeset
625 /* Statement expressions. ***************************************/
kono
parents:
diff changeset
626
kono
parents:
diff changeset
627 void test_statement_expression (void)
kono
parents:
diff changeset
628 {
kono
parents:
diff changeset
629 __emit_expression_range (0, ({ static int a; a; }) + 1); /* { dg-warning "range" } */
kono
parents:
diff changeset
630 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
631 __emit_expression_range (0, ({ static int a; a; }) + 1);
kono
parents:
diff changeset
632 ~~~~~~~~~~~~~~~~~~~~~~~^~~
kono
parents:
diff changeset
633 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
634
kono
parents:
diff changeset
635 __emit_expression_range (0, 1 + ({ static int a; a; }) ); /* { dg-warning "range" } */
kono
parents:
diff changeset
636 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
637 __emit_expression_range (0, 1 + ({ static int a; a; }) );
kono
parents:
diff changeset
638 ~~^~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
639 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
640 }
kono
parents:
diff changeset
641
kono
parents:
diff changeset
642 /* Other expressions. */
kono
parents:
diff changeset
643
kono
parents:
diff changeset
644 void test_address_of_label (void)
kono
parents:
diff changeset
645 {
kono
parents:
diff changeset
646 label:
kono
parents:
diff changeset
647 __emit_expression_range (0, &&label ); /* { dg-warning "range" } */
kono
parents:
diff changeset
648 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
649 __emit_expression_range (0, &&label );
kono
parents:
diff changeset
650 ^~~~~~~
kono
parents:
diff changeset
651 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
652 }
kono
parents:
diff changeset
653
kono
parents:
diff changeset
654 void test_transaction_expressions (void)
kono
parents:
diff changeset
655 {
kono
parents:
diff changeset
656 int i;
kono
parents:
diff changeset
657 i = __transaction_atomic (42); /* { dg-error "without transactional memory support enabled" } */
kono
parents:
diff changeset
658 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
659 i = __transaction_atomic (42);
kono
parents:
diff changeset
660 ^~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
661 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
662 i = __transaction_relaxed (42); /* { dg-error "without transactional memory support enabled" } */
kono
parents:
diff changeset
663 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
664 i = __transaction_relaxed (42);
kono
parents:
diff changeset
665 ^~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
666 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
667 }
kono
parents:
diff changeset
668
kono
parents:
diff changeset
669 void test_keywords (int i)
kono
parents:
diff changeset
670 {
kono
parents:
diff changeset
671 __emit_expression_range (0, __FUNCTION__[i] ); /* { dg-warning "range" } */
kono
parents:
diff changeset
672 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
673 __emit_expression_range (0, __FUNCTION__[i] );
kono
parents:
diff changeset
674 ~~~~~~~~~~~~~~^
kono
parents:
diff changeset
675 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
676
kono
parents:
diff changeset
677 __emit_expression_range (0, __PRETTY_FUNCTION__[i] ); /* { dg-warning "range" } */
kono
parents:
diff changeset
678 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
679 __emit_expression_range (0, __PRETTY_FUNCTION__[i] );
kono
parents:
diff changeset
680 ~~~~~~~~~~~~~~~~~~~~~^
kono
parents:
diff changeset
681 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
682
kono
parents:
diff changeset
683 __emit_expression_range (0, __func__[i] ); /* { dg-warning "range" } */
kono
parents:
diff changeset
684 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
685 __emit_expression_range (0, __func__[i] );
kono
parents:
diff changeset
686 ~~~~~~~~~~^
kono
parents:
diff changeset
687 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
688 }
kono
parents:
diff changeset
689
kono
parents:
diff changeset
690 void test_builtin_va_arg (__builtin_va_list v)
kono
parents:
diff changeset
691 {
kono
parents:
diff changeset
692 __emit_expression_range (0, __builtin_va_arg (v, int) ); /* { dg-warning "range" } */
kono
parents:
diff changeset
693 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
694 __emit_expression_range (0, __builtin_va_arg (v, int) );
kono
parents:
diff changeset
695 ~~~~~~~~~~~~~~~~~~~~~^~~~
kono
parents:
diff changeset
696 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
697
kono
parents:
diff changeset
698 __emit_expression_range (0, __builtin_va_arg (v, int) + 1 ); /* { dg-warning "range" } */
kono
parents:
diff changeset
699 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
700 __emit_expression_range (0, __builtin_va_arg (v, int) + 1 );
kono
parents:
diff changeset
701 ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
kono
parents:
diff changeset
702 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
703 }
kono
parents:
diff changeset
704
kono
parents:
diff changeset
705 struct s { int i; float f; };
kono
parents:
diff changeset
706
kono
parents:
diff changeset
707 void test_builtin_offsetof (int i)
kono
parents:
diff changeset
708 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
709 __emit_expression_range (0, __builtin_offsetof (struct s, f) ); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
710 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
711 __emit_expression_range (0, __builtin_offsetof (struct s, f) );
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
712 ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
111
kono
parents:
diff changeset
713 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
714 }
kono
parents:
diff changeset
715
kono
parents:
diff changeset
716 /* Examples of non-trivial expressions. ****************************/
kono
parents:
diff changeset
717
kono
parents:
diff changeset
718 extern double sqrt (double x);
kono
parents:
diff changeset
719
kono
parents:
diff changeset
720 void test_quadratic (double a, double b, double c)
kono
parents:
diff changeset
721 {
kono
parents:
diff changeset
722 __emit_expression_range (0, b * b - 4 * a * c ); /* { dg-warning "range" } */
kono
parents:
diff changeset
723 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
724 __emit_expression_range (0, b * b - 4 * a * c );
kono
parents:
diff changeset
725 ~~~~~~^~~~~~~~~~~
kono
parents:
diff changeset
726 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
727
kono
parents:
diff changeset
728 __emit_expression_range (0,
kono
parents:
diff changeset
729 (-b + sqrt (b * b - 4 * a * c))
kono
parents:
diff changeset
730 / (2 * a)); /* { dg-warning "range" } */
kono
parents:
diff changeset
731 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
732 (-b + sqrt (b * b - 4 * a * c))
kono
parents:
diff changeset
733 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
734 / (2 * a));
kono
parents:
diff changeset
735 ^~~~~~~~~
kono
parents:
diff changeset
736 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
737
kono
parents:
diff changeset
738 }
kono
parents:
diff changeset
739
kono
parents:
diff changeset
740 int bar (int);
kono
parents:
diff changeset
741 void test_combinations (int a)
kono
parents:
diff changeset
742 {
kono
parents:
diff changeset
743 __emit_expression_range (0, bar (a) > a ); /* { dg-warning "range" } */
kono
parents:
diff changeset
744 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
745 __emit_expression_range (0, bar (a) > a );
kono
parents:
diff changeset
746 ~~~~~~~~^~~
kono
parents:
diff changeset
747 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
748 }
kono
parents:
diff changeset
749
kono
parents:
diff changeset
750 /* C++-specific expresssions. ****************************************/
kono
parents:
diff changeset
751
kono
parents:
diff changeset
752 void test_cp_literal_keywords (int a, int b)
kono
parents:
diff changeset
753 {
kono
parents:
diff changeset
754 this; /* { dg-error "invalid use of 'this' in non-member function" } */
kono
parents:
diff changeset
755 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
756 this;
kono
parents:
diff changeset
757 ^~~~
kono
parents:
diff changeset
758 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
759
kono
parents:
diff changeset
760 }
kono
parents:
diff changeset
761
kono
parents:
diff changeset
762 class base {
kono
parents:
diff changeset
763 public:
kono
parents:
diff changeset
764 base ();
kono
parents:
diff changeset
765 base (int i);
kono
parents:
diff changeset
766 virtual ~base ();
kono
parents:
diff changeset
767 int pub ();
kono
parents:
diff changeset
768 private:
kono
parents:
diff changeset
769 int priv ();
kono
parents:
diff changeset
770 };
kono
parents:
diff changeset
771 class derived : public base { ~derived (); };
kono
parents:
diff changeset
772
kono
parents:
diff changeset
773 void test_cp_casts (base *ptr)
kono
parents:
diff changeset
774 {
kono
parents:
diff changeset
775 __emit_expression_range (0, dynamic_cast <derived *> (ptr)); /* { dg-warning "range" } */
kono
parents:
diff changeset
776 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
777 __emit_expression_range (0, dynamic_cast <derived *> (ptr));
kono
parents:
diff changeset
778 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
779 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
780
kono
parents:
diff changeset
781 __emit_expression_range (0, static_cast <derived *> (ptr)); /* { dg-warning "range" } */
kono
parents:
diff changeset
782 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
783 __emit_expression_range (0, static_cast <derived *> (ptr));
kono
parents:
diff changeset
784 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
785 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
786
kono
parents:
diff changeset
787 __emit_expression_range (0, reinterpret_cast <int *> (ptr)); /* { dg-warning "range" } */
kono
parents:
diff changeset
788 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
789 __emit_expression_range (0, reinterpret_cast <int *> (ptr));
kono
parents:
diff changeset
790 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
791 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
792
kono
parents:
diff changeset
793 __emit_expression_range (0, const_cast <base *> (ptr)); /* { dg-warning "range" } */
kono
parents:
diff changeset
794 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
795 __emit_expression_range (0, const_cast <base *> (ptr));
kono
parents:
diff changeset
796 ^~~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
797 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
798 }
kono
parents:
diff changeset
799
kono
parents:
diff changeset
800 void test_functional_casts (int i, float f)
kono
parents:
diff changeset
801 {
kono
parents:
diff changeset
802 __emit_expression_range (0, float(i)); /* { dg-warning "range" } */
kono
parents:
diff changeset
803 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
804 __emit_expression_range (0, float(i));
kono
parents:
diff changeset
805 ^~~~~~~~
kono
parents:
diff changeset
806 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
807
kono
parents:
diff changeset
808 __emit_expression_range (0, int(f)); /* { dg-warning "range" } */
kono
parents:
diff changeset
809 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
810 __emit_expression_range (0, int(f));
kono
parents:
diff changeset
811 ^~~~~~
kono
parents:
diff changeset
812 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
813
kono
parents:
diff changeset
814 __emit_expression_range (0, s{i, f}); /* { dg-warning "range" } */
kono
parents:
diff changeset
815 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
816 __emit_expression_range (0, s{i, f});
kono
parents:
diff changeset
817 ^~~~~~~
kono
parents:
diff changeset
818 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
819 }
kono
parents:
diff changeset
820
kono
parents:
diff changeset
821 template <typename TYPENAME>
kono
parents:
diff changeset
822 class example_template
kono
parents:
diff changeset
823 {
kono
parents:
diff changeset
824 public:
kono
parents:
diff changeset
825 example_template (TYPENAME v);
kono
parents:
diff changeset
826 };
kono
parents:
diff changeset
827
kono
parents:
diff changeset
828 void test_template_id (void)
kono
parents:
diff changeset
829 {
kono
parents:
diff changeset
830 example_template <int>; /* { dg-warning "declaration does not declare anything" } */
kono
parents:
diff changeset
831 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
832 example_template <int>;
kono
parents:
diff changeset
833 ^~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
834 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
835 }
kono
parents:
diff changeset
836
kono
parents:
diff changeset
837 void test_new (void)
kono
parents:
diff changeset
838 {
kono
parents:
diff changeset
839 __emit_expression_range (0, ::new base); /* { dg-warning "range" } */
kono
parents:
diff changeset
840 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
841 __emit_expression_range (0, ::new base);
kono
parents:
diff changeset
842 ^~~~~~~~~~
kono
parents:
diff changeset
843 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
844
kono
parents:
diff changeset
845 __emit_expression_range (0, new base); /* { dg-warning "range" } */
kono
parents:
diff changeset
846 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
847 __emit_expression_range (0, new base);
kono
parents:
diff changeset
848 ^~~~~~~~
kono
parents:
diff changeset
849 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
850
kono
parents:
diff changeset
851 __emit_expression_range (0, new (base)); /* { dg-warning "range" } */
kono
parents:
diff changeset
852 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
853 __emit_expression_range (0, new (base));
kono
parents:
diff changeset
854 ^~~~~~~~~~
kono
parents:
diff changeset
855 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
856
kono
parents:
diff changeset
857 __emit_expression_range (0, new base (42)); /* { dg-warning "range" } */
kono
parents:
diff changeset
858 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
859 __emit_expression_range (0, new base (42));
kono
parents:
diff changeset
860 ^~~~~~~~~~~~~
kono
parents:
diff changeset
861 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
862
kono
parents:
diff changeset
863 __emit_expression_range (0, new (base) (42)); /* { dg-warning "range" } */
kono
parents:
diff changeset
864 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
865 __emit_expression_range (0, new (base) (42));
kono
parents:
diff changeset
866 ^~~~~~~~~~~~~~~
kono
parents:
diff changeset
867 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
868
kono
parents:
diff changeset
869 /* TODO: placement new. */
kono
parents:
diff changeset
870
kono
parents:
diff changeset
871 __emit_expression_range (0, new example_template<int> (42)); /* { dg-warning "range" } */
kono
parents:
diff changeset
872 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
873 __emit_expression_range (0, new example_template<int> (42));
kono
parents:
diff changeset
874 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
875 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
876 }
kono
parents:
diff changeset
877
kono
parents:
diff changeset
878 void test_methods ()
kono
parents:
diff changeset
879 {
kono
parents:
diff changeset
880 __emit_expression_range (0, ((base *)1)->pub () ); /* { dg-warning "range" } */
kono
parents:
diff changeset
881 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
882 __emit_expression_range (0, ((base *)1)->pub () );
kono
parents:
diff changeset
883 ~~~~~~~~~~~~~~~~~^~
kono
parents:
diff changeset
884 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
885
kono
parents:
diff changeset
886 ((base *)1)->priv (); // { dg-error " is private " }
kono
parents:
diff changeset
887 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
888 ((base *)1)->priv ();
kono
parents:
diff changeset
889 ^
kono
parents:
diff changeset
890 { dg-end-multiline-output "" }
kono
parents:
diff changeset
891 { dg-begin-multiline-output "" }
kono
parents:
diff changeset
892 int priv ();
kono
parents:
diff changeset
893 ^~~~
kono
parents:
diff changeset
894 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
895 }
kono
parents:
diff changeset
896
kono
parents:
diff changeset
897 class tests
kono
parents:
diff changeset
898 {
kono
parents:
diff changeset
899 public:
kono
parents:
diff changeset
900 void test_method_calls ();
kono
parents:
diff changeset
901 int some_method () const;
kono
parents:
diff changeset
902 };
kono
parents:
diff changeset
903
kono
parents:
diff changeset
904 void
kono
parents:
diff changeset
905 tests::test_method_calls ()
kono
parents:
diff changeset
906 {
kono
parents:
diff changeset
907 __emit_expression_range (0, this->some_method () ); /* { dg-warning "range" } */
kono
parents:
diff changeset
908 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
909 __emit_expression_range (0, this->some_method () );
kono
parents:
diff changeset
910 ~~~~~~~~~~~~~~~~~~^~
kono
parents:
diff changeset
911 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
912 }
kono
parents:
diff changeset
913
kono
parents:
diff changeset
914 namespace std
kono
parents:
diff changeset
915 {
kono
parents:
diff changeset
916 class type_info { public: int foo; };
kono
parents:
diff changeset
917 }
kono
parents:
diff changeset
918
kono
parents:
diff changeset
919 void test_typeid (int i)
kono
parents:
diff changeset
920 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
921 __emit_expression_range (0, typeid(i)); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
922 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
923 __emit_expression_range (0, typeid(i));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
924 ^~~~~~~~~
111
kono
parents:
diff changeset
925 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
926
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
927 __emit_expression_range (0, typeid(int)); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
928 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
929 __emit_expression_range (0, typeid(int));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
930 ^~~~~~~~~~~
111
kono
parents:
diff changeset
931 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
932
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
933 __emit_expression_range (0, typeid(i * 2)); /* { dg-warning "range" } */
111
kono
parents:
diff changeset
934 /* { dg-begin-multiline-output "" }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
935 __emit_expression_range (0, typeid(i * 2));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
936 ^~~~~~~~~~~~~
111
kono
parents:
diff changeset
937 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
938 }
kono
parents:
diff changeset
939
kono
parents:
diff changeset
940 /* Various tests of locations involving macros. */
kono
parents:
diff changeset
941
kono
parents:
diff changeset
942 void test_within_macro_1 (int lhs, int rhs)
kono
parents:
diff changeset
943 {
kono
parents:
diff changeset
944 #define MACRO_1(EXPR) EXPR
kono
parents:
diff changeset
945
kono
parents:
diff changeset
946 __emit_expression_range (0, MACRO_1 (lhs == rhs));
kono
parents:
diff changeset
947
kono
parents:
diff changeset
948 /* { dg-warning "range" "" { target *-*-* } .-2 } */
kono
parents:
diff changeset
949 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
950 __emit_expression_range (0, MACRO_1 (lhs == rhs));
kono
parents:
diff changeset
951 ~~~~^~~~~~
kono
parents:
diff changeset
952 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
953 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
954 #define MACRO_1(EXPR) EXPR
kono
parents:
diff changeset
955 ^~~~
kono
parents:
diff changeset
956 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
957
kono
parents:
diff changeset
958 #undef MACRO_1
kono
parents:
diff changeset
959 }
kono
parents:
diff changeset
960
kono
parents:
diff changeset
961 void test_within_macro_2 (int lhs, int rhs)
kono
parents:
diff changeset
962 {
kono
parents:
diff changeset
963 #define MACRO_2(EXPR) EXPR
kono
parents:
diff changeset
964
kono
parents:
diff changeset
965 __emit_expression_range (0, MACRO_2 (MACRO_2 (lhs == rhs)));
kono
parents:
diff changeset
966
kono
parents:
diff changeset
967 /* { dg-warning "range" "" { target *-*-* } .-2 } */
kono
parents:
diff changeset
968 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
969 __emit_expression_range (0, MACRO_2 (MACRO_2 (lhs == rhs)));
kono
parents:
diff changeset
970 ~~~~^~~~~~
kono
parents:
diff changeset
971 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
972 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
973 __emit_expression_range (0, MACRO_2 (MACRO_2 (lhs == rhs)));
kono
parents:
diff changeset
974 ^~~~~~~
kono
parents:
diff changeset
975 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
976 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
977 #define MACRO_2(EXPR) EXPR
kono
parents:
diff changeset
978 ^~~~
kono
parents:
diff changeset
979 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
980
kono
parents:
diff changeset
981 #undef MACRO_2
kono
parents:
diff changeset
982 }
kono
parents:
diff changeset
983
kono
parents:
diff changeset
984 void test_within_macro_3 (int lhs, int rhs)
kono
parents:
diff changeset
985 {
kono
parents:
diff changeset
986 #define MACRO_3(EXPR) EXPR
kono
parents:
diff changeset
987
kono
parents:
diff changeset
988 __emit_expression_range (0, MACRO_3 (lhs) == MACRO_3 (rhs));
kono
parents:
diff changeset
989
kono
parents:
diff changeset
990 /* { dg-warning "range" "" { target *-*-* } .-2 } */
kono
parents:
diff changeset
991 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
992 __emit_expression_range (0, MACRO_3 (lhs) == MACRO_3 (rhs));
kono
parents:
diff changeset
993 ^
kono
parents:
diff changeset
994 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
995
kono
parents:
diff changeset
996 #undef MACRO_3
kono
parents:
diff changeset
997 }
kono
parents:
diff changeset
998
kono
parents:
diff changeset
999 void test_within_macro_4 (int lhs, int rhs)
kono
parents:
diff changeset
1000 {
kono
parents:
diff changeset
1001 #define MACRO_4(EXPR) EXPR
kono
parents:
diff changeset
1002
kono
parents:
diff changeset
1003 __emit_expression_range (0, MACRO_4 (MACRO_4 (lhs) == MACRO_4 (rhs)));
kono
parents:
diff changeset
1004
kono
parents:
diff changeset
1005 /* { dg-warning "range" "" { target *-*-* } .-2 } */
kono
parents:
diff changeset
1006 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
1007 __emit_expression_range (0, MACRO_4 (MACRO_4 (lhs) == MACRO_4 (rhs)));
kono
parents:
diff changeset
1008 ^
kono
parents:
diff changeset
1009 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
1010 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
1011 #define MACRO_4(EXPR) EXPR
kono
parents:
diff changeset
1012 ^~~~
kono
parents:
diff changeset
1013 { dg-end-multiline-output "" } */
kono
parents:
diff changeset
1014
kono
parents:
diff changeset
1015 #undef MACRO_4
kono
parents:
diff changeset
1016 }