[cfe-commits] r71181 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/forward-class-1.m
Fariborz Jahanian
fjahanian at apple.com
Thu May 7 14:49:26 PDT 2009
Author: fjahanian
Date: Thu May 7 16:49:26 2009
New Revision: 71181
URL: http://llvm.org/viewvc/llvm-project?rev=71181&view=rev
Log:
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/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/forward-class-1.m
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=71181&r1=71180&r2=71181&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu May 7 16:49:26 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/trunk/test/SemaObjC/forward-class-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/forward-class-1.m?rev=71181&r1=71180&r2=71181&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/forward-class-1.m (original)
+++ cfe/trunk/test/SemaObjC/forward-class-1.m Thu May 7 16:49:26 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