[C++ PATCH] Commonixe using directive finishing
authorNathan Sidwell <nathan@acm.org>
Mon, 20 May 2019 13:49:53 +0000 (13:49 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 20 May 2019 13:49:53 +0000 (13:49 +0000)
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

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h
gcc/cp/parser.c
gcc/cp/pt.c
libcc1/ChangeLog
libcc1/libcp1plugin.cc

index b9d128434e325031102eb40923181fc069e6dc92..75236fb29687019f98d50c3f754aad8e0602fe20 100644 (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
index 58f3265352d297f492036cccee5289fb79ae46ff..f7952eebe0cb94731b3c8cae101729a89f825714 100644 (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.  */
index 311654af75d87071a84bcc1b9bc63b72e7cc9283..aa6180f2d2a45706f2df18a9e0327fb8a00fdd72 100644 (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);
index 6705d64389c1ed90ca49c2f20edaee49526f6e22..b2d6c33300d40f4195c7f21ce23550694296c25c 100644 (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);
index ab79a9e73fac48a344efb3bb5b37c8267a11f3df..97d8f08c94d912877000ecfe6e5538691f8f0de0 100644 (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:
index 0570304b9b7e1c183ce38ef10bccd0e88744f39e..376e3622410fb4e72725d53d1264695c3606d603 100644 (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.
index 2aab488ba2ae714598f9bb76f03c0ca6db2dcd04..eed94662f85d07d00a13173418febebbf791fe0c 100644 (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;
 }