Fix parsing of a line with only a # in it.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 19 Oct 2011 18:48:52 +0000 (18:48 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 19 Oct 2011 18:48:52 +0000 (18:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142537 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/line_with_hash.s [new file with mode: 0644]

index 4e8e15c7d6cbba9fe942de2fb13e8fffb3425c32..d7ee1c4ca3e76cda9c7ed1e39dd5906dd6695daf 100644 (file)
@@ -1228,7 +1228,8 @@ bool AsmParser::ParseStatement() {
 /// EatToEndOfLine uses the Lexer to eat the characters to the end of the line
 /// since they may not be able to be tokenized to get to the end of line token.
 void AsmParser::EatToEndOfLine() {
- Lexer.LexUntilEndOfLine();
+  if (!Lexer.is(AsmToken::EndOfStatement))
+    Lexer.LexUntilEndOfLine();
  // Eat EOL.
  Lex();
 }
diff --git a/test/MC/AsmParser/line_with_hash.s b/test/MC/AsmParser/line_with_hash.s
new file mode 100644 (file)
index 0000000..6fdab40
--- /dev/null
@@ -0,0 +1,15 @@
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+
+// We used to incorrectly parse a line with only a # in it
+
+.zero 42
+#
+.ifndef FOO
+.zero 2
+.else
+.endif
+.zero 24
+
+// CHECK: .zero 42
+// CHECK-NEXT: .zero 2
+// CHECK-NEXT: .zero 24