From patchwork Thu May 18 18:20:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 764123 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 3wTKHL6cFFz9s7F for ; Fri, 19 May 2017 04:20:30 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="scI2O9Bn"; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=scw7rdNp2532CX2jH1K1Tf7+gwWXknis/ITIMwt6wXshdPCtvW dJsS0YNZun231VDO0Qp3Sj4Z615m7xq1DRoYx12tarFAZ//Qpo5AxR6/l20d04UH 02IrENOQnbAS4xQpT5YLdmbI0CHUHCqRnbjZN+rGYVmuDpyUDNqsKlPIA= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=G/tHm6X3WCseNoK5vHXL5c8vuS4=; b=scI2O9Bn71jch3TbmQi7 cc7efNQgdr7dylUpAc0pN5SXlPYgTOrT6PQdOFuI6yhuMfezl8IE8ORkG355r6Ut B/Fx54AlaoZbPzPzA3Y8po9zJ70mHUZFNAgTjURfG2P6QCeytfv97yzwe+Xy3ye3 xOFFAmZrbCM8qhb4JUumneY= Received: (qmail 73023 invoked by alias); 18 May 2017 18:20:19 -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 72992 invoked by uid 89); 18 May 2017 18:20:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw0-f181.google.com Received: from mail-yw0-f181.google.com (HELO mail-yw0-f181.google.com) (209.85.161.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 May 2017 18:20:15 +0000 Received: by mail-yw0-f181.google.com with SMTP id b68so24875846ywe.3 for ; Thu, 18 May 2017 11:20:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=vvE+IdaNvFOgWm/PQ/Ej2lyEdZ8zGoaV2IUejoWJ/8Q=; b=k/tPKXI5eUKrROWzBF1+BDjbR3k2bPg9oWoYCEAQNWqzneYTdR54ZDy38r33c9eGXR OIzhAE9CbaGHEEeOKU2tjc+Uc5va2q20bnbhR5Dvyg7XpfDpZPtRBjq82NAkW8PtaIEo m7+thuNR1ZEvj3CF6rw3mZiqLRASk50tDXHaC4s+khhCqY4+7FPWALGfdPISD36LYEzN gxIUJfpshz7F+LQW4jDtUGNGBlXcZrMf36inf12YNl6RsJbpYaFia2XA6fQwzGji+RfM LgD6AGmtheIuaJ/AyWqhnHoeWtuE5l3cqCAcY3uesEgRP0YJYClxujDp/aOyrVi6vU2s gUjg== X-Gm-Message-State: AODbwcBqVn1qXUJl7Sb/kzBWoweGHdbVARsoM6FyXYD9olsTe9NSeSl9 4k/AzHbREusWYQ== X-Received: by 10.13.232.16 with SMTP id r16mr5032086ywe.145.1495131617032; Thu, 18 May 2017 11:20:17 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:f6d0:5ac5:64cd:f102? ([2620:10d:c091:200::7:4a1a]) by smtp.googlemail.com with ESMTPSA id w192sm2964930yww.56.2017.05.18.11.20.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 11:20:16 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] OVERLOAD iterators #7 Message-ID: <25509e86-4e01-82ff-89e6-3f7a0933e7ea@acm.org> Date: Thu, 18 May 2017 14:20:14 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 This patch adds OVL_USED_P, using TREE_USED, which marks when an overload is being used by a template body -- and hence is immutable. This replaces and extends the current OVL_ARG_DEPENDENT_P flag, which was just set for koenig lookups. We'll be generating other transient lookups, which can benefit from such marking. nathan 2017-05-18 Nathan Sidwell * cp-tree.h (OVL_ARG_DEPENDENT): Delete. (OVL_USED_P): New. (lookup_keep): Declare. * name-lookup.c (add_function): Don't set OVL_ARG_DEPENDENT. * pt.c (tsubst_copy): Assert lookup is persistent. * semantics.c (finish_call_expr): Use lkp_iterator, call lookup_keep. * tree.c (ovl_copy): New. (ovl_insert, ovl_iterator::remove_node): Copy immutable nodes. (lookup_keep): New. Index: cp-tree.h =================================================================== --- cp-tree.h (revision 248229) +++ cp-tree.h (working copy) @@ -323,7 +323,6 @@ extern GTY(()) tree cp_global_trees[CPTI IMPLICIT_CONV_EXPR_DIRECT_INIT (in IMPLICIT_CONV_EXPR) TRANSACTION_EXPR_IS_STMT (in TRANSACTION_EXPR) CONVERT_EXPR_VBASE_PATH (in CONVERT_EXPR) - OVL_ARG_DEPENDENT (in OVERLOAD) PACK_EXPANSION_LOCAL_P (in *_PACK_EXPANSION) TINFO_HAS_ACCESS_ERRORS (in TEMPLATE_INFO) SIZEOF_EXPR_TYPE_P (in SIZEOF_EXPR) @@ -641,9 +640,6 @@ typedef struct ptrmem_cst * ptrmem_cst_t ((TREE_CODE (NODE) == OVERLOAD) ? OVL_FUNCTION (NODE) : (NODE)) #define OVL_NEXT(NODE) \ ((TREE_CODE (NODE) == OVERLOAD) ? TREE_CHAIN (NODE) : NULL_TREE) -/* If set, this OVERLOAD was created for argument-dependent lookup - and can be freed afterward. */ -#define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE)) /* If set, this was imported in a using declaration. */ #define OVL_USING_P(NODE) TREE_LANG_FLAG_1 (OVERLOAD_CHECK (NODE)) @@ -651,6 +647,8 @@ typedef struct ptrmem_cst * ptrmem_cst_t #define OVL_NESTED_P(NODE) TREE_LANG_FLAG_3 (OVERLOAD_CHECK (NODE)) /* If set, this overload was constructed during lookup. */ #define OVL_LOOKUP_P(NODE) TREE_LANG_FLAG_4 (OVERLOAD_CHECK (NODE)) +/* If set, this is a persistant lookup. */ +#define OVL_USED_P(NODE) TREE_USED (OVERLOAD_CHECK (NODE)) /* The first decl of an overload. */ #define OVL_FIRST(NODE) ovl_first (NODE) @@ -6809,6 +6807,7 @@ extern tree ovl_make (tree fn, extern tree ovl_insert (tree fn, tree maybe_ovl, bool using_p = false); extern tree lookup_add (tree fns, tree lookup); +extern void lookup_keep (tree lookup, bool keep); extern int is_overloaded_fn (tree); extern tree dependent_name (tree); extern tree get_fns (tree) ATTRIBUTE_PURE; Index: name-lookup.c =================================================================== --- name-lookup.c (revision 248229) +++ name-lookup.c (working copy) @@ -159,11 +159,7 @@ add_function (struct arg_lookup *k, tree else if (fn == k->functions) ; else - { - k->functions = lookup_add (fn, k->functions); - if (TREE_CODE (k->functions) == OVERLOAD) - OVL_ARG_DEPENDENT (k->functions) = true; - } + k->functions = lookup_add (fn, k->functions); return false; } Index: pt.c =================================================================== --- pt.c (revision 248198) +++ pt.c (working copy) @@ -14565,6 +14565,8 @@ tsubst_copy (tree t, tree args, tsubst_f overload set from function scope will just be represented with an IDENTIFIER_NODE, and from class scope with a BASELINK. */ gcc_assert (!uses_template_parms (t)); + /* We must have marked any lookups as persistent. */ + gcc_assert (!OVL_LOOKUP_P (t) || OVL_USED_P (t)); return t; case BASELINK: Index: semantics.c =================================================================== --- semantics.c (revision 248166) +++ semantics.c (working copy) @@ -2304,18 +2304,28 @@ finish_call_expr (tree fn, vecf", "c.f", "C::f", and "f" will all be considered possibly