From patchwork Thu Dec 3 20:40:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1410631 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=D7GSGrHw; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cn74p5Vljz9sSs for ; Fri, 4 Dec 2020 07:40:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AEB513971C33; Thu, 3 Dec 2020 20:40:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by sourceware.org (Postfix) with ESMTPS id 8E437384A881 for ; Thu, 3 Dec 2020 20:40:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8E437384A881 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x72c.google.com with SMTP id u4so3444647qkk.10 for ; Thu, 03 Dec 2020 12:40:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=yu8DfhKmDG57ol1qI+FXbPtfRPeIMKE92TrnI7rWxVM=; b=D7GSGrHwQPEjPAbIRzZeOKp9ETXv5YK56LYoQzfkaKfdHTiBAZ15yDvMswJd7jENac xje5+vKLTJOIMeknz5wGz5XIak8kz0xrpSYDGY5tjsqc8hPW3XS8cCKgpR9G1F9fhBGk FplFdlVv5iXFcxfu1sR4/FpAbO47hFncDfk0x7Xbwbs/T0b/6/mFZs4cBi4joAg2hPbm 4aigq5bEMfc5NKwe8Em/ei02pgbcf8eipD9+pGSlJGvTobMte1zeuw2rkanomMFxR2Oh 7qMeE5oKDSRoOF23ZaC4PUpq2/twB2z9zdNt2zzrxLcKD84qU78YS+BnKYpkhQo7Wki3 ucUA== 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=yu8DfhKmDG57ol1qI+FXbPtfRPeIMKE92TrnI7rWxVM=; b=mqw/cZfQ48HtJkJTpJer4PsGzMSng22vAjESiodZ6tNLXEhvn6UeF1oj6VhPtiCQnj 5DuSRYkcHcuzfzC9i6jUdiD+JhRK/5UQYXiKuvnm2camICic63h6TG0QmAxYHXK9ARzZ +wEeD53B2YySEp/yrGKj5BbYJv6DQZnHFUCx4CEbOBoIupWSPXtEHu8Chbcf2JEj6yCB qeqYTLw5nCkxQuGapCG1rabgT0h3FIaMYATCBLnY6SQ4WPTCCLr2p7ni3vguV8aefGJc 84HmUxcosxHQDaVgVkOOGpiYArlZpEqcFkMfbExpz/7PeaGclzuQ1dcA4PqnD9IwmiuV pCpQ== X-Gm-Message-State: AOAM533VnePp2w3E54CtUWVE0GhXSCie2d6lv9u2fxBwBWrOlFB3iJmC yVbvu3UBfVFyjrN1rQmwkPQ= X-Google-Smtp-Source: ABdhPJwxHZjBYFCN1XXv/TvzF1PTNhTujm9IlzAfuDIr+iKyKJ1OVBasjqJ130Xrd/Ice3S8xnhABA== X-Received: by 2002:a05:620a:16cd:: with SMTP id a13mr4742734qkn.11.1607028003709; Thu, 03 Dec 2020 12:40:03 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:ded:7157:da24:d154? ([2620:10d:c091:480::1:e9f0]) by smtp.googlemail.com with ESMTPSA id o19sm2489250qkk.10.2020.12.03.12.40.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2020 12:40:02 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: c++: Exported using decls Message-ID: <10cc5064-1cdd-a79c-6a79-cd50e1e238c2@acm.org> Date: Thu, 3 Dec 2020 15:40:01 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" With modules we need to record whethe a (namespace-scope) using decl is exporting the named entities. Record this on the OVERLOAD marking the used decl. gcc/cp/ * cp-tree.h (OVL_EXPORT): New. (class ovl_iterator): Add get_using, exporting_p. * tree.c (ovl_insert): Extend using_or_hidden meaning to include an exported using. pushed to trunk diff --git i/gcc/cp/cp-tree.h w/gcc/cp/cp-tree.h index 4db50128443..4720af2175a 100644 --- i/gcc/cp/cp-tree.h +++ w/gcc/cp/cp-tree.h @@ -503,6 +503,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; FUNCTION_RVALUE_QUALIFIED (in FUNCTION_TYPE, METHOD_TYPE) CALL_EXPR_REVERSE_ARGS (in CALL_EXPR, AGGR_INIT_EXPR) CONSTRUCTOR_PLACEHOLDER_BOUNDARY (in CONSTRUCTOR) + OVL_EXPORT_P (in OVERLOAD) 6: TYPE_MARKED_P (in _TYPE) DECL_NONTRIVIALLY_INITIALIZED_P (in VAR_DECL) RANGE_FOR_IVDEP (in RANGE_FOR_STMT) @@ -780,6 +781,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 OVL_USING_P overload is exported. */ +#define OVL_EXPORT_P(NODE) TREE_LANG_FLAG_5 (OVERLOAD_CHECK (NODE)) /* The first decl of an overload. */ #define OVL_FIRST(NODE) ovl_first (NODE) @@ -839,6 +842,11 @@ class ovl_iterator { return fn; } + tree get_using () const + { + gcc_checking_assert (using_p ()); + return ovl; + } public: /* Whether this overload was introduced by a using decl. */ @@ -847,6 +855,12 @@ class ovl_iterator { return (TREE_CODE (ovl) == USING_DECL || (TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl))); } + /* Whether this using is being exported. */ + bool exporting_p () const + { + return OVL_EXPORT_P (get_using ()); + } + bool hidden_p () const { return TREE_CODE (ovl) == OVERLOAD && OVL_HIDDEN_P (ovl); diff --git i/gcc/cp/tree.c w/gcc/cp/tree.c index 8d7df60f963..d9fa505041f 100644 --- i/gcc/cp/tree.c +++ w/gcc/cp/tree.c @@ -2272,10 +2272,11 @@ ovl_make (tree fn, tree next) return result; } -/* Add FN to the (potentially NULL) overload set OVL. USING_OR_HIDDEN - is > 0, if FN is via a using declaration. USING_OR_HIDDEN is < 0, - if FN is hidden. (A decl cannot be both using and hidden.) We - keep the hidden decls first, but remaining ones are unordered. */ +/* Add FN to the (potentially NULL) overload set OVL. USING_OR_HIDDEN is > + zero if this is a using-decl. It is > 1 if we're exporting the + using decl. USING_OR_HIDDEN is < 0, if FN is hidden. (A decl + cannot be both using and hidden.) We keep the hidden decls first, + but remaining ones are unordered. */ tree ovl_insert (tree fn, tree maybe_ovl, int using_or_hidden) @@ -2299,7 +2300,11 @@ ovl_insert (tree fn, tree maybe_ovl, int using_or_hidden) if (using_or_hidden < 0) OVL_HIDDEN_P (maybe_ovl) = true; if (using_or_hidden > 0) - OVL_DEDUP_P (maybe_ovl) = OVL_USING_P (maybe_ovl) = true; + { + OVL_DEDUP_P (maybe_ovl) = OVL_USING_P (maybe_ovl) = true; + if (using_or_hidden > 1) + OVL_EXPORT_P (maybe_ovl) = true; + } } else maybe_ovl = fn;