From e67c1aa3986cf98f2021a31a6ad502857c757b7b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 5 Jan 2009 08:13:38 +0000 Subject: [PATCH] reject undef/zero labels. This fixes PR3281:crash0[56].ll with these diagnostics: llvm-as: crash05.ll:1:14: invalid type for null constant global label zeroinitializer addrspace (75), section "c" ^ llvm-as: crash06.ll:2:14: invalid type for null constant udiv label zeroinitializer, @0 ^ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61681 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AsmParser/LLParser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 68946393119..bdb94530706 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1906,6 +1906,9 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, V = ConstantPointerNull::get(cast(Ty)); return false; case ValID::t_Undef: + // FIXME: LabelTy should not be a first-class type. + if (!Ty->isFirstClassType() || Ty == Type::LabelTy) + return Error(ID.Loc, "invalid type for undef constant"); V = UndefValue::get(Ty); return false; case ValID::t_EmptyArray: @@ -1914,7 +1917,8 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, V = UndefValue::get(Ty); return false; case ValID::t_Zero: - if (!Ty->isFirstClassType()) + // FIXME: LabelTy should not be a first-class type. + if (!Ty->isFirstClassType() || Ty == Type::LabelTy) return Error(ID.Loc, "invalid type for null constant"); V = Constant::getNullValue(Ty); return false;