diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-05 07:52:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-05 07:52:51 +0000 |
commit | 081b505f77b183b7b029818218245cf4986e8948 (patch) | |
tree | 7b9cde749e28b09563533c0954b8b0a6d763119d /lib/AsmParser | |
parent | 3fbb3ab14d86f752a933b5af4e6728c5e57e1155 (diff) | |
download | external_llvm-081b505f77b183b7b029818218245cf4986e8948.zip external_llvm-081b505f77b183b7b029818218245cf4986e8948.tar.gz external_llvm-081b505f77b183b7b029818218245cf4986e8948.tar.bz2 |
fix PR3281:accepted0[02].ll: represent empty arrays distinctly, and
diagnose attempts to initialize non-empty arrays with them. This
produces:
llvm-as: accepted02.ll:1:28: invalid empty array initializer
@"o" = global [5 x double] []
^
llvm-as: accepted00.ll:1:32: invalid empty array initializer
@"za" = thread_local global {} []
^
[
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser')
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 1f08ca3..d2ce6ec 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -36,6 +36,7 @@ namespace llvm { t_LocalName, t_GlobalName, // Name in StrVal. t_APSInt, t_APFloat, // Value in APSIntVal/APFloatVal. t_Null, t_Undef, t_Zero, // No value. + t_EmptyArray, // No value: [] t_Constant, // Value in ConstantVal. t_InlineAsm // Value in StrVal/StrVal2/UIntVal. } Kind; @@ -1578,7 +1579,7 @@ bool LLParser::ParseValID(ValID &ID) { if (Elts.empty()) { // Use undef instead of an array because it's inconvenient to determine // the element type at this point, there being no elements to examine. - ID.Kind = ValID::t_Undef; + ID.Kind = ValID::t_EmptyArray; return false; } @@ -1904,6 +1905,11 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, case ValID::t_Undef: V = UndefValue::get(Ty); return false; + case ValID::t_EmptyArray: + if (!isa<ArrayType>(Ty) || cast<ArrayType>(Ty)->getNumElements() != 0) + return Error(ID.Loc, "invalid empty array initializer"); + V = UndefValue::get(Ty); + return false; case ValID::t_Zero: if (!Ty->isFirstClassType()) return Error(ID.Loc, "invalid type for null constant"); |