aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-12 06:27:57 +0000
committerChris Lattner <sabre@nondot.org>2010-04-12 06:27:57 +0000
commita823d6ad69beccfbc5f36db742b74e2e3ae73cee (patch)
treef98c14516e3cf81a9bdb429921f7e6e9ca8e460c
parentc987a4107c73308c58832beb1dc9709e7a3285c0 (diff)
fix a rejects-valid bug that I introduced, pointed out
by David Chisnall git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101024 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseExpr.cpp10
-rw-r--r--test/SemaObjC/super.m7
2 files changed, 12 insertions, 5 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index d1686a183e..9ec5f1677f 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -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();
diff --git a/test/SemaObjC/super.m b/test/SemaObjC/super.m
index 0c072e9194..66894230ea 100644
--- a/test/SemaObjC/super.m
+++ b/test/SemaObjC/super.m
@@ -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;
+}