]> granicus.if.org Git - clang/commitdiff
fix a rejects-valid bug that I introduced, pointed out
authorChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 06:27:57 +0000 (06:27 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 06:27:57 +0000 (06:27 +0000)
by David Chisnall

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

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

index d1686a183e342c4a02615e1e28e481a3c9685349..9ec5f1677fd85ef9c74af66b3f498a267684c6f7 100644 (file)
@@ -1436,15 +1436,15 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
 
       CastTy = Ty.get();
 
-      if (stopIfCastExpr) {
-        // Note that this doesn't parse the subsequent cast-expression, it just
-        // returns the parsed type to the callee.
+      // Note that this doesn't parse the subsequent cast-expression, it just
+      // returns the parsed type to the callee.
+      if (stopIfCastExpr)
         return OwningExprResult(Actions);
-      }
       
       // Reject the cast of super idiom in ObjC.
       if (Tok.is(tok::identifier) && getLang().ObjC1 &&
-          Tok.getIdentifierInfo() == Ident_super) {
+          Tok.getIdentifierInfo() == Ident_super && 
+          CurScope->isInObjcMethodScope()) {
         Diag(Tok.getLocation(), diag::err_illegal_super_cast)
           << SourceRange(OpenLoc, RParenLoc);
         return ExprError();
index 0c072e91945aa9168a8cae51163ec6f095c55a6b..66894230ead4fa51e4029c70d559fc7636c90305 100644 (file)
@@ -58,3 +58,10 @@ int test2() {
   struct SomeStruct super = { 0 };
   return super.X;
 }
+
+int test3() {
+  id super = 0;
+  [(B*)super instanceMethod];
+  int *s1 = (int*)super;
+  return 0;
+}