From 8b9f187ab79e4077067f57660c75d6ac24066c7e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 12 Apr 2010 17:09:27 +0000 Subject: [PATCH] tighten the check for cast of super to avoid rejecting valid code, rdar://7853261 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101048 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseExpr.cpp | 3 ++- test/SemaObjC/super.m | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 9ec5f1677f..e479c36792 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -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(); diff --git a/test/SemaObjC/super.m b/test/SemaObjC/super.m index d751d17719..9498a8ce7e 100644 --- a/test/SemaObjC/super.m +++ b/test/SemaObjC/super.m @@ -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 -- 2.40.0