PR2151 (by not creating the empty implicit init list).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51556
91177308-0d34-0410-b5e6-
96231b3b80d8
"scalar initializer cannot be empty")
DIAG(err_illegal_initializer, ERROR,
"illegal initializer (only variables can be initialized)")
+DIAG(err_implicit_empty_initializer, ERROR,
+ "initializer for aggregate with no elements requires explicit braces")
DIAG(err_redefinition_of_label, ERROR,
"redefinition of label '%0'")
else
assert(0 && "CheckImplicitInitList(): Illegal type");
+ if (maxElements == 0) {
+ SemaRef->Diag(ParentIList->getInit(Index)->getLocStart(),
+ diag::err_implicit_empty_initializer);
+ hadError = true;
+ return;
+ }
+
// Check the element types *before* we create the implicit init list;
// otherwise, we might end up taking the wrong number of elements
unsigned NewIndex = Index;
void varArray() {
int c[][x] = { 0 }; //expected-error{{variable-sized object may not be initialized}}
}
+
+// PR2151
+int emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct extension}} expected-error{{initializer for aggregate with no elements}}
+