Skip to content

Commit 5aa4654

Browse files
committed
[clang][Tests] Update diagnostic tests for function-like macros to clarify usage and improve error messages
1 parent 33e001e commit 5aa4654

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

clang/test/Preprocessor/macro_with_initializer_list.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ void test_NE() {
133133
// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:9-110:9}:"("
134134
// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:32-110:32}:")"
135135

136-
#define INIT(var, init) Foo var = init; // expected-note 3{{defined here}}
137-
// expected-note@-1 2{{'INIT' exists, but as a function-like macro; perhaps, did you forget the parentheses?}}
136+
#define INIT(var, init) Foo var = init; // expected-note 3{{macro 'INIT' defined here}}
137+
// expected-note@-1 2{{'INIT' is defined here as a function-like macro; did you mean to write 'INIT(...)'}}
138138
// Can't use an initializer list as a macro argument. The commas in the list
139139
// will be interpretted as argument separaters and adding parenthesis will
140140
// make it no longer an initializer list.
@@ -166,7 +166,7 @@ void test() {
166166
#define M(name,a,b,c,d,e,f,g,h,i,j,k,l) \
167167
Foo name = a + b + c + d + e + f + g + h + i + j + k + l;
168168
// expected-note@-2 2{{defined here}}
169-
// expected-note@-3 {{'M' exists, but as a function-like macro; perhaps, did you forget the parentheses?}}
169+
// expected-note@-3 {{'M' is defined here as a function-like macro; did you mean to write 'M(...)'}}
170170
void test2() {
171171
M(F1, Foo(), Foo(), Foo(), Foo(), Foo(), Foo(),
172172
Foo(), Foo(), Foo(), Foo(), Foo(), Foo());
@@ -182,3 +182,11 @@ void test2() {
182182
// expected-error@-3 {{use of undeclared identifier}}
183183
// expected-note@-4 {{cannot use initializer list at the beginning of a macro argument}}
184184
}
185+
186+
#define LIM() 10
187+
// expected-note@-1 {{'LIM' is defined here as a function-like macro; did you mean to write 'LIM(...)'}}
188+
189+
void test3() {
190+
int iter = LIM;
191+
// expected-error@-1 {{use of undeclared identifier LIM}}
192+
}

0 commit comments

Comments
 (0)