MC: loosen an overzealous assertion
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 21 May 2014 17:53:18 +0000 (17:53 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 21 May 2014 17:53:18 +0000 (17:53 +0000)
Permit active macro expansions when terminating the assembler if there were
errors during the expansion.  This would only trigger on invalid input when
built with assertions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209309 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/invalid-input-assertion.s [new file with mode: 0644]

index 633d101248161e24c7b92e44ee3f8e6bf65b9ba8..ec2094d6715bc3ef4eb54b0a4fff753a540af042 100644 (file)
@@ -528,7 +528,8 @@ AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out,
 }
 
 AsmParser::~AsmParser() {
-  assert(ActiveMacros.empty() && "Unexpected active macro instantiation!");
+  assert((HadError || ActiveMacros.empty()) &&
+         "Unexpected active macro instantiation!");
 
   // Destroy any macros.
   for (StringMap<MCAsmMacro *>::iterator it = MacroMap.begin(),
diff --git a/test/MC/AsmParser/invalid-input-assertion.s b/test/MC/AsmParser/invalid-input-assertion.s
new file mode 100644 (file)
index 0000000..68846fe
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: not llvm-mc -triple i686-linux -o /dev/null %s
+// REQUIRES: asserts
+
+       .macro macro parameter=0
+               .if \parameter
+               .else
+       .endm
+
+       macro 1
+