Fix PR3372
authorChris Lattner <sabre@nondot.org>
Mon, 2 Feb 2009 07:24:28 +0000 (07:24 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 2 Feb 2009 07:24:28 +0000 (07:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63501 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp
test/Assembler/2009-02-01-UnnamedForwardRef.ll [new file with mode: 0644]

index 401dc39ca539c977d2abeca0c046c43f8cb23ef8..943f1d00256819870acea7baf125cb1d04a3ed42 100644 (file)
@@ -471,8 +471,9 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
   GlobalVariable *GV = 0;
 
   // See if the global was forward referenced, if so, use the global.
-  if (!Name.empty() && (GV = M->getGlobalVariable(Name, true))) {
-    if (!ForwardRefVals.erase(Name))
+  if (!Name.empty()) {
+    if ((GV = M->getGlobalVariable(Name, true)) &&
+        !ForwardRefVals.erase(Name))
       return Error(NameLoc, "redefinition of global '@" + Name + "'");
   } else {
     std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
diff --git a/test/Assembler/2009-02-01-UnnamedForwardRef.ll b/test/Assembler/2009-02-01-UnnamedForwardRef.ll
new file mode 100644 (file)
index 0000000..9c6e20d
--- /dev/null
@@ -0,0 +1,6 @@
+; RUN: llvm-as < %s | llvm-dis
+; PR3372
+
+@X = global i32* @0
+global i32 4
+