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 | 05cfc295f45dae510104f56d4ee6cb94206c3799 (patch) | |
| tree | a479564ec4d2a0f2bc76498bc0e69840b6f9354d /clang/lib | |
| parent | f3d3ae665cdb8cdd72ecab587929321a1dae6290 (diff) | |
| download | bcm5719-llvm-05cfc295f45dae510104f56d4ee6cb94206c3799.tar.gz bcm5719-llvm-05cfc295f45dae510104f56d4ee6cb94206c3799.zip | |
Namespaces can only be defined at global or namespace scope. Fixes PR6596.
llvm-svn: 103767
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 015ac5b5ddd..149efda8551 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/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); |

