Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ 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 at least two parameters" + " named '" + Parameter.Name + "'"); + if (Lexer.is(AsmToken::Colon)) { Lex(); // consume ':' Index: test/MC/AsmParser/macro-duplicate-params-names-err.s =================================================================== --- test/MC/AsmParser/macro-duplicate-params-names-err.s +++ test/MC/AsmParser/macro-duplicate-params-names-err.s @@ -0,0 +1,8 @@ +// RUN: not llvm-mc -triple x86_64-unknown-unknown %s 2> %t +// RUN: FileCheck < %t %s + +.macro M a a + nop +.endm + +// CHECK: macro 'M' has at least two parameters named 'a'