[C++ PATCH] Commonixe using directive finishing

https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01251.html
	gcc/cp/
	* name-lookup.c (finish_namespace_using_directive)
	(finish_local_using_directive): Merge to ...
	(finish_using_directive): ... here.  Handle both contexts.
	* name-lookup.h (finish_namespace_using_directive)
	(finish_local_using_directive): Replace with ...
	(finish_using_directive): ... this.
	* parser.c (cp_parser_using_directive): Adjust.
	* pt.c (tsubst_expr): Likewise.

	libcc1/
	* libcp1plugin.cc (plugin_add_using_namespace): Call renamed
	finish_using_directive.

From-SVN: r271420
This commit is contained in:
Nathan Sidwell 2019-05-20 13:49:53 +00:00 committed by Nathan Sidwell
parent eb06160156
commit 6db76e48c1
7 changed files with 42 additions and 49 deletions

View File

@ -1,5 +1,14 @@
2019-05-20 Nathan Sidwell <nathan@acm.org>
* name-lookup.c (finish_namespace_using_directive)
(finish_local_using_directive): Merge to ...
(finish_using_directive): ... here. Handle both contexts.
* name-lookup.h (finish_namespace_using_directive)
(finish_local_using_directive): Replace with ...
(finish_using_directive): ... this.
* parser.c (cp_parser_using_directive): Adjust.
* pt.c (tsubst_expr): Likewise.
* cp-tree.h (struct lang_decl_ns): Remove usings field.
(DECL_NAMESPACE_USING): Delete.
* name-lookup.c (name_lookup::search_usings): Use namespace's

View File

@ -7234,54 +7234,38 @@ emit_debug_info_using_namespace (tree from, tree target, bool implicit)
implicit);
}
/* Process a namespace-scope using directive. */
/* Process a using directive. */
void
finish_namespace_using_directive (tree target, tree attribs)
finish_using_directive (tree target, tree attribs)
{
gcc_checking_assert (namespace_bindings_p ());
if (target == error_mark_node)
return;
add_using_namespace (current_binding_level->using_directives,
ORIGINAL_NAMESPACE (target));
emit_debug_info_using_namespace (current_namespace,
ORIGINAL_NAMESPACE (target), false);
if (attribs == error_mark_node)
return;
for (tree a = attribs; a; a = TREE_CHAIN (a))
{
tree name = get_attribute_name (a);
if (is_attribute_p ("strong", name))
{
warning (0, "strong using directive no longer supported");
if (CP_DECL_CONTEXT (target) == current_namespace)
inform (DECL_SOURCE_LOCATION (target),
"you may use an inline namespace instead");
}
else
warning (OPT_Wattributes, "%qD attribute directive ignored", name);
}
}
/* Process a function-scope using-directive. */
void
finish_local_using_directive (tree target, tree attribs)
{
gcc_checking_assert (local_bindings_p ());
if (target == error_mark_node)
return;
if (attribs)
warning (OPT_Wattributes, "attributes ignored on local using directive");
add_stmt (build_stmt (input_location, USING_STMT, target));
if (current_binding_level->kind != sk_namespace)
add_stmt (build_stmt (input_location, USING_STMT, target));
else
emit_debug_info_using_namespace (current_binding_level->this_entity,
ORIGINAL_NAMESPACE (target), false);
add_using_namespace (current_binding_level->using_directives,
ORIGINAL_NAMESPACE (target));
if (attribs != error_mark_node)
for (tree a = attribs; a; a = TREE_CHAIN (a))
{
tree name = get_attribute_name (a);
if (current_binding_level->kind == sk_namespace
&& is_attribute_p ("strong", name))
{
warning (0, "strong using directive no longer supported");
if (CP_DECL_CONTEXT (target) == current_namespace)
inform (DECL_SOURCE_LOCATION (target),
"you may use an inline namespace instead");
}
else
warning (OPT_Wattributes, "%qD attribute directive ignored", name);
}
}
/* Pushes X into the global namespace. */

View File

@ -1,4 +1,4 @@
/* Declarations for C++ name lookup routines.
/* Declarations for -*- C++ -*- name lookup routines.
Copyright (C) 2003-2019 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
@ -317,8 +317,7 @@ extern void cp_emit_debug_info_for_using (tree, tree);
extern void finish_namespace_using_decl (tree, tree, tree);
extern void finish_local_using_decl (tree, tree, tree);
extern void finish_namespace_using_directive (tree, tree);
extern void finish_local_using_directive (tree, tree);
extern void finish_using_directive (tree, tree);
extern tree pushdecl (tree, bool is_friend = false);
extern tree pushdecl_outermost_localscope (tree);
extern tree pushdecl_top_level (tree, bool is_friend = false);

View File

@ -19737,10 +19737,7 @@ cp_parser_using_directive (cp_parser* parser)
attribs = cp_parser_attributes_opt (parser);
/* Update the symbol table. */
if (namespace_bindings_p ())
finish_namespace_using_directive (namespace_decl, attribs);
else
finish_local_using_directive (namespace_decl, attribs);
finish_using_directive (namespace_decl, attribs);
/* Look for the final `;'. */
cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);

View File

@ -17043,8 +17043,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
break;
case USING_STMT:
finish_local_using_directive (USING_STMT_NAMESPACE (t),
/*attribs=*/NULL_TREE);
finish_using_directive (USING_STMT_NAMESPACE (t), /*attribs=*/NULL_TREE);
break;
case DECL_EXPR:

View File

@ -1,3 +1,8 @@
2019-05-20 Nathan Sidwell <nathan@acm.org>
* libcp1plugin.cc (plugin_add_using_namespace): Call renamed
finish_using_directive.
2019-01-01 Jakub Jelinek <jakub@redhat.com>
Update copyright years.

View File

@ -941,7 +941,7 @@ plugin_add_using_namespace (cc1_plugin::connection *,
gcc_assert (TREE_CODE (used_ns) == NAMESPACE_DECL);
finish_namespace_using_directive (used_ns, NULL_TREE);
finish_using_directive (used_ns, NULL_TREE);
return 1;
}