diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-12 06:20:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-12 06:20:33 +0000 |
commit | cd963185f07bbbc61c660da8bb4c1264b571faec (patch) | |
tree | b156342887b659580511e6fd569cf97e9fed0232 | |
parent | df74264787d6e1b63b117de7c344ac79ad98751a (diff) | |
download | bcm5719-llvm-cd963185f07bbbc61c660da8bb4c1264b571faec.tar.gz bcm5719-llvm-cd963185f07bbbc61c660da8bb4c1264b571faec.zip |
fix a rejects-valid testcase involving super that I dreamt up.
This also fixes cases where super is used in a block in a
method which isn't valid.
llvm-svn: 101021
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaObjC/super.m | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index ad422642e47..a29ea81f761 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -639,7 +639,9 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression, // Support 'Class.property' and 'super.property' notation. if (getLang().ObjC1 && Tok.is(tok::period) && - (Actions.getTypeName(II, ILoc, CurScope) || II.isStr("super"))) { + (Actions.getTypeName(II, ILoc, CurScope) || + // Allow the base to be 'super' if in an objc-method. + (II.isStr("super") && CurScope->isInObjcMethodScope()))) { SourceLocation DotLoc = ConsumeToken(); if (Tok.isNot(tok::identifier)) { diff --git a/clang/test/SemaObjC/super.m b/clang/test/SemaObjC/super.m index bae92cbdff7..0c072e91945 100644 --- a/clang/test/SemaObjC/super.m +++ b/clang/test/SemaObjC/super.m @@ -49,3 +49,12 @@ void test() { [FooTD cMethod]; [super cMethod]; } + +struct SomeStruct { + int X; +}; + +int test2() { + struct SomeStruct super = { 0 }; + return super.X; +} |