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
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. */
-/* 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>
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);
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);