From patchwork Thu Apr 27 18:02:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 756098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wDPtG0B4Lz9sN8 for ; Fri, 28 Apr 2017 04:02:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="HNOKZ6W0"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=aaQ1SYAW5ehQU9jGL ujuVziclW1jDx8cSG4c0o6BX+ntjd8eporriMZfg4pyFYxKudiXPHrsQHqw5tMsx f/sYsScfbMD55qegG/5qr3/LSfB0VdKRIGPVaQebx4gSBuEajDheNLG+jPAeoE0P c+27LS1V/w/j/sjpVF8zo/XdA8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=wxVworFlfWqZxjxzgCrmxaF xTYc=; b=HNOKZ6W0epnd+KYiA5rqpp3rpe9AZTwO/ets0oqykL5rE8C1iACO7D2 sjMGMKu2/Qm1YhKY00eGf/gMxY0TTFqmdshbR0sxg8T/daLAej3JDouVWmvGJ9gE VaJqcq0rvYag9NOhypQTr1cQEWyj6qYu39bYJiX4JetpXsH37OLs= Received: (qmail 108857 invoked by alias); 27 Apr 2017 18:02:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 108588 invoked by uid 89); 27 Apr 2017 18:02:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.1 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=61617, our X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Apr 2017 18:02:10 +0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v3RI28Ph000796 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Apr 2017 18:02:09 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v3RI28lk001901 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Apr 2017 18:02:08 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v3RI27kA020631; Thu, 27 Apr 2017 18:02:07 GMT Received: from [192.168.1.4] (/87.20.193.125) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 27 Apr 2017 11:02:07 -0700 Subject: [C++ Patch] Remove is_auto_or_concept, etc (Was: Re: [C++, concepts] Two slightly obscure pt.c functions?) To: "gcc@gnu.org" References: <5859ec12-a027-c944-57a4-7c49320429c6@oracle.com> Cc: Jason Merrill , Adam Butcher , "gcc-patches@gcc.gnu.org" From: Paolo Carlini Message-ID: <24d74e87-7b21-0f8f-fe9b-08d0824a2c64@oracle.com> Date: Thu, 27 Apr 2017 20:02:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <5859ec12-a027-c944-57a4-7c49320429c6@oracle.com> X-IsSubscribed: yes Hi again, On 26/04/2017 12:32, Paolo Carlini wrote: > Hi, > > in 2013 (2013-09-16) Adam added two slightly obscure functions and I > can't find much around in terms of rationale, etc: > > /* Returns true iff TYPE is a TEMPLATE_TYPE_PARM representing 'auto', > 'decltype(auto)' or a concept. */ > > bool > is_auto_or_concept (const_tree type) > { > return is_auto (type); // or concept > } > > /* Returns the TEMPLATE_TYPE_PARM in TYPE representing a generic type > (`auto' or > a concept identifier) iff TYPE contains a use of a generic type. > Returns > NULL_TREE otherwise. */ > > tree > type_uses_auto_or_concept (tree type) > { > return find_type_usage (type, is_auto_or_concept); > } > > The latter seems completely unused (it's meant for debugging > purposes?); the former evidently simply forwards to is_auto, and we > end up in the front-end with uses of both, which in fact are > equivalent, which seems weird: IMHO, if they are actually equivalent > in our implementation we should clearly explain that in the comment > and have only one. Or what? ... replying to myself, in practice we could do the below, which certainly passes testing, and in fact now seems to me even more obvious than I thought a couple of days ago... Thanks, Paolo. ///////////////////// 2017-04-27 Paolo Carlini * pt.c (is_auto_or_concept): Remove. (type_uses_auto_or_concept): Remove, unused. (find_parameter_packs_r, extract_autos_r, is_auto_r): Adjust. * parser.c (tree_type_is_auto_or_concept): Remove, unused. * cp-tree.h (is_auto_or_concept): Remove. Index: cp-tree.h =================================================================== --- cp-tree.h (revision 247347) +++ cp-tree.h (working copy) @@ -6161,7 +6161,6 @@ extern void append_type_to_template_for_access_che extern tree convert_generic_types_to_packs (tree, int, int); extern tree splice_late_return_type (tree, tree); extern bool is_auto (const_tree); -extern bool is_auto_or_concept (const_tree); extern tree process_template_parm (tree, location_t, tree, bool, bool); extern tree end_template_parm_list (tree); Index: parser.c =================================================================== --- parser.c (revision 247347) +++ parser.c (working copy) @@ -38791,16 +38791,6 @@ make_generic_type_name () return get_identifier (buf); } -/* Predicate that behaves as is_auto_or_concept but matches the parent - node of the generic type rather than the generic type itself. This - allows for type transformation in add_implicit_template_parms. */ - -static inline bool -tree_type_is_auto_or_concept (const_tree t) -{ - return TREE_TYPE (t) && is_auto_or_concept (TREE_TYPE (t)); -} - /* Add an implicit template type parameter to the CURRENT_TEMPLATE_PARMS (creating a new template parameter list if necessary). Returns the newly created template type parm. */ Index: pt.c =================================================================== --- pt.c (revision 247347) +++ pt.c (working copy) @@ -3489,7 +3489,7 @@ find_parameter_packs_r (tree *tp, int *walk_subtre parameter pack (14.6.3), or the type-specifier-seq of a type-id that is a pack expansion, the invented template parameter is a template parameter pack. */ - if (ppd->type_pack_expansion_p && is_auto_or_concept (t)) + if (ppd->type_pack_expansion_p && is_auto (t)) TEMPLATE_TYPE_PARAMETER_PACK (t) = true; if (TEMPLATE_TYPE_PARAMETER_PACK (t)) parameter_pack_p = true; @@ -24806,7 +24806,7 @@ static int extract_autos_r (tree t, void *data) { hash_table &hash = *(hash_table*)data; - if (is_auto_or_concept (t)) + if (is_auto (t)) { /* All the autos were built with index 0; fix that up now. */ tree *p = hash.find_slot (t, INSERT); @@ -25530,7 +25530,7 @@ is_auto (const_tree type) int is_auto_r (tree tp, void */*data*/) { - return is_auto_or_concept (tp); + return is_auto (tp); } /* Returns the TEMPLATE_TYPE_PARM in TYPE representing `auto' iff TYPE contains @@ -25556,26 +25556,6 @@ type_uses_auto (tree type) return find_type_usage (type, is_auto); } -/* Returns true iff TYPE is a TEMPLATE_TYPE_PARM representing 'auto', - 'decltype(auto)' or a concept. */ - -bool -is_auto_or_concept (const_tree type) -{ - return is_auto (type); // or concept -} - -/* Returns the TEMPLATE_TYPE_PARM in TYPE representing a generic type (`auto' or - a concept identifier) iff TYPE contains a use of a generic type. Returns - NULL_TREE otherwise. */ - -tree -type_uses_auto_or_concept (tree type) -{ - return find_type_usage (type, is_auto_or_concept); -} - - /* For a given template T, return the vector of typedefs referenced in T for which access check is needed at T instantiation time. T is either a FUNCTION_DECL or a RECORD_TYPE.