[cfe-commits] r71185 - in /cfe/branches/Apple/Dib: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/forward-class-1.m

Mike Stump mrs at apple.com
Thu May 7 15:19:53 PDT 2009


Author: mrs
Date: Thu May  7 17:19:52 2009
New Revision: 71185

URL: http://llvm.org/viewvc/llvm-project?rev=71185&view=rev
Log:
Merge in 71181:

a forward class declaration matching a typedef name of a class
refers to the underlying class.
This is radar 6859726. Steve, please read the radar for my rational.

Modified:
    cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp
    cfe/branches/Apple/Dib/test/SemaObjC/forward-class-1.m

Modified: cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp?rev=71185&r1=71184&r2=71185&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp Thu May  7 17:19:52 2009
@@ -1075,6 +1075,13 @@
         Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
         Diag(PrevDecl->getLocation(), diag::note_previous_definition);
       }
+      else if (TDD) {
+        // a forward class declaration matching a typedef name of a class
+        // refers to the underlying class.
+        if (ObjCInterfaceType * OI = 
+              dyn_cast<ObjCInterfaceType>(TDD->getUnderlyingType()))
+          PrevDecl = OI->getDecl();
+      }
     }
     ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); 
     if (!IDecl) {  // Not already seen?  Make a forward decl.

Modified: cfe/branches/Apple/Dib/test/SemaObjC/forward-class-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/SemaObjC/forward-class-1.m?rev=71185&r1=71184&r2=71185&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/SemaObjC/forward-class-1.m (original)
+++ cfe/branches/Apple/Dib/test/SemaObjC/forward-class-1.m Thu May  7 17:19:52 2009
@@ -22,3 +22,26 @@
 
 @interface INTF2 : INTF1 // expected-error {{duplicate interface definition for class 'INTF2'}}
 @end
+
+// 2nd test of a forward class declaration matching a typedef name
+// referring to class object.
+// FIXME. This may become a negative test should we decide to make this an error.
+//
+ at interface NSObject @end
+
+ at protocol XCElementP @end
+
+typedef NSObject <XCElementP> XCElement;
+
+ at interface XCElementMainImp  {
+  XCElement * _editingElement;
+}
+ at end
+
+ at class XCElement;
+
+ at implementation XCElementMainImp
+- (XCElement *)editingElement  { return _editingElement;  }
+ at end
+
+





More information about the cfe-commits mailing list