Skip to content

Commit 60b403e

Browse files
committed
Always flush pending errors in MCAsmParser
This has become visible with the --fatal-warnings support.
1 parent bc58e02 commit 60b403e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -916,21 +916,20 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
916916
// While we have input, parse each statement.
917917
while (Lexer.isNot(AsmToken::Eof)) {
918918
ParseStatementInfo Info(&AsmStrRewrites);
919-
if (!parseStatement(Info, nullptr))
920-
continue;
919+
bool Parsed = parseStatement(Info, nullptr);
921920

922921
// If we have a Lexer Error we are on an Error Token. Load in Lexer Error
923922
// for printing ErrMsg via Lex() only if no (presumably better) parser error
924923
// exists.
925-
if (!hasPendingError() && Lexer.getTok().is(AsmToken::Error)) {
924+
if (Parsed && !hasPendingError() && Lexer.getTok().is(AsmToken::Error)) {
926925
Lex();
927926
}
928927

929928
// parseStatement returned true so may need to emit an error.
930929
printPendingErrors();
931930

932931
// Skipping to the next line if needed.
933-
if (!getLexer().isAtStartOfStatement())
932+
if (Parsed && !getLexer().isAtStartOfStatement())
934933
eatToEndOfStatement();
935934
}
936935

llvm/test/MC/ARM/arm-load-store-multiple-deprecated.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@ RUN: llvm-mc -triple armv6t2-linux-eabi -filetype asm -o - %s 2>&1 \
22
@ RUN: | FileCheck %s
3+
@ RUN: not llvm-mc -triple armv6t2-linux-eabi --fatal-warnings -filetype asm -o - %s 2>&1 \
4+
@ RUN: | FileCheck -check-prefix CHECK-ERROR %s
35

46
@ RUN: not llvm-mc -triple armv7-linux-eabi -filetype asm -o - %s 2>&1 \
57
@ RUN: | FileCheck %s -check-prefix CHECK -check-prefix CHECK-V7
@@ -12,10 +14,12 @@
1214
stm:
1315
stm sp!, {r0, pc}
1416
@ CHECK: warning: use of SP or PC in the list is deprecated
17+
@ CHECK-ERROR: error: use of SP or PC in the list is deprecated
1518
@ CHECK: stm sp!, {r0, pc}
1619
@ CHECK: ^
1720
stm r0!, {r0, sp}
1821
@ CHECK: warning: use of SP or PC in the list is deprecated
22+
@ CHECK-ERROR: error: use of SP or PC in the list is deprecated
1923
@ CHECK: stm r0!, {r0, sp}
2024
@ CHECK: ^
2125
stm r1!, {r0, sp, pc}

0 commit comments

Comments
 (0)