[llvm] [MCParser, test] Improve macro argument charset test (PR #218828)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 20:16:17 PDT 2026


https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/218828

'@', '#', and '?' are assembly identifier characters, but they terminate
a macro argument name.

>From 9e50371651e8bced61f0be551e5c79de2ad43b55 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Tue, 25 Aug 2026 20:08:36 -0700
Subject: [PATCH] [MCParser,test] Improve macro argument charset test

'@', '#', and '?' are assembly identifier characters, but they terminate
a macro argument name.
---
 llvm/test/MC/AsmParser/altmacro-arg.s | 2 ++
 llvm/test/MC/AsmParser/macro-arg.s    | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/llvm/test/MC/AsmParser/altmacro-arg.s b/llvm/test/MC/AsmParser/altmacro-arg.s
index 713f5ad4aeab7..ac1405474b0b5 100644
--- a/llvm/test/MC/AsmParser/altmacro-arg.s
+++ b/llvm/test/MC/AsmParser/altmacro-arg.s
@@ -10,6 +10,7 @@
 # CHECK:      .data
 # CHECK-NEXT: .ascii "b cc rbx"
 # CHECK-NEXT: .ascii "bcc ccx rbx raxx"
+# CHECK-NEXT: .ascii "b?x b at x b#x b!x a_"
 .macro gen a, ra, rax
   ja 1f
   xorq %rax, %rax
@@ -17,6 +18,7 @@
 .data
   .ascii "\a \ra \rax"
   .ascii "a\()ra ra\()x rax raxx"
+  .ascii "a?x a at x a#x a!x a_"
 .endm
 gen b, cc, rbx
 
diff --git a/llvm/test/MC/AsmParser/macro-arg.s b/llvm/test/MC/AsmParser/macro-arg.s
index 19065402309ec..fd6a3b65d9dc1 100644
--- a/llvm/test/MC/AsmParser/macro-arg.s
+++ b/llvm/test/MC/AsmParser/macro-arg.s
@@ -100,3 +100,12 @@ ascii3 x - y z 1
 ascii3 1, (2 3)
 # CHECK: .ascii "1|(2 3)|"
 ascii3 1 (2 3)
+
+## '@', '#' and '?' are identifier characters, but they terminate a macro argument name.
+.macro charset a
+.ascii "\a?x|\a?|\a at x|\a#x|\a!x"
+\a?y:
+.endm
+# CHECK:      .ascii "fo?x|fo?|fo at x|fo#x|fo!x"
+# CHECK-NEXT: "fo?y":
+charset fo



More information about the llvm-commits mailing list