From cc50469f3fbbe3d9cb877386abad68b59a84c816 Mon Sep 17 00:00:00 2001 From: Prashanth Date: Wed, 12 Feb 2025 16:17:08 +0530 Subject: [PATCH] [clang][Sema] Update diagnostic tests for object-like macros in initializer list tests --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +- clang/lib/Sema/SemaExpr.cpp | 2 +- clang/test/Preprocessor/macro_with_initializer_list.cpp | 6 +++--- clang/test/Sema/typo-correction.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index e74020f8c8a0e..bafc2308f522f 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -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">; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 26150bcb34967..c3b5c705178a1 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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(); diff --git a/clang/test/Preprocessor/macro_with_initializer_list.cpp b/clang/test/Preprocessor/macro_with_initializer_list.cpp index dab60e60b14a1..d9e653106d4a1 100644 --- a/clang/test/Preprocessor/macro_with_initializer_list.cpp +++ b/clang/test/Preprocessor/macro_with_initializer_list.cpp @@ -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}} } @@ -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}} } diff --git a/clang/test/Sema/typo-correction.c b/clang/test/Sema/typo-correction.c index 3efd35538dd58..e16ad78583223 100644 --- a/clang/test/Sema/typo-correction.c +++ b/clang/test/Sema/typo-correction.c @@ -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); @@ -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'(...)'?}} }