summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index b938bd6f8b0..ec822212899 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -809,6 +809,12 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
unsigned NumElts,
AttributeList *attrList) {
SmallVector<Decl *, 8> DeclsInGroup;
+ if (isa<ObjCContainerDecl>(CurContext)) {
+ Diag(AtProtocolLoc,
+ diag::err_objc_decls_may_only_appear_in_global_scope);
+ return BuildDeclaratorGroup(DeclsInGroup, false);
+ }
+
for (unsigned i = 0; i != NumElts; ++i) {
IdentifierInfo *Ident = IdentList[i].first;
ObjCProtocolDecl *PrevDecl = LookupProtocol(Ident, IdentList[i].second,
@@ -1927,6 +1933,12 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
SourceLocation *IdentLocs,
unsigned NumElts) {
SmallVector<Decl *, 8> DeclsInGroup;
+ if (isa<ObjCContainerDecl>(CurContext)) {
+ Diag(AtClassLoc,
+ diag::err_objc_decls_may_only_appear_in_global_scope);
+ return BuildDeclaratorGroup(DeclsInGroup, false);
+ }
+
for (unsigned i = 0; i != NumElts; ++i) {
// Check for another declaration kind with the same name.
NamedDecl *PrevDecl
OpenPOWER on IntegriCloud