]> granicus.if.org Git - clang/commitdiff
fix a rejects-valid testcase involving super that I dreamt up.
authorChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 06:20:33 +0000 (06:20 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 06:20:33 +0000 (06:20 +0000)
This also fixes cases where super is used in a block in a
method which isn't valid.

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

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

index ad422642e4797b7ce6e9fc7fdd213994d0be1cb6..a29ea81f761e8dfa627ac77ceb18fff6e3ad001f 100644 (file)
@@ -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)) {
index bae92cbdff79de908b6fa0a54c9ed4bb84bfd892..0c072e91945aa9168a8cae51163ec6f095c55a6b 100644 (file)
@@ -49,3 +49,12 @@ void test() {
   [FooTD cMethod];
   [super cMethod];
 }
+
+struct SomeStruct {
+  int X;
+};
+
+int test2() {
+  struct SomeStruct super = { 0 };
+  return super.X;
+}