[PATCH] D31674: [AsmParser]Emit an error if a macro has two (or more) parameters sharing the same name

coby via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 10 11:07:11 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL299815: [AsmParser]Emit an error if a macro has two (or more) parameters sharing theā€¦ (authored by coby).

Changed prior to commit:
  https://reviews.llvm.org/D31674?vs=94096&id=94605#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31674

Files:
  llvm/trunk/lib/MC/MCParser/AsmParser.cpp
  llvm/trunk/test/MC/AsmParser/macro-duplicate-params-names-err.s


Index: llvm/trunk/test/MC/AsmParser/macro-duplicate-params-names-err.s
===================================================================
--- llvm/trunk/test/MC/AsmParser/macro-duplicate-params-names-err.s
+++ llvm/trunk/test/MC/AsmParser/macro-duplicate-params-names-err.s
@@ -0,0 +1,7 @@
+// RUN: not llvm-mc %s 2> %t
+// RUN: FileCheck < %t %s
+
+.macro M a a
+.endm
+
+// CHECK: macro 'M' has multiple parameters named 'a'
Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -3874,6 +3874,12 @@
     if (parseIdentifier(Parameter.Name))
       return TokError("expected identifier in '.macro' directive");
 
+    // Emit an error if two (or more) named parameters share the same name
+    for (const MCAsmMacroParameter& CurrParam : Parameters)
+      if (CurrParam.Name.equals(Parameter.Name))
+        return TokError("macro '" + Name + "' has multiple parameters"
+                        " named '" + Parameter.Name + "'");
+
     if (Lexer.is(AsmToken::Colon)) {
       Lex();  // consume ':'
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31674.94605.patch
Type: text/x-patch
Size: 1162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170410/3a13b926/attachment.bin>


More information about the llvm-commits mailing list