public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: Marek Polacek <polacek@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ PATCH] Using decls
Date: Tue, 21 May 2019 15:30:00 -0000	[thread overview]
Message-ID: <eeb64c04-44bb-b91c-ad07-1b0489bd59d4@acm.org> (raw)
In-Reply-To: <20190521144355.GO7979@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

On 5/21/19 10:43 AM, Marek Polacek wrote:
> Thanks for the patch and sorry for nitpicking:
> 
> On Tue, May 21, 2019 at 10:32:31AM -0400, Nathan Sidwell wrote:
>> -/* Process a local-scope or namespace-scope using declaration.  SCOPE
>> +/* Process a local-scope or namespace-scope using declaration.
>> +   FIXME
> 
> This ain't look right.  You meant to document the INSERT_P param, right.

The INSERT_P parameter is not (yet) needed.  This patch removes it and 
cleans up the inadvertent stray FIXMEs.  Sorry for the noise.

nathan
-- 
Nathan Sidwell

[-- Attachment #2: ns-using-2.diff --]
[-- Type: text/x-patch, Size: 5340 bytes --]

2019-05-20  Nathan Sidwell  <nathan@acm.org>

	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.

Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 271416)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -7235,52 +7235,36 @@ emit_debug_info_using_namespace (tree fr
 }
 
-/* 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);
+      }
 }
 
Index: gcc/cp/name-lookup.h
===================================================================
--- gcc/cp/name-lookup.h	(revision 271416)
+++ gcc/cp/name-lookup.h	(working copy)
@@ -1,3 +1,3 @@
-/* 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>
@@ -318,6 +318,5 @@ extern void cp_emit_debug_info_for_using
 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);
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 271416)
+++ gcc/cp/parser.c	(working copy)
@@ -19738,8 +19738,5 @@ cp_parser_using_directive (cp_parser* pa
 
   /* 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 `;'.  */
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 271416)
+++ gcc/cp/pt.c	(working copy)
@@ -17044,6 +17044,5 @@ tsubst_expr (tree t, tree args, tsubst_f
 
     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;
 
Index: libcc1/libcp1plugin.cc
===================================================================
--- libcc1/libcp1plugin.cc	(revision 271416)
+++ libcc1/libcp1plugin.cc	(working copy)
@@ -942,5 +942,5 @@ plugin_add_using_namespace (cc1_plugin::
   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;

  parent reply	other threads:[~2019-05-21 15:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21 14:32 Nathan Sidwell
2019-05-21 14:44 ` Marek Polacek
2019-05-21 14:47   ` Nathan Sidwell
2019-05-21 15:30   ` Nathan Sidwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-05-23 11:07 [C++ PATCH] using decls Nathan Sidwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eeb64c04-44bb-b91c-ad07-1b0489bd59d4@acm.org \
    --to=nathan@acm.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=polacek@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).