[cfe-commits] r58216 - in /cfe/trunk: lib/Parse/ParseInit.cpp test/Parser/objc-init.m
Chris Lattner
sabre at nondot.org
Sun Oct 26 16:29:41 PDT 2008
Author: lattner
Date: Sun Oct 26 18:29:41 2008
New Revision: 58216
URL: http://llvm.org/viewvc/llvm-project?rev=58216&view=rev
Log:
implement some more FIXMEs, by rejecting more bogus stuff in
objc mode.
Modified:
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/test/Parser/objc-init.m
Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=58216&r1=58215&r2=58216&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Sun Oct 26 18:29:41 2008
@@ -121,8 +121,18 @@
// 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);
@@ -143,8 +153,19 @@
// 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);
}
Modified: cfe/trunk/test/Parser/objc-init.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-init.m?rev=58216&r1=58215&r2=58216&view=diff
==============================================================================
--- cfe/trunk/test/Parser/objc-init.m (original)
+++ cfe/trunk/test/Parser/objc-init.m Sun Oct 26 18:29:41 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify %s -pedantic
// rdar://5707001
@interface NSNumber;
@@ -6,6 +6,10 @@
- (unsigned) METH2;
@end
+struct SomeStruct {
+ int x, y, z, q;
+};
+
void test1() {
id objects[] = {[NSNumber METH]};
}
@@ -24,3 +28,14 @@
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}}
+ };
+}
More information about the cfe-commits
mailing list