[llvm] 60b403e - Always flush pending errors in MCAsmParser

Joerg Sonnenberger via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 24 15:48:38 PDT 2019


Author: Joerg Sonnenberger
Date: 2019-10-25T00:48:12+02:00
New Revision: 60b403e75cd25a0c76aaaf4e6b176923acf49443

URL: https://github.com/llvm/llvm-project/commit/60b403e75cd25a0c76aaaf4e6b176923acf49443
DIFF: https://github.com/llvm/llvm-project/commit/60b403e75cd25a0c76aaaf4e6b176923acf49443.diff

LOG: Always flush pending errors in MCAsmParser

This has become visible with the --fatal-warnings support.

Added: 
    

Modified: 
    llvm/lib/MC/MCParser/AsmParser.cpp
    llvm/test/MC/ARM/arm-load-store-multiple-deprecated.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index b59ac08ad6cc..72225ef6039f 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -916,13 +916,12 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
   // While we have input, parse each statement.
   while (Lexer.isNot(AsmToken::Eof)) {
     ParseStatementInfo Info(&AsmStrRewrites);
-    if (!parseStatement(Info, nullptr))
-      continue;
+    bool Parsed = parseStatement(Info, nullptr);
 
     // If we have a Lexer Error we are on an Error Token. Load in Lexer Error
     // for printing ErrMsg via Lex() only if no (presumably better) parser error
     // exists.
-    if (!hasPendingError() && Lexer.getTok().is(AsmToken::Error)) {
+    if (Parsed && !hasPendingError() && Lexer.getTok().is(AsmToken::Error)) {
       Lex();
     }
 
@@ -930,7 +929,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
     printPendingErrors();
 
     // Skipping to the next line if needed.
-    if (!getLexer().isAtStartOfStatement())
+    if (Parsed && !getLexer().isAtStartOfStatement())
       eatToEndOfStatement();
   }
 

diff  --git a/llvm/test/MC/ARM/arm-load-store-multiple-deprecated.s b/llvm/test/MC/ARM/arm-load-store-multiple-deprecated.s
index 9354822bc417..e41aa279f398 100644
--- a/llvm/test/MC/ARM/arm-load-store-multiple-deprecated.s
+++ b/llvm/test/MC/ARM/arm-load-store-multiple-deprecated.s
@@ -1,5 +1,7 @@
 @ RUN: llvm-mc -triple armv6t2-linux-eabi -filetype asm -o - %s 2>&1 \
 @ RUN:   | FileCheck %s
+@ RUN: not llvm-mc -triple armv6t2-linux-eabi --fatal-warnings -filetype asm -o - %s 2>&1 \
+@ RUN:   | FileCheck -check-prefix CHECK-ERROR %s
 
 @ RUN: not llvm-mc -triple armv7-linux-eabi -filetype asm -o - %s 2>&1 \
 @ RUN:   | FileCheck %s -check-prefix CHECK -check-prefix CHECK-V7
@@ -12,10 +14,12 @@
 stm:
 	stm sp!, {r0, pc}
 @ CHECK: warning: use of SP or PC in the list is deprecated
+@ CHECK-ERROR: error: use of SP or PC in the list is deprecated
 @ CHECK: stm sp!, {r0, pc}
 @ CHECK: ^
 	stm r0!, {r0, sp}
 @ CHECK: warning: use of SP or PC in the list is deprecated
+@ CHECK-ERROR: error: use of SP or PC in the list is deprecated
 @ CHECK: stm r0!, {r0, sp}
 @ CHECK: ^
 	stm r1!, {r0, sp, pc}


        


More information about the llvm-commits mailing list