Parsing of namespaces:
-NamespaceDecl for the AST
-Checks for name clashes between namespaces and tag/normal declarations.
This commit doesn't implement proper name lookup for namespaces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50321 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 04cd254..5d49f4d 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -62,17 +62,25 @@
// FIXME: Verify no attributes were present.
// FIXME: parse this.
} else if (Tok.is(tok::l_brace)) {
+
SourceLocation LBrace = ConsumeBrace();
- // FIXME: push a scope, push a namespace decl.
-
- while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
- // FIXME capture the decls.
+
+ // Enter a scope for the namespace.
+ EnterScope(Scope::DeclScope);
+
+ DeclTy *NamespcDecl =
+ Actions.ActOnStartNamespaceDef(CurScope, IdentLoc, Ident, LBrace);
+
+ while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof))
ParseExternalDeclaration();
- }
SourceLocation RBrace = MatchRHSPunctuation(tok::r_brace, LBrace);
+ Actions.ActOnFinishNamespaceDef(NamespcDecl, RBrace);
+
+ ExitScope();
+
+ return NamespcDecl;
- // FIXME: act on this.
} else {
unsigned D = Ident ? diag::err_expected_lbrace :
diag::err_expected_ident_lbrace;