From 40d10639cfe465b1d600ec68a54c602724b7a86a Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 16 Feb 2015 08:41:08 +0000 Subject: [PATCH] AsmParser: Make sure GlobalVariables have sane types git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229364 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AsmParser/LLParser.cpp | 2 +- test/Assembler/gv-invalid-type.ll | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/Assembler/gv-invalid-type.ll 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 -- 2.34.1