[llvm-commits] [llvm] r128289 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/dot-symbol.s
Daniel Dunbar
daniel at zuster.org
Fri Mar 25 10:47:18 PDT 2011
Author: ddunbar
Date: Fri Mar 25 12:47:17 2011
New Revision: 128289
URL: http://llvm.org/viewvc/llvm-project?rev=128289&view=rev
Log:
MC: Improve some diagnostics on uses of '.' pseudo-symbol.
Added:
llvm/trunk/test/MC/AsmParser/dot-symbol.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=128289&r1=128288&r2=128289&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Fri Mar 25 12:47:17 2011
@@ -897,12 +897,19 @@
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 @@
// 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 @@
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 @@
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();
Added: llvm/trunk/test/MC/AsmParser/dot-symbol.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/dot-symbol.s?rev=128289&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/dot-symbol.s (added)
+++ llvm/trunk/test/MC/AsmParser/dot-symbol.s Fri Mar 25 12:47:17 2011
@@ -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
More information about the llvm-commits
mailing list