summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-14 05:08:22 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-14 05:08:22 +0000
commit05cfc295f45dae510104f56d4ee6cb94206c3799 (patch)
treea479564ec4d2a0f2bc76498bc0e69840b6f9354d /clang/lib
parentf3d3ae665cdb8cdd72ecab587929321a1dae6290 (diff)
downloadbcm5719-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.cpp8
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);
OpenPOWER on IntegriCloud