[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 31 15:27:17 PST 2025


================
@@ -159,12 +160,13 @@ void test() {
   // expected-note at -3 {{cannot use initializer list at the beginning of a macro argument}}
 }
 
-// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:11-145:11}:"("
-// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:23-145:23}:")"
+// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:11-146:11}:"("
+// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:23-146:23}:")"
 
 #define M(name,a,b,c,d,e,f,g,h,i,j,k,l) \
   Foo name = a + b + c + d + e + f + g + h + i + j + k + l;
 // expected-note at -2 2{{defined here}}
+// expected-note at -3 {{'M' is defined here as a function-like macro; did you mean 'M(...)'}}
----------------
shafik wrote:

The addition of this diagnostic here when the diagnostic below is `error: too many arguments provided to function-like macro invocation` seems not very helpful and too verbose.

https://github.com/llvm/llvm-project/pull/123495


More information about the cfe-commits mailing list