summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2015-10-16 22:07:59 +0000
committerJim Grosbach <grosbach@apple.com>2015-10-16 22:07:59 +0000
commit0fdd572763a3fd1503c31ac9ac89b8bf04065040 (patch)
treef88ab7901251c441a42686bc1a797cf58a37f74e
parent7dccca543a5f29cee53e2fea8ed8abb56be90c3c (diff)
downloadbcm5719-llvm-0fdd572763a3fd1503c31ac9ac89b8bf04065040.tar.gz
bcm5719-llvm-0fdd572763a3fd1503c31ac9ac89b8bf04065040.zip
MC: Don't crash after issuing a diagnostic.
Crashing is bad, m'kay? Fixing a 4 year old bug of my own creation. Adding the testcase now which I should have added then which would have long since caught this. The problem is that printMessage() will display the diagnostic but not set HadError to true, resulting in the assembler continuing on its way and trying to create relocations for things that may not allow them or otherwise get itself into trouble. Using the Error() helper function here rather than calling printMessage() directly resolves this. rdar://23133240 llvm-svn: 250557
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp5
-rw-r--r--llvm/test/MC/AsmParser/undefined-local-symbol.s8
2 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 9c542244fc7..c003c797dd9 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -690,9 +690,8 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
// FIXME: We would really like to refer back to where the symbol was
// first referenced for a source location. We need to add something
// to track that. Currently, we just point to the end of the file.
- printMessage(getLexer().getLoc(), SourceMgr::DK_Error,
- "assembler local symbol '" + Sym->getName() +
- "' not defined");
+ return Error(getLexer().getLoc(), "assembler local symbol '" +
+ Sym->getName() + "' not defined");
}
}
diff --git a/llvm/test/MC/AsmParser/undefined-local-symbol.s b/llvm/test/MC/AsmParser/undefined-local-symbol.s
new file mode 100644
index 00000000000..280fc555980
--- /dev/null
+++ b/llvm/test/MC/AsmParser/undefined-local-symbol.s
@@ -0,0 +1,8 @@
+# RUN: not llvm-mc -triple i386-apple-darwin -filetype=obj -o /dev/null %s 2>&1 | FileCheck %s
+
+# NOTE: apple-darwin portion of the triple is to enforce the convention choice
+# of what an assembler local symbol looks like (i.e., 'L' prefix.)
+
+# CHECK: error: assembler local symbol 'Lbar' not defined
+foo:
+ jmp Lbar
OpenPOWER on IntegriCloud