]> granicus.if.org Git - clang/commitdiff
When we have two identifiers in a row in Objective-C, make sure to
authorDouglas Gregor <dgregor@apple.com>
Tue, 28 Sep 2010 17:48:56 +0000 (17:48 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 28 Sep 2010 17:48:56 +0000 (17:48 +0000)
verify that we aren't in a message-send expression before digging into
the identifier or looking ahead more tokens. Fixes a regression
(<rdar://problem/8483253>) I introduced with bracket insertion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114968 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
test/SemaObjCXX/message.mm

index e04e62bcb2c011e61168db748d00e298f07a3199..2785f1b14da8389be29361348e43b2e3fdec56bf 100644 (file)
@@ -671,7 +671,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
     // If we have an Objective-C class name followed by an identifier and
     // either ':' or ']', this is an Objective-C class message send that's
     // missing the opening '['. Recovery appropriately.
-    if (getLang().ObjC1 && Tok.is(tok::identifier)) {
+    if (getLang().ObjC1 && Tok.is(tok::identifier) && !InMessageExpression) {
       const Token& Next = NextToken();
       if (Next.is(tok::colon) || Next.is(tok::r_square))
         if (ParsedType Typ = Actions.getTypeName(II, ILoc, getCurScope()))
index ab86d9437f02bd7a52afcb45c7729b70ff39d63e..fce546304f26e99d0932536dfcdea81d61fbca40 100644 (file)
@@ -92,3 +92,23 @@ void test_I5(I5 *i5, String s) {
   [i5 method:"hello" other:s];
   [i5 method:s other:"world"]; // expected-error{{non-const lvalue reference to type 'String' cannot bind to a value of unrelated type 'const char [6]'}}
 }
+
+// <rdar://problem/8483253>
+@interface A
+
+struct X { };
+
++ (A *)create:(void (*)(void *x, X r, void *data))callback
+             callbackData:(void *)callback_data;
+
+@end
+
+
+void foo(void)
+{
+  void *fun;
+  void *ptr;
+  X r;
+  A *im = [A create:(void (*)(void *cgl_ctx, X r, void *data)) fun
+             callbackData:ptr];
+}