summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-05 19:01:00 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-05 19:01:00 +0000
commitdeb7ba9cc00b8bbb085011f9582033ba5694ebe0 (patch)
treebfda13dd502466913eed6402bb89d065e216ccc4
parent8557426958e01bf2c808fde5703c1e9a0ceef2df (diff)
downloadbcm5719-llvm-deb7ba9cc00b8bbb085011f9582033ba5694ebe0.tar.gz
bcm5719-llvm-deb7ba9cc00b8bbb085011f9582033ba5694ebe0.zip
MC: Reject attempts to define a variable symbol.
llvm-svn: 103111
-rw-r--r--llvm/lib/MC/MCAsmStreamer.cpp5
-rw-r--r--llvm/lib/MC/MCMachOStreamer.cpp6
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp2
3 files changed, 4 insertions, 9 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index dc09f217caf..1d231bbffa0 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -218,6 +218,7 @@ void MCAsmStreamer::SwitchSection(const MCSection *Section) {
void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
+ assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
assert(CurSection && "Cannot emit before setting section!");
OS << *Symbol << ":";
@@ -234,10 +235,6 @@ void MCAsmStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
}
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
- // Only absolute symbols can be redefined.
- assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
- "Cannot define a symbol twice!");
-
OS << *Symbol << " = " << *Value;
EmitEOL();
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index cfb39598f54..b4bd5575358 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -162,6 +162,8 @@ void MCMachOStreamer::SwitchSection(const MCSection *Section) {
void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
+ assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
+ assert(CurSection && "Cannot emit before setting section!");
// FIXME: This is wasteful, we don't necessarily need to create a data
// fragment. Instead, we should mark the symbol as pointing into the data
@@ -190,10 +192,6 @@ void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
}
void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
- // Only absolute symbols can be redefined.
- assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
- "Cannot define a symbol twice!");
-
// FIXME: Lift context changes into super class.
// FIXME: Set associated section.
Symbol->setVariableValue(AddValueSymbols(Value));
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 7c553fe7389..88e6e9a714e 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -457,7 +457,7 @@ bool AsmParser::ParseStatement() {
// FIXME: This doesn't diagnose assignment to a symbol which has been
// implicitly marked as external.
MCSymbol *Sym = CreateSymbol(IDVal);
- if (!Sym->isUndefined())
+ if (!Sym->isUndefined() || Sym->isVariable())
return Error(IDLoc, "invalid symbol redefinition");
// Emit the label.
OpenPOWER on IntegriCloud