Skip to content

Commit

Permalink
[clang][Sema] Update diagnostic tests for object-like macros in initi…
Browse files Browse the repository at this point in the history
…alizer list tests
  • Loading branch information
StarOne01 committed Feb 12, 2025
1 parent e4d2186 commit cc50469
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -10858,7 +10858,7 @@ def err_undeclared_use_suggest : Error<
def err_undeclared_var_use_suggest : Error<
"use of undeclared identifier %0; did you mean %1?">;
def err_undeclared_var_use_suggest_func_like_macro : Error<
"%0 is defined as an object-like macro; did you mean '%0(...)'?">;
"'%0' is defined as an object-like macro; did you mean '%0(...)'?">;
def err_no_template : Error<"no template named %0">;
def err_no_template_suggest : Error<"no template named %0; did you mean %1?">;
def err_no_member_template : Error<"no template named %0 in %1">;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2358,7 +2358,7 @@ static bool diagnoseFunctionLikeMacro(Sema &SemaRef, DeclarationName Name,
if (MI && MI->isFunctionLike()) {
SemaRef.Diag(TypoLoc,
diag::err_undeclared_var_use_suggest_func_like_macro)
<< II;
<< II ->getName();
SemaRef.Diag(MI->getDefinitionLoc(),
diag::note_function_like_macro_requires_parens)
<< II->getName();
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Preprocessor/macro_with_initializer_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ void test() {
// Can't be fixed by parentheses.
INIT(e, {1, 2, 3});
// expected-error@-1 {{too many arguments provided}}
// expected-error@-2 {{use of undeclared identifier}}
// expected-error@-2 {{'INIT' is defined as an object-like macro; did you mean 'INIT(...)'?}}
// expected-note@-3 {{cannot use initializer list at the beginning of a macro argument}}

// Can't be fixed by parentheses.
INIT(e, {1, 2, 3} + {1, 2, 3});
// expected-error@-1 {{too many arguments provided}}
// expected-error@-2 {{use of undeclared identifier}}
// expected-error@-2 {{'INIT' is defined as an object-like macro; did you mean 'INIT(...)'?}}
// expected-note@-3 {{cannot use initializer list at the beginning of a macro argument}}
}

Expand All @@ -179,6 +179,6 @@ void test2() {
M(F3, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3},
{1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3});
// expected-error@-2 {{too many arguments provided}}
// expected-error@-3 {{use of undeclared identifier}}
// expected-error@-3 {{'M' is defined as an object-like macro; did you mean 'M(...)'?}}
// expected-note@-4 {{cannot use initializer list at the beginning of a macro argument}}
}
8 changes: 4 additions & 4 deletions clang/test/Sema/typo-correction.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ void PR40286_4(int the_value) { // expected-note {{'the_value' declared here}}
#define FOO1() 10
// expected-note@-1 4 {{'FOO1' defined here as a function-like macro}}

int x = FOO1; // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
int x = FOO1; // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1(...)'?}}

void test3() {
int iter = FOO1;
// expected-error@-1 {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
// expected-error@-1 {{'FOO1' is defined as an object-like macro; did you mean 'FOO1(...)'?}}
}

void bar(int);
Expand All @@ -133,6 +133,6 @@ void test4() {
}

void test5() {
FOO1 + 1; // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
bar(FOO1); // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
FOO1 + 1; // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1(...)'?}}
bar(FOO1); // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1'(...)'?}}
}

0 comments on commit cc50469

Please sign in to comment.