aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-23 23:24:23 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-23 23:24:23 +0000
commitfce79ebc6c16676b106ade71356b3adfc11493e7 (patch)
treed03fbb434a637dc6bd988812fdadf6d550e6311a /lib/Sema/SemaDeclObjC.cpp
parent30a2805c2c85e6abfe3149293f83f60da018b2df (diff)
Make sure we don't accept an @interface inside another objc container
just because there was an attribute in front of it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153355 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--lib/Sema/SemaDeclObjC.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 268ab368ce..27500fcd69 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -2903,13 +2903,15 @@ Decl *Sema::ActOnMethodDeclaration(
}
bool Sema::CheckObjCDeclScope(Decl *D) {
- if (isa<TranslationUnitDecl>(CurContext->getRedeclContext()))
- return false;
// Following is also an error. But it is caused by a missing @end
// and diagnostic is issued elsewhere.
- if (isa<ObjCContainerDecl>(CurContext->getRedeclContext())) {
+ if (isa<ObjCContainerDecl>(CurContext->getRedeclContext()))
+ return false;
+
+ // If we switched context to translation unit while we are still lexically in
+ // an objc container, it means the parser missed emitting an error.
+ if (isa<TranslationUnitDecl>(getCurLexicalContext()->getRedeclContext()))
return false;
- }
Diag(D->getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
D->setInvalidDecl();