aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AsmParser
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-05 21:50:38 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-05 21:50:38 +0000
commit90e2f631518a1910249eee2e03e9aa8a766e800e (patch)
tree112d78936df9be361988479528fc192ec4bb4b25 /lib/AsmParser
parent73d6cf12adfd915897cce7e1ba9de00f962502d5 (diff)
downloadexternal_llvm-90e2f631518a1910249eee2e03e9aa8a766e800e.zip
external_llvm-90e2f631518a1910249eee2e03e9aa8a766e800e.tar.gz
external_llvm-90e2f631518a1910249eee2e03e9aa8a766e800e.tar.bz2
For PR1077:
Disallow merging of dupliate global variables. It is now illegal to declare or define two global variables of the same name and same type. llvm-gcc3 is dead in 2.0 and llvm-gcc4 doesn't have that problem nor need the hack. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32933 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser')
-rw-r--r--lib/AsmParser/llvmAsmParser.y33
1 files changed, 7 insertions, 26 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 133c534..0059531 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -635,8 +635,8 @@ static void setValueName(Value *V, char *NameStr) {
assert(inFunctionScope() && "Must be in function scope!");
SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
if (ST.lookup(V->getType(), Name)) {
- GenerateError("Redefinition of value named '" + Name + "' in the '" +
- V->getType()->getDescription() + "' type plane!");
+ GenerateError("Redefinition of value '" + Name + "' of type '" +
+ V->getType()->getDescription() + "'!");
return;
}
@@ -687,32 +687,13 @@ ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
}
// If this global has a name, check to see if there is already a definition
- // of this global in the module. If so, merge as appropriate. Note that
- // this is really just a hack around problems in the CFE. :(
+ // of this global in the module. If so, it is an error.
if (!Name.empty()) {
// We are a simple redefinition of a value, check to see if it is defined
// the same as the old one.
- if (GlobalVariable *EGV =
- CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
- // We are allowed to redefine a global variable in two circumstances:
- // 1. If at least one of the globals is uninitialized or
- // 2. If both initializers have the same value.
- //
- if (!EGV->hasInitializer() || !Initializer ||
- EGV->getInitializer() == Initializer) {
-
- // Make sure the existing global version gets the initializer! Make
- // sure that it also gets marked const if the new version is.
- if (Initializer && !EGV->hasInitializer())
- EGV->setInitializer(Initializer);
- if (isConstantGlobal)
- EGV->setConstant(true);
- EGV->setLinkage(Linkage);
- return EGV;
- }
-
+ if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
GenerateError("Redefinition of global variable named '" + Name +
- "' in the '" + Ty->getDescription() + "' type plane!");
+ "' of type '" + Ty->getDescription() + "'!");
return 0;
}
}
@@ -767,8 +748,8 @@ static bool setTypeName(const Type *T, char *NameStr) {
if (Existing == T) return true; // Yes, it's equal.
// Any other kind of (non-equivalent) redefinition is an error.
- GenerateError("Redefinition of type named '" + Name + "' in the '" +
- T->getDescription() + "' type plane!");
+ GenerateError("Redefinition of type named '" + Name + "' of type '" +
+ T->getDescription() + "'!");
}
return false;