From: David Majnemer Date: Mon, 16 Feb 2015 08:41:08 +0000 (+0000) Subject: AsmParser: Make sure GlobalVariables have sane types X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=40d10639cfe465b1d600ec68a54c602724b7a86a;p=oota-llvm.git AsmParser: Make sure GlobalVariables have sane types git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229364 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 159bbccc87d..7818586dfa4 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -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 index 00000000000..bde04dab7a2 --- /dev/null +++ b/test/Assembler/gv-invalid-type.ll @@ -0,0 +1,4 @@ +; RUN: not llvm-as < %s 2>&1 | FileCheck %s + +@gv = global metadata undef +; CHECK: invalid type for global variable