aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2008-02-25 01:26:24 -0500
committerJason Merrill <jason@gcc.gnu.org>2008-02-25 01:26:24 -0500
commit4cfaec1cefa9e393cceb88fa818c7c2530e75289 (patch)
treeb3e9a71438b63c4eab718359b3976d6d06ff3474 /gcc/cp/parser.c
parentc9be0915bde2e7c447889dc651ee561e1d742ee1 (diff)
downloadgcc-4cfaec1cefa9e393cceb88fa818c7c2530e75289.zip
gcc-4cfaec1cefa9e393cceb88fa818c7c2530e75289.tar.gz
gcc-4cfaec1cefa9e393cceb88fa818c7c2530e75289.tar.bz2
re PR c++/33486 (namespace association doesn't handle parallel namespaces)
* gcc/cp/parser.c (cp_parser_declaration): Handle 'inline namespace'. (cp_parser_namespace_definition): Likewise. PR c++/33486 * gcc/cp/name-lookup.c (arg_assoc_namespace): Look down into inline namespaces, too. * libstdc++-v3/include/bits/c++config: Use 'inline namespace' instead of strong using. From-SVN: r132611
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index a5bd055..cb00593 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -7737,6 +7737,10 @@ cp_parser_declaration (cp_parser* parser)
|| token2.type == CPP_OPEN_BRACE
|| token2.keyword == RID_ATTRIBUTE))
cp_parser_namespace_definition (parser);
+ /* An inline (associated) namespace definition. */
+ else if (token1.keyword == RID_INLINE
+ && token2.keyword == RID_NAMESPACE)
+ cp_parser_namespace_definition (parser);
/* Objective-C++ declaration/definition. */
else if (c_dialect_objc () && OBJC_IS_AT_KEYWORD (token1.keyword))
cp_parser_objc_declaration (parser);
@@ -11562,6 +11566,15 @@ cp_parser_namespace_definition (cp_parser* parser)
{
tree identifier, attribs;
bool has_visibility;
+ bool is_inline;
+
+ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_INLINE))
+ {
+ is_inline = true;
+ cp_lexer_consume_token (parser->lexer);
+ }
+ else
+ is_inline = false;
/* Look for the `namespace' keyword. */
cp_parser_require_keyword (parser, RID_NAMESPACE, "`namespace'");
@@ -11583,6 +11596,21 @@ cp_parser_namespace_definition (cp_parser* parser)
/* Start the namespace. */
push_namespace (identifier);
+ /* "inline namespace" is equivalent to a stub namespace definition
+ followed by a strong using directive. */
+ if (is_inline)
+ {
+ tree namespace = current_namespace;
+ /* Set up namespace association. */
+ DECL_NAMESPACE_ASSOCIATIONS (namespace)
+ = tree_cons (CP_DECL_CONTEXT (namespace), NULL_TREE,
+ DECL_NAMESPACE_ASSOCIATIONS (namespace));
+ /* Import the contents of the inline namespace. */
+ pop_namespace ();
+ do_using_directive (namespace);
+ push_namespace (identifier);
+ }
+
has_visibility = handle_namespace_attrs (current_namespace, attribs);
/* Parse the body of the namespace. */