Skip to content

Commit c274178

Browse files
committed
[clang][Tests] Modify tests for function-like macros according to the new behavior and Format the changes
1 parent ea6c9ca commit c274178

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5961,8 +5961,9 @@ def err_fold_expression_limit_exceeded: Error<
59615961
"instantiating fold expression with %0 arguments exceeded expression nesting "
59625962
"limit of %1">, DefaultFatal, NoSFINAE;
59635963

5964-
def note_function_like_macro_requires_parens : Note<
5965-
"'%0' exists, but as a function-like macro; perhaps, did you forget the parentheses?">;
5964+
def note_function_like_macro_requires_parens
5965+
: Note<"'%0' exists, but as a function-like macro; perhaps, did you forget "
5966+
"the parentheses?">;
59665967
def err_unexpected_typedef : Error<
59675968
"unexpected type name %0: expected expression">;
59685969
def err_unexpected_namespace : Error<

clang/lib/Sema/SemaExpr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,8 +2527,9 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
25272527
if (II->hasMacroDefinition()) {
25282528
MacroInfo *MI = PP.getMacroInfo(II);
25292529
if (MI && MI->isFunctionLike()) {
2530-
Diag( R.getNameLoc() ,diag::err_undeclared_var_use) << II->getName();
2531-
Diag(MI->getDefinitionLoc(), diag::note_function_like_macro_requires_parens)
2530+
Diag(R.getNameLoc(), diag::err_undeclared_var_use) << II->getName();
2531+
Diag(MI->getDefinitionLoc(),
2532+
diag::note_function_like_macro_requires_parens)
25322533
<< II->getName();
25332534
return true;
25342535
}
@@ -2645,7 +2646,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
26452646
<< SS.getRange();
26462647
return true;
26472648
}
2648-
2649+
26492650
// Give up, we can't recover.
26502651
Diag(R.getNameLoc(), diagnostic) << Name;
26512652
return true;

clang/test/Preprocessor/macro_with_initializer_list.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ void test_NE() {
134134
// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:32-110:32}:")"
135135

136136
#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?}}
137138
// Can't use an initializer list as a macro argument. The commas in the list
138139
// will be interpretted as argument separaters and adding parenthesis will
139140
// make it no longer an initializer list.
@@ -159,12 +160,13 @@ void test() {
159160
// expected-note@-3 {{cannot use initializer list at the beginning of a macro argument}}
160161
}
161162

162-
// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:11-145:11}:"("
163-
// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:23-145:23}:")"
163+
// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:11-146:11}:"("
164+
// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:23-146:23}:")"
164165

165166
#define M(name,a,b,c,d,e,f,g,h,i,j,k,l) \
166167
Foo name = a + b + c + d + e + f + g + h + i + j + k + l;
167168
// expected-note@-2 2{{defined here}}
169+
// expected-note@-3 {{'M' exists, but as a function-like macro; perhaps, did you forget the parentheses?}}
168170
void test2() {
169171
M(F1, Foo(), Foo(), Foo(), Foo(), Foo(), Foo(),
170172
Foo(), Foo(), Foo(), Foo(), Foo(), Foo());

0 commit comments

Comments
 (0)