]> granicus.if.org Git - clang/commitdiff
fix a bug I noticed by inspection, correcting two reject-valid bugs.
authorChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 06:36:00 +0000 (06:36 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 06:36:00 +0000 (06:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101026 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseInit.cpp
lib/Parse/ParseObjc.cpp
test/SemaObjC/super.m

index 57751c9c3fb55be604cc08e629be11bb08add1fc..123908d25a4be2328db7b96b7d0f7ee46fbba779 100644 (file)
@@ -14,6 +14,7 @@
 #include "clang/Parse/Designator.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Parse/Scope.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
@@ -125,12 +126,16 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
     SourceLocation StartLoc = ConsumeBracket();
 
     // If Objective-C is enabled and this is a typename (class message send) or
-    // 'super', parse this as a message send expression.
+    // send to 'super', parse this as a message send expression.
     if (getLang().ObjC1 && Tok.is(tok::identifier)) {
       IdentifierInfo *II = Tok.getIdentifierInfo();
 
-      if (II == Ident_super || Actions.getTypeName(*II, Tok.getLocation(),
-                                                   CurScope)) {
+      // Three cases. This is a message send to a type: [type foo]
+      // This is a message send to super:  [super foo]
+      // This is a message sent to an expr:  [super.bar foo]
+      if (Actions.getTypeName(*II, Tok.getLocation(), CurScope) ||
+          (II == Ident_super && GetLookAheadToken(1).isNot(tok::period) &&
+           CurScope->isInObjcMethodScope())) {
         // If we have exactly one array designator, this used the GNU
         // 'designation: array-designator' extension, otherwise there should be no
         // designators at all!
index 42076a244ea029fd220f8e70cd2879d16a4c6cda..6c5053d4fbceb2f3f431846e7226cc4f9163d2f6 100644 (file)
@@ -1723,7 +1723,6 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
 
     // If this is '[' 'super', then this is a magic superclass message.
     // We parse '[' 'super' '.' 'foo'  as an expression?
-    // FIXME: Not in ParseInit.cpp?
     if ((II == Ident_super && GetLookAheadToken(1).isNot(tok::period) &&
          CurScope->isInObjcMethodScope()) ||
         // Check to see if this is a typename.  If so, it is a class message.
index 66894230ead4fa51e4029c70d559fc7636c90305..88de77c259ad1d743150b8780a3f40086f7eb977 100644 (file)
@@ -6,6 +6,7 @@
 @end
 
 @interface A
++ superClassMethod;
 @end
 
 @interface B : A
@@ -21,6 +22,9 @@
 
 + classMethod {
   [super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
+  
+  id X[] = { [ super superClassMethod] };
+  id Y[] = { [ super.superClassMethod iMethod] };
   return 0;
 }
 @end
@@ -63,5 +67,7 @@ int test3() {
   id super = 0;
   [(B*)super instanceMethod];
   int *s1 = (int*)super;
+  
+  id X[] = { [ super superClassMethod] };
   return 0;
 }