Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -689,7 +689,7 @@ // Variable symbols may not be marked as defined, so check those // explicitly. If we know it's a variable, we have a definition for // the purposes of this check. - if (Sym->isTemporary() && !Sym->isVariable() && !Sym->isDefined()) + if (Sym->isTemporary() && !Sym->isVariable() && !Sym->isDefined(false)) // 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. @@ -867,11 +867,12 @@ // If this is an absolute variable reference, substitute it now to preserve // semantics in the face of reassignment. - if (Sym->isVariable() && isa(Sym->getVariableValue())) { + if (Sym->isVariable() && + isa(Sym->getVariableValue(false))) { if (Variant) return Error(EndLoc, "unexpected modifier on variable reference"); - Res = Sym->getVariableValue(); + Res = Sym->getVariableValue(false); return false; } @@ -903,7 +904,7 @@ MCSymbol *Sym = Ctx.getDirectionalLocalSymbol(IntVal, IDVal == "b"); Res = MCSymbolRefExpr::create(Sym, Variant, getContext()); - if (IDVal == "b" && Sym->isUndefined()) + if (IDVal == "b" && Sym->isUndefined(false)) return Error(Loc, "invalid reference to undefined symbol"); EndLoc = Lexer.getTok().getEndLoc(); Lex(); // Eat identifier. @@ -1346,7 +1347,7 @@ Sym->redefineIfPossible(); - if (!Sym->isUndefined() || Sym->isVariable()) + if (!Sym->isUndefined(false) || Sym->isVariable()) return Error(IDLoc, "invalid symbol redefinition"); // Emit the label. @@ -3752,7 +3753,7 @@ return Error(Pow2AlignmentLoc, "invalid '.comm' or '.lcomm' directive " "alignment, can't be less than zero"); - if (!Sym->isUndefined()) + if (!Sym->isUndefined(false)) return Error(IDLoc, "invalid symbol redefinition"); // Create the Symbol as a common or local common with Size and Pow2Alignment @@ -4002,9 +4003,9 @@ MCSymbol *Sym = getContext().lookupSymbol(Name); if (expect_defined) - TheCondState.CondMet = (Sym && !Sym->isUndefined()); + TheCondState.CondMet = (Sym && !Sym->isUndefined(false)); else - TheCondState.CondMet = (!Sym || Sym->isUndefined()); + TheCondState.CondMet = (!Sym || Sym->isUndefined(false)); TheCondState.Ignore = !TheCondState.CondMet; } @@ -4760,7 +4761,7 @@ const MCSymbol &S = static_cast(Value)->getSymbol(); if (S.isVariable()) - return isSymbolUsedInExpression(Sym, S.getVariableValue()); + return isSymbolUsedInExpression(Sym, S.getVariableValue(false)); return &S == Sym; } case MCExpr::Unary: @@ -4805,21 +4806,18 @@ // FIXME: Diagnose assignment to protected identifier (e.g., register name). if (isSymbolUsedInExpression(Sym, Value)) return Parser.Error(EqualLoc, "Recursive use of '" + Name + "'"); - else if (Sym->isUndefined() && !Sym->isUsed() && !Sym->isVariable()) + else if (Sym->isUndefined(false) && !Sym->isUsed() && !Sym->isVariable()) ; // Allow redefinitions of undefined symbols only used in directives. else if (Sym->isVariable() && !Sym->isUsed() && allow_redef) ; // Allow redefinitions of variables that haven't yet been used. - else if (!Sym->isUndefined() && (!Sym->isVariable() || !allow_redef)) + else if (!Sym->isUndefined(false) && (!Sym->isVariable() || !allow_redef)) return Parser.Error(EqualLoc, "redefinition of '" + Name + "'"); else if (!Sym->isVariable()) return Parser.Error(EqualLoc, "invalid assignment to '" + Name + "'"); - else if (!isa(Sym->getVariableValue())) + else if (!isa(Sym->getVariableValue(false))) return Parser.Error(EqualLoc, "invalid reassignment of non-absolute variable '" + Name + "'"); - - // Don't count these checks as uses. - Sym->setUsed(false); } else if (Name == ".") { if (Parser.getStreamer().EmitValueToOffset(Value, 0)) { Parser.Error(EqualLoc, "expected absolute expression"); Index: test/MC/AsmParser/reassign.s =================================================================== --- /dev/null +++ test/MC/AsmParser/reassign.s @@ -0,0 +1,10 @@ +// RUN: llvm-mc -triple i386-unknown-unknown %s + + .text +bar: + + .data +.globl foo +.set foo, bar +.globl foo +.set foo, bar