aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2019-05-20 13:49:53 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2019-05-20 13:49:53 +0000
commit6db76e48c18bae5432634a83643542dacf2273e9 (patch)
tree6d3edd79956d8bce5509eb3ddbba1ccf9ba719f5 /gcc
parenteb061601564dfe61d8a2fe8519a7b6057af2b17d (diff)
downloadgcc-6db76e48c18bae5432634a83643542dacf2273e9.zip
gcc-6db76e48c18bae5432634a83643542dacf2273e9.tar.gz
gcc-6db76e48c18bae5432634a83643542dacf2273e9.tar.bz2
[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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/name-lookup.c62
-rw-r--r--gcc/cp/name-lookup.h5
-rw-r--r--gcc/cp/parser.c5
-rw-r--r--gcc/cp/pt.c3
5 files changed, 36 insertions, 48 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b9d1284..75236fb 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 58f3265..f7952ee 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -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. */
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index 311654a..aa6180f 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -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);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 6705d64..b2d6c33 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ab79a9e..97d8f08 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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: