Fix crash on an @interface nested inside @implementation, rdar://10336158
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143085 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index c863e76..673b5df 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -607,11 +607,11 @@
explicit ObjCDeclContextSwitch(Parser &p) : P(p),
DC(p.getObjCDeclContext()) {
if (DC)
- P.Actions.ActOnObjCTemporaryExitContainerContext();
+ P.Actions.ActOnObjCTemporaryExitContainerContext(cast<DeclContext>(DC));
}
~ObjCDeclContextSwitch() {
if (DC)
- P.Actions.ActOnObjCReenterContainerContext();
+ P.Actions.ActOnObjCReenterContainerContext(cast<DeclContext>(DC));
}
};
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index acfdf7a..a0f4a62 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -1245,8 +1245,8 @@
/// scope for parsing/looking-up C constructs.
///
/// Must be followed by a call to \see ActOnObjCReenterContainerContext
- void ActOnObjCTemporaryExitContainerContext();
- void ActOnObjCReenterContainerContext();
+ void ActOnObjCTemporaryExitContainerContext(DeclContext *DC);
+ void ActOnObjCReenterContainerContext(DeclContext *DC);
/// ActOnTagDefinitionError - Invoked when there was an unrecoverable
/// error parsing the definition of a tag.
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 7ad8fb3..4fa9cbd 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -8287,13 +8287,13 @@
PopDeclContext();
}
-void Sema::ActOnObjCTemporaryExitContainerContext() {
+void Sema::ActOnObjCTemporaryExitContainerContext(DeclContext *DC) {
OriginalLexicalContext = CurContext;
ActOnObjCContainerFinishDefinition();
}
-void Sema::ActOnObjCReenterContainerContext() {
- ActOnObjCContainerStartDefinition(cast<Decl>(OriginalLexicalContext));
+void Sema::ActOnObjCReenterContainerContext(DeclContext *DC) {
+ ActOnObjCContainerStartDefinition(cast<Decl>(DC));
OriginalLexicalContext = 0;
}
diff --git a/test/SemaObjC/incomplete-implementation.m b/test/SemaObjC/incomplete-implementation.m
index f5c5a7c..a79628a 100644
--- a/test/SemaObjC/incomplete-implementation.m
+++ b/test/SemaObjC/incomplete-implementation.m
@@ -24,4 +24,17 @@
- Meth {return 0;} // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
@end
+@interface Q
+@end
+
+// rdar://10336158
+@implementation Q
+
+__attribute__((visibility("default")))
+@interface QN
+{
+}
+@end
+
+@end