// If Objective-C is enabled and this is a typename or other identifier
// receiver, parse this as a message send expression.
if (getLang().ObjC1 && isTokObjCMessageIdentifierReceiver()) {
- // FIXME: Emit ext_gnu_missing_equal_designator for inits like
- // [4][foo bar].
+ // If we have exactly one array designator, this used the GNU
+ // 'designation: array-designator' extension, otherwise there should be no
+ // designators at all!
+ if (Desig) {
+ if (Desig->getNumDesignators() == 1 &&
+ (Desig->getDesignator(0).isArrayDesignator() ||
+ Desig->getDesignator(0).isArrayRangeDesignator()))
+ Diag(StartLoc, diag::ext_gnu_missing_equal_designator);
+ else
+ Diag(Tok, diag::err_expected_equal_designator);
+ }
+
IdentifierInfo *Name = Tok.getIdentifierInfo();
ConsumeToken();
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, Name, 0);
// an assignment-expression production.
if (getLang().ObjC1 && Tok.isNot(tok::ellipsis) &&
Tok.isNot(tok::r_square)) {
- // FIXME: Emit ext_gnu_missing_equal_designator for inits like
- // [4][foo bar].
+
+ // If we have exactly one array designator, this used the GNU
+ // 'designation: array-designator' extension, otherwise there should be no
+ // designators at all!
+ if (Desig) {
+ if (Desig->getNumDesignators() == 1 &&
+ (Desig->getDesignator(0).isArrayDesignator() ||
+ Desig->getDesignator(0).isArrayRangeDesignator()))
+ Diag(StartLoc, diag::ext_gnu_missing_equal_designator);
+ else
+ Diag(Tok, diag::err_expected_equal_designator);
+ }
+
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, 0,Idx.Val);
}
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify %s -pedantic
// rdar://5707001
@interface NSNumber;
- (unsigned) METH2;
@end
+struct SomeStruct {
+ int x, y, z, q;
+};
+
void test1() {
id objects[] = {[NSNumber METH]};
}
unsigned x[] = {[NSNumber METH2]+2};
}
+void test5(NSNumber *x) {
+ unsigned y[] = {
+ [4][NSNumber METH2]+2, // expected-warning {{use of GNU 'missing =' extension in designator}}
+ [4][x METH2]+2 // expected-warning {{use of GNU 'missing =' extension in designator}}
+ };
+
+ struct SomeStruct z = {
+ .x = [x METH2], // ok.
+ .x [x METH2] // expected-error {{expected '=' or another designator}}
+ };
+}