summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-09-22 00:02:16 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-09-22 00:02:16 +0000
commitaa78931e914f79a1dc95f8f5321e63cba45eeb7d (patch)
treef7e7e8b6339d66bbc7c26c0e13ff86c783c5a62d /clang/lib/Sema
parent829aec590030e40337c5dc873c497d9044f0f74b (diff)
downloadbcm5719-llvm-aa78931e914f79a1dc95f8f5321e63cba45eeb7d.tar.gz
bcm5719-llvm-aa78931e914f79a1dc95f8f5321e63cba45eeb7d.zip
ObjectiveC: ObjC declarations, including forward class
and protocols can be at global scope only. llvm-svn: 191155
Diffstat (limited to 'clang/lib/Sema')
-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