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

>From 7e1210a668cf10ccb3502fd063a297ae67354c5a Mon Sep 17 00:00:00 2001
From: Prashanth <[email protected]>
Date: Wed, 16 Sep 2026 07:10:45 +0530
Subject: [PATCH 1/3] [clang][Sema] Add regression tests for function-like
 macro usage in C and C++

---
 .../Sema/typo-correction-func-like-macro.cpp  | 11 ++++++
 clang/test/Sema/typo-correction.c             | 36 +++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 clang/test/Sema/typo-correction-func-like-macro.cpp

diff --git a/clang/test/Sema/typo-correction-func-like-macro.cpp 
b/clang/test/Sema/typo-correction-func-like-macro.cpp
new file mode 100644
index 0000000000000..be938dab0141c
--- /dev/null
+++ b/clang/test/Sema/typo-correction-func-like-macro.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Regression test for the "function-like macro used without parens"
+// diagnostic added in https://github.com/llvm/llvm-project/pull/123495.
+// Confirms the same diagnostic fires correctly in C++ (not just C),
+// since the implementation lives in the shared SemaExpr.cpp.
+
+#define BAZ() 1
+// expected-note@-1 {{'BAZ' defined here as a function-like macro}}
+
+int x = BAZ; // expected-error {{'BAZ' is defined as a function-like macro; 
did you mean 'BAZ(...)'?}}
\ No newline at end of file
diff --git a/clang/test/Sema/typo-correction.c 
b/clang/test/Sema/typo-correction.c
index 1f6bcd0485a02..18df040f57392 100644
--- a/clang/test/Sema/typo-correction.c
+++ b/clang/test/Sema/typo-correction.c
@@ -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@-1 {{'FOO1' defined here as a function-like macro}}
+
+void test7() {
+    int w = FOO1; // expected-error {{'FOO1' is defined as a function-like 
macro; did you mean 'FOO1(...)'?}}
+}
+
+#define FOO2() 42
+
+void test8() {
+    int y = FOO2 /* comment */ (); // no error expected — still a real call
+}
+
+void test9() {
+    int z = FOO2
+        (); // no error expected — paren across a line break
+}
+
+void test10() {
+    int arr[FOO1]; // expected-error {{'FOO1' is defined as a function-like 
macro; did you mean 'FOO1(...)'?}}
+}
+
+#define VARFOO(...) 1
+// expected-note@-1 {{'VARFOO' defined here as a function-like macro}}
+
+void test11() {
+    int v = VARFOO; // expected-error {{'VARFOO' is defined as a function-like 
macro; did you mean 'VARFOO(...)'?}}
+}
\ No newline at end of file

>From 41307f6fb8e00c9569625ce1f6ebabee039ba4d8 Mon Sep 17 00:00:00 2001
From: Prashanth <[email protected]>
Date: Thu, 17 Sep 2026 21:56:34 +0530
Subject: [PATCH 2/3] [clang][Sema] move cpp funclikemacro test to
 typo-correction-nohang and add new line in eof

---
 clang/test/Sema/typo-correction-func-like-macro.cpp | 11 -----------
 clang/test/Sema/typo-correction-no-hang.cpp         |  7 +++++++
 clang/test/Sema/typo-correction.c                   |  2 +-
 3 files changed, 8 insertions(+), 12 deletions(-)
 delete mode 100644 clang/test/Sema/typo-correction-func-like-macro.cpp

diff --git a/clang/test/Sema/typo-correction-func-like-macro.cpp 
b/clang/test/Sema/typo-correction-func-like-macro.cpp
deleted file mode 100644
index be938dab0141c..0000000000000
--- a/clang/test/Sema/typo-correction-func-like-macro.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-// Regression test for the "function-like macro used without parens"
-// diagnostic added in https://github.com/llvm/llvm-project/pull/123495.
-// Confirms the same diagnostic fires correctly in C++ (not just C),
-// since the implementation lives in the shared SemaExpr.cpp.
-
-#define BAZ() 1
-// expected-note@-1 {{'BAZ' defined here as a function-like macro}}
-
-int x = BAZ; // expected-error {{'BAZ' is defined as a function-like macro; 
did you mean 'BAZ(...)'?}}
\ No newline at end of file
diff --git a/clang/test/Sema/typo-correction-no-hang.cpp 
b/clang/test/Sema/typo-correction-no-hang.cpp
index 34b8486bed902..3e7202e6aed9f 100644
--- a/clang/test/Sema/typo-correction-no-hang.cpp
+++ b/clang/test/Sema/typo-correction-no-hang.cpp
@@ -40,3 +40,10 @@ int Bar(const B &b) {
   return b.depar().longitude() + //expected-error{{no member named 'longitude' 
in 'A'}}
          b.depar().latitude();   //expected-error{{no member named 'latitude' 
in 'A'}}
 }
+
+#define BAZ() 1
+// expected-note@-1 {{'BAZ' defined here as a function-like macro}}
+
+void testFuncLikeMacroWithoutParens() {
+    int x = BAZ; // expected-error {{'BAZ' is defined as a function-like 
macro; did you mean 'BAZ(...)'?}}
+}
diff --git a/clang/test/Sema/typo-correction.c 
b/clang/test/Sema/typo-correction.c
index 18df040f57392..82cc82a096199 100644
--- a/clang/test/Sema/typo-correction.c
+++ b/clang/test/Sema/typo-correction.c
@@ -175,4 +175,4 @@ void test10() {
 
 void test11() {
     int v = VARFOO; // expected-error {{'VARFOO' is defined as a function-like 
macro; did you mean 'VARFOO(...)'?}}
-}
\ No newline at end of file
+}

>From 52658d41f3db78127ce0c6758147c188b3346369 Mon Sep 17 00:00:00 2001
From: Prashanth <[email protected]>
Date: Fri, 18 Sep 2026 05:25:44 +0530
Subject: [PATCH 3/3] [clang][Sema] Consolidate expected-note annotations per
 review

FOO1: use expected-note 2 instead of duplicating the note comment.
VARFOO: inline expected-note onto the #define line.
---
 clang/test/Sema/typo-correction.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/test/Sema/typo-correction.c 
b/clang/test/Sema/typo-correction.c
index 82cc82a096199..7cda42f8640d5 100644
--- a/clang/test/Sema/typo-correction.c
+++ b/clang/test/Sema/typo-correction.c
@@ -148,8 +148,7 @@ void test6(){
 }
 
 
-#define FOO1() 99 // expected-note {{'FOO1' defined here as a function-like 
macro}}
-// expected-note@-1 {{'FOO1' defined here as a function-like macro}}
+#define FOO1() 99 // expected-note 2 {{'FOO1' defined here as a function-like 
macro}}
 
 void test7() {
     int w = FOO1; // expected-error {{'FOO1' is defined as a function-like 
macro; did you mean 'FOO1(...)'?}}
@@ -170,8 +169,7 @@ void test10() {
     int arr[FOO1]; // expected-error {{'FOO1' is defined as a function-like 
macro; did you mean 'FOO1(...)'?}}
 }
 
-#define VARFOO(...) 1
-// expected-note@-1 {{'VARFOO' defined here as a function-like macro}}
+#define VARFOO(...) 1 // expected-note {{'VARFOO' defined here as a 
function-like macro}}
 
 void test11() {
     int v = VARFOO; // expected-error {{'VARFOO' is defined as a function-like 
macro; did you mean 'VARFOO(...)'?}}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to