diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-14 05:08:22 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-14 05:08:22 +0000 |
commit | 95f1b15ce1b281c8517d77792abe540753fbcc12 (patch) | |
tree | d65e72d070343f5c9907fc6398659c9a7de82a35 /lib/Parse/ParseDeclCXX.cpp | |
parent | 00b4b039f02d338ae4774797053235a7e65abbde (diff) |
Namespaces can only be defined at global or namespace scope. Fixes PR6596.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 015ac5b5dd..149efda855 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -87,6 +87,14 @@ Parser::DeclPtrTy Parser::ParseNamespace(unsigned Context, SourceLocation LBrace = ConsumeBrace(); + if (CurScope->isClassScope() || CurScope->isTemplateParamScope() || + CurScope->isInObjcMethodScope() || CurScope->getBlockParent() || + CurScope->getFnParent()) { + Diag(LBrace, diag::err_namespace_nonnamespace_scope); + SkipUntil(tok::r_brace, false); + return DeclPtrTy(); + } + // Enter a scope for the namespace. ParseScope NamespaceScope(this, Scope::DeclScope); |