return &Designations[i];
return 0;
}
+
+ /// EraseDesignation - If there is a designator for the specified initializer
+ /// index, remove it.
+ void EraseDesignation(unsigned Idx) {
+ Designation *D =const_cast<Designation*>(getDesignationForInitializer(Idx));
+ if (D == 0) return; // No designator.
+
+ D->FreeExprs(Actions);
+ unsigned SlotNo = D-&Designations[0];
+ Designations.erase(Designations.begin()+SlotNo);
+ }
};
ExprResult SubElt;
if (!MayBeDesignationStart(Tok.getKind(), PP))
SubElt = ParseInitializer();
- else
+ else {
SubElt = ParseInitializerWithPotentialDesignator(InitExprDesignations,
InitExprs.size());
-
+
+ // If we had an erroneous initializer, and we had a potentially valid
+ // designator, make sure to remove the designator from
+ // InitExprDesignations, otherwise we'll end up with a designator with no
+ // making initializer.
+ if (SubElt.isInvalid)
+ InitExprDesignations.EraseDesignation(InitExprs.size());
+ }
+
// If we couldn't parse the subelement, bail out.
if (!SubElt.isInvalid) {
InitExprs.push_back(SubElt.Val);
((int)(&((struct sym_reg *)0)->nc_gpreg)) & 0,
8 * ((int)(&((struct sym_reg *)0)->nc_gpreg))
};
+
+// PR3001
+struct s1 s2 = {
+ .a = sizeof(struct s3), // expected-error {{invalid application of 'sizeof'}}
+ .b = bogus // expected-error {{use of undeclared identifier 'bogus'}}
+}
+