aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-05-07 21:49:26 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-05-07 21:49:26 +0000
commitcae27c51f0da674cdd3b53b8b2f7ba08c44c54b0 (patch)
treea267bd35d3d2854d642170400f2623dbeeb7496f
parent908116859ed8c166c1c0712992e504edd0c5a6e1 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71181 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclObjC.cpp7
-rw-r--r--test/SemaObjC/forward-class-1.m23
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 0e655a493d..27f127716e 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1075,6 +1075,13 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
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.
diff --git a/test/SemaObjC/forward-class-1.m b/test/SemaObjC/forward-class-1.m
index d8eb311cf4..f5f9505666 100644
--- a/test/SemaObjC/forward-class-1.m
+++ b/test/SemaObjC/forward-class-1.m
@@ -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.
+//
+@interface NSObject @end
+
+@protocol XCElementP @end
+
+typedef NSObject <XCElementP> XCElement;
+
+@interface XCElementMainImp {
+ XCElement * _editingElement;
+}
+@end
+
+@class XCElement;
+
+@implementation XCElementMainImp
+- (XCElement *)editingElement { return _editingElement; }
+@end
+
+