forked from OSchip/llvm-project
Template instantiation for GNU array-range designators.
llvm-svn: 72234
This commit is contained in:
parent
ca1aeecd37
commit
0f9d4003df
|
@ -1672,7 +1672,7 @@ Sema::OwningExprResult Sema::ActOnDesignatedInitializer(Designation &Desig,
|
|||
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();
|
||||
|
|
|
@ -628,7 +628,22 @@ TemplateExprInstantiator::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
|
|||
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 =
|
||||
|
|
|
@ -54,3 +54,16 @@ struct DesigArrayInit0 {
|
|||
|
||||
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}}
|
||||
|
|
Loading…
Reference in New Issue