[clang] [Clang][Lex] Fix crash when empty macro arguments leave a trailing ## (PR #239693)
Daniel Petrovic via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 8 12:13:28 PST 2026
================
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -E -P %s | FileCheck %s
+// RUN: %clang_cc1 -E -P -x c++ %s | FileCheck %s
+
+#define PASTE(x, y) x####y
+
+// CHECK: int one() {
+// CHECK-NEXT: return 1;
+// CHECK-NEXT: }
+int one() {
+ return PASTE(1,);
+}
+
+// CHECK: int twelve() {
+// CHECK-NEXT: return 12;
+// CHECK-NEXT: }
+int twelve() {
+ return PASTE(1, 2);
----------------
daniel-petrovic wrote:
What I also had to add: when pasting empty arg with ## , e.g. P ## ## , the 2.nd ## has to be changed to "unknown" for not to be considered as paste operator (similar is done in other places too, e.g. passing ## via arg)
https://github.com/llvm/llvm-project/pull/239693
More information about the cfe-commits
mailing list