aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sema/SemaDecl.cpp8
-rw-r--r--include/clang/AST/Decl.h4
-rw-r--r--test/Sema/objc-legacy-implementation-1.m9
3 files changed, 19 insertions, 2 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 9a52874f79..5470eb456b 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -1105,6 +1105,14 @@ Sema::DeclTy *Sema::ObjcStartClassImplementation(Scope *S,
ObjcImplementationDecl* IMPDecl =
new ObjcImplementationDecl(AtClassImplLoc, ClassName, SDecl);
+ if (!IDecl) {
+ // Legacy case of @implementation with no corresponding @interface.
+ // Build, chain & install the interface decl into the identifier.
+ IDecl = new ObjcInterfaceDecl(AtClassImplLoc, 0, ClassName);
+ IDecl->setNext(ClassName->getFETokenInfo<ScopedDecl>());
+ ClassName->setFETokenInfo(IDecl);
+
+ }
// Check that there is no duplicate implementation of this class.
bool err = false;
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 425e8711ea..7cb370b41c 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -858,7 +858,7 @@ public:
static bool classof(const ObjcCategoryDecl *D) { return true; }
};
-class ObjcImplementationDecl : public ScopedDecl {
+class ObjcImplementationDecl : public TypeDecl {
/// Implementation Class's super class.
ObjcInterfaceDecl *SuperClass;
@@ -878,7 +878,7 @@ class ObjcImplementationDecl : public ScopedDecl {
public:
ObjcImplementationDecl(SourceLocation L, IdentifierInfo *Id,
ObjcInterfaceDecl* superDecl)
- : ScopedDecl(ObjcImplementation, L, Id, 0),
+ : TypeDecl(ObjcImplementation, L, Id, 0),
SuperClass(superDecl),
Ivars(0), NumIvars(-1),
InsMethods(0), NumInsMethods(-1), ClsMethods(0), NumClsMethods(-1) {}
diff --git a/test/Sema/objc-legacy-implementation-1.m b/test/Sema/objc-legacy-implementation-1.m
new file mode 100644
index 0000000000..c706ec7543
--- /dev/null
+++ b/test/Sema/objc-legacy-implementation-1.m
@@ -0,0 +1,9 @@
+@implementation INTF // expected-warning {{cannot find interface declaration for 'INTF'}}
+@end
+
+INTF* pi;
+
+INTF* FUNC()
+{
+ return pi;
+}