[clang] [clang][Sema][Tests] Add test coverage for function-like macro diagnostic edge cases and C++ (PR #223895)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 11:53:59 PDT 2026


================
@@ -140,3 +140,39 @@ void test5() {
     FOO1 + 1; // expected-error {{'FOO1' is defined as a function-like macro; did you mean 'FOO1(...)'?}}
     bar(FOO1); // expected-error {{'FOO1' is defined as a function-like macro; did you mean 'FOO1(...)'?}}
 }
+
+#undef FOO1
+
+void test6(){
+    int iter = FOO1;  //expected-error {{use of undeclared identifier 'FOO1'}}
+}
+
+
+#define FOO1() 99 // expected-note {{'FOO1' defined here as a function-like macro}}
+// expected-note at -1 {{'FOO1' defined here as a function-like macro}}
----------------
AaronBallman wrote:

```suggestion
#define FOO1() 99 // expected-note 2 {{'FOO1' defined here as a function-like macro}}
```

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


More information about the cfe-commits mailing list