aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-08 19:11:42 +0000
committerChris Lattner <sabre@nondot.org>2002-03-08 19:11:42 +0000
commit34538145f4852b439438bd956d4bd8a67db1fab5 (patch)
tree556410c9e81d4ef4f260f5e75f78aa557fdc769a
parentdf00605a9d979a763d6ad78fd00ed656c357c415 (diff)
Fix bug: test/Regression/2002-03-08-NameCollision2.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1839 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AsmParser/llvmAsmParser.y13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 9d6c99d41e..8a1cf0ab32 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -1110,8 +1110,8 @@ Module : MethodList {
//
MethodList : MethodList Method {
$$ = $1;
- if (!$2->getParent())
- $1->getMethodList().push_back($2);
+ assert($2->getParent() == 0 && "Method already in module!");
+ $1->getMethodList().push_back($2);
CurMeth.MethodDone();
}
| MethodList MethodProto {
@@ -1184,6 +1184,11 @@ MethodHeaderH : OptInternal TypesV STRINGCONSTANT '(' ArgList ')' {
// or it needs to be.
if (!CurMeth.isDeclare && !M->isExternal())
ThrowException("Redefinition of method '" + MethodName + "'!");
+
+ // If we found a preexisting method prototype, remove it from the module,
+ // so that we don't get spurious conflicts with global & local variables.
+ //
+ CurModule.CurrentModule->getMethodList().remove(M);
}
}
@@ -1232,8 +1237,8 @@ Method : BasicBlockList END {
MethodProto : DECLARE { CurMeth.isDeclare = true; } MethodHeaderH {
$$ = CurMeth.CurrentMethod;
- if (!$$->getParent())
- CurModule.CurrentModule->getMethodList().push_back($$);
+ assert($$->getParent() == 0 && "Method already in module!");
+ CurModule.CurrentModule->getMethodList().push_back($$);
CurMeth.MethodDone();
}