From 458bacff986ed8d30e7ae191c823d4db6cfaf16b Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 27 Oct 2011 00:09:34 +0000 Subject: [PATCH] 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 --- include/clang/Parse/Parser.h | 4 ++-- include/clang/Sema/Sema.h | 4 ++-- lib/Sema/SemaDecl.cpp | 6 +++--- test/SemaObjC/incomplete-implementation.m | 13 +++++++++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index c863e76b9d..673b5df093 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -607,11 +607,11 @@ private: explicit ObjCDeclContextSwitch(Parser &p) : P(p), DC(p.getObjCDeclContext()) { if (DC) - P.Actions.ActOnObjCTemporaryExitContainerContext(); + P.Actions.ActOnObjCTemporaryExitContainerContext(cast(DC)); } ~ObjCDeclContextSwitch() { if (DC) - P.Actions.ActOnObjCReenterContainerContext(); + P.Actions.ActOnObjCReenterContainerContext(cast(DC)); } }; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index acfdf7a583..a0f4a628fa 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1245,8 +1245,8 @@ public: /// 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 7ad8fb34b8..4fa9cbdcc5 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -8287,13 +8287,13 @@ void Sema::ActOnObjCContainerFinishDefinition() { PopDeclContext(); } -void Sema::ActOnObjCTemporaryExitContainerContext() { +void Sema::ActOnObjCTemporaryExitContainerContext(DeclContext *DC) { OriginalLexicalContext = CurContext; ActOnObjCContainerFinishDefinition(); } -void Sema::ActOnObjCReenterContainerContext() { - ActOnObjCContainerStartDefinition(cast(OriginalLexicalContext)); +void Sema::ActOnObjCReenterContainerContext(DeclContext *DC) { + ActOnObjCContainerStartDefinition(cast(DC)); OriginalLexicalContext = 0; } diff --git a/test/SemaObjC/incomplete-implementation.m b/test/SemaObjC/incomplete-implementation.m index f5c5a7cc18..a79628aeed 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 -- 2.40.0