From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105968 invoked by alias); 21 May 2019 15:30:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 100843 invoked by uid 89); 21 May 2019 15:30:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=function-scope, USING_STMT, functionscope, sk:local_b X-HELO: mail-pg1-f178.google.com Received: from mail-pg1-f178.google.com (HELO mail-pg1-f178.google.com) (209.85.215.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 May 2019 15:30:14 +0000 Received: by mail-pg1-f178.google.com with SMTP id i21so8749548pgi.12 for ; Tue, 21 May 2019 08:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=nppVO/miXSrn8WNy5QnOTxmJ59OP9U9PmbHa3M8uHOI=; b=ingSgHEtPP9ryYsTZfyuVG9d7HPfSNZpVbmT6X4+gcRLl+E+VroRrYKEtqxzidQTG3 6VEjjQR+d0jV7kQtaAkXSNYfoYIc3Zbpea7CktlFyjo5HLBCmSz+0wyDNgLaBbAnVhCe uudEhYkK5ac3fG3sZCBV9IqVOqYear1jfHgCxxOe8LYvgdt4X+/O8KoKIGFAEES9JWTu GSf95wjOjTfj1P3Gl9vdKp7Oair1AiVRjzmV7g1NzGQMwUjb3zHpQteeugMxXVR4qjA3 /AN53ItX5r2HZixzPUpRco23Z8ThgfmpxJ04gjTR6CiFw7+sjg/zJLx3dlgXvtBQ6rcK 3afg== Return-Path: Received: from ?IPv6:2620:10d:c0a3:1407:6077:ec57:6cfa:c95c? ([2620:10d:c091:500::3:8245]) by smtp.googlemail.com with ESMTPSA id a18sm33973185pfr.22.2019.05.21.08.30.08 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 08:30:09 -0700 (PDT) Subject: Re: [C++ PATCH] Using decls To: Marek Polacek Cc: GCC Patches References: <328937e0-531e-a7be-3151-e3a622be0efa@acm.org> <20190521144355.GO7979@redhat.com> From: Nathan Sidwell Message-ID: Date: Tue, 21 May 2019 15:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190521144355.GO7979@redhat.com> Content-Type: multipart/mixed; boundary="------------C7E70AC5A7CA8048A38124D3" X-SW-Source: 2019-05/txt/msg01411.txt.bz2 This is a multi-part message in MIME format. --------------C7E70AC5A7CA8048A38124D3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 554 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 --------------C7E70AC5A7CA8048A38124D3 Content-Type: text/x-patch; name="ns-using-2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ns-using-2.diff" Content-length: 5340 2019-05-20 Nathan Sidwell 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 @@ -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; --------------C7E70AC5A7CA8048A38124D3--