[cfe-commits] r72234 - in /cfe/trunk: lib/Sema/SemaInit.cpp lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-c99.cpp
Douglas Gregor
dgregor at apple.com
Thu May 21 16:30:39 PDT 2009
Author: dgregor
Date: Thu May 21 18:30:39 2009
New Revision: 72234
URL: http://llvm.org/viewvc/llvm-project?rev=72234&view=rev
Log:
Template instantiation for GNU array-range designators.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
cfe/trunk/test/SemaTemplate/instantiate-c99.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=72234&r1=72233&r2=72234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu May 21 18:30:39 2009
@@ -1672,7 +1672,7 @@
else if (StartValue.getBitWidth() < EndValue.getBitWidth())
StartValue.extend(EndValue.getBitWidth());
- if (EndValue < StartValue) {
+ if (!StartDependent && !EndDependent && EndValue < StartValue) {
Diag(D.getEllipsisLoc(), diag::err_array_designator_empty_range)
<< StartValue.toString(10) << EndValue.toString(10)
<< StartIndex->getSourceRange() << EndIndex->getSourceRange();
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72234&r1=72233&r2=72234&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Thu May 21 18:30:39 2009
@@ -628,7 +628,22 @@
continue;
}
- assert(false && "No array range designators, yet");
+ assert(D->isArrayRangeDesignator() && "New kind of designator?");
+ OwningExprResult Start = Visit(E->getArrayRangeStart(*D));
+ if (Start.isInvalid())
+ return SemaRef.ExprError();
+
+ OwningExprResult End = Visit(E->getArrayRangeEnd(*D));
+ if (End.isInvalid())
+ return SemaRef.ExprError();
+
+ Desig.AddDesignator(Designator::getArrayRange(Start.get(),
+ End.get(),
+ D->getLBracketLoc(),
+ D->getEllipsisLoc()));
+
+ ArrayExprs.push_back(Start.release());
+ ArrayExprs.push_back(End.release());
}
OwningExprResult Result =
Modified: cfe/trunk/test/SemaTemplate/instantiate-c99.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-c99.cpp?rev=72234&r1=72233&r2=72234&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-c99.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-c99.cpp Thu May 21 18:30:39 2009
@@ -54,3 +54,16 @@
template struct DesigArrayInit0<int[8], 5, 3, float, int>;
template struct DesigArrayInit0<int[8], 5, 13, float, int>; // expected-note{{instantiation}}
+
+template<typename T, int Subscript1, int Subscript2,
+ typename Val1>
+struct DesigArrayRangeInit0 {
+ void f(Val1 val1) {
+ T array = {
+ [Subscript1...Subscript2] = val1 // expected-error{{exceeds}}
+ };
+ }
+};
+
+template struct DesigArrayRangeInit0<int[8], 3, 5, float>;
+template struct DesigArrayRangeInit0<int[8], 5, 13, float>; // expected-note{{instantiation}}
More information about the cfe-commits
mailing list