diff options
author | Daniel Dunbar <daniel@zuster.org> | 2011-03-25 17:47:17 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2011-03-25 17:47:17 +0000 |
commit | 8b2b43c41d2f9a25d1eb387bd74dd761fe3cb83b (patch) | |
tree | b95f0f13ca54c955232821ddb35397e2e592ab7c | |
parent | 0143ac136847977bea1ba49f4f343feeabfc6a13 (diff) | |
download | external_llvm-8b2b43c41d2f9a25d1eb387bd74dd761fe3cb83b.zip external_llvm-8b2b43c41d2f9a25d1eb387bd74dd761fe3cb83b.tar.gz external_llvm-8b2b43c41d2f9a25d1eb387bd74dd761fe3cb83b.tar.bz2 |
MC: Improve some diagnostics on uses of '.' pseudo-symbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128289 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 19 | ||||
-rw-r--r-- | test/MC/AsmParser/dot-symbol.s | 12 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 47d700a..19f7bd8 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -897,12 +897,19 @@ bool AsmParser::ParseStatement() { return TokError("unexpected token at start of statement"); } } + + } else if (Lexer.is(AsmToken::Dot)) { + // Treat '.' as a valid identifier in this context. + Lex(); + IDVal = "."; + } else if (ParseIdentifier(IDVal)) { if (!TheCondState.Ignore) return TokError("unexpected token at start of statement"); IDVal = ""; } + // Handle conditional assembly here before checking for skipping. We // have to do this so that .endif isn't skipped in a ".if 0" block for // example. @@ -935,6 +942,10 @@ bool AsmParser::ParseStatement() { // identifier ':' -> Label. Lex(); + // Diagnose attempt to use '.' as a label. + if (IDVal == ".") + return Error(IDLoc, "invalid use of pseudo-symbol '.' as a label"); + // Diagnose attempt to use a variable as a label. // // FIXME: Diagnostics. Note the location of the definition as a label. @@ -978,7 +989,7 @@ bool AsmParser::ParseStatement() { return HandleMacroEntry(IDVal, IDLoc, M); // Otherwise, we have a normal instruction or directive. - if (IDVal[0] == '.') { + if (IDVal[0] == '.' && IDVal != ".") { // Assembler features if (IDVal == ".set" || IDVal == ".equ") return ParseDirectiveSet(IDVal, true); @@ -1306,6 +1317,12 @@ bool AsmParser::ParseAssignment(StringRef Name, bool allow_redef) { if (Lexer.isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in assignment"); + // Error on assignment to '.'. + if (Name == ".") { + return Error(EqualLoc, ("assignment to pseudo-symbol '.' is unsupported " + "(use '.space' or '.org').)")); + } + // Eat the end of statement marker. Lex(); diff --git a/test/MC/AsmParser/dot-symbol.s b/test/MC/AsmParser/dot-symbol.s new file mode 100644 index 0000000..4a38a40 --- /dev/null +++ b/test/MC/AsmParser/dot-symbol.s @@ -0,0 +1,12 @@ +# Historically 'as' treats '.' as a reference to the current location in +# arbitrary contects. We don't support this in general. + +# RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t +# RUN: FileCheck -input-file %t %s + +# CHECK: assignment to pseudo-symbol '.' is unsupported (use '.space' or '.org'). +. = . + 8 + +# CHECK: invalid use of pseudo-symbol '.' as a label +.: + .long 0 |