]> granicus.if.org Git - clang/commitdiff
tighten the check for cast of super to avoid rejecting valid code,
authorChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 17:09:27 +0000 (17:09 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 17:09:27 +0000 (17:09 +0000)
rdar://7853261

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

lib/Parse/ParseExpr.cpp
test/SemaObjC/super.m

index 9ec5f1677fd85ef9c74af66b3f498a267684c6f7..e479c367925242dad10dccaa068551b8d7c62b23 100644 (file)
@@ -1444,7 +1444,8 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
       // Reject the cast of super idiom in ObjC.
       if (Tok.is(tok::identifier) && getLang().ObjC1 &&
           Tok.getIdentifierInfo() == Ident_super && 
-          CurScope->isInObjcMethodScope()) {
+          CurScope->isInObjcMethodScope() &&
+          GetLookAheadToken(1).isNot(tok::period)) {
         Diag(Tok.getLocation(), diag::err_illegal_super_cast)
           << SourceRange(OpenLoc, RParenLoc);
         return ExprError();
index d751d1771945732ba75a1b813c0abf3da7254828..9498a8ce7ea9ada140986518c9b27d300d927546 100644 (file)
@@ -34,7 +34,11 @@ void takevoidptr(void*);
   [super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
   
   id X[] = { [ super superClassMethod] };
-  id Y[] = { [ super.superClassMethod iMethod] };
+  id Y[] = {
+    [ super.superClassMethod iMethod],
+    super.superClassMethod,
+    (id)super.superClassMethod  // not a cast of super: rdar://7853261
+  };
   return 0;
 }
 @end