MC: Reject attempts to define a variable symbol.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 5 May 2010 19:01:00 +0000 (19:01 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 5 May 2010 19:01:00 +0000 (19:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103111 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCAsmStreamer.cpp
lib/MC/MCMachOStreamer.cpp
lib/MC/MCParser/AsmParser.cpp

index dc09f217cafc457ad8dbc6cf7a2d1bf03407d16e..1d231bbffa0ef89eac2952da797f5b599020a944 100644 (file)
@@ -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();
 
index cfb39598f543e831f0e983fa27958347844ed37f..b4bd55753588bb4f8ebbe10b2789a4854d165ad0 100644 (file)
@@ -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));
index 7c553fe7389386cd2dff4b00697e874161d3421c..88e6e9a714e13a8eb86d57c835045bc090ece752 100644 (file)
@@ -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.