[llvm-commits] [llvm] r61676 - /llvm/trunk/lib/AsmParser/LLParser.cpp
Chris Lattner
sabre at nondot.org
Sun Jan 4 23:52:51 PST 2009
Author: lattner
Date: Mon Jan 5 01:52:51 2009
New Revision: 61676
URL: http://llvm.org/viewvc/llvm-project?rev=61676&view=rev
Log:
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 {} []
^
[
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=61676&r1=61675&r2=61676&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jan 5 01:52:51 2009
@@ -36,6 +36,7 @@
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 @@
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 @@
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");
More information about the llvm-commits
mailing list