AsmParser: Make sure GlobalVariables have sane types
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 16 Feb 2015 08:41:08 +0000 (08:41 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 16 Feb 2015 08:41:08 +0000 (08:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229364 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp
test/Assembler/gv-invalid-type.ll [new file with mode: 0644]

index 159bbccc87db9a56036de73c5eabb589f3b2a5e9..7818586dfa45d80723ae6b62ca3c62ca47e27c18 100644 (file)
@@ -749,7 +749,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
       return true;
   }
 
-  if (Ty->isFunctionTy() || Ty->isLabelTy())
+  if (Ty->isFunctionTy() || !PointerType::isValidElementType(Ty))
     return Error(TyLoc, "invalid type for global variable");
 
   GlobalValue *GVal = nullptr;
diff --git a/test/Assembler/gv-invalid-type.ll b/test/Assembler/gv-invalid-type.ll
new file mode 100644 (file)
index 0000000..bde04da
--- /dev/null
@@ -0,0 +1,4 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+@gv = global metadata undef
+; CHECK: invalid type for global variable