From patchwork Wed Jun 16 21:28:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1493096 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=TmnklfSk; 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 4G4yxK5F25z9sW4 for ; Thu, 17 Jun 2021 07:29:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6790F3857815 for ; Wed, 16 Jun 2021 21:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6790F3857815 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623878945; bh=a3mwgy9nHrHUHaS1l0oAWLC3y+YeAInbyzJef4IQQUQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=TmnklfSkBe91uRK39sBUKLpDhs883RhLOBuRJNhADDMPpQiCpvoK+ZsbQcBBWBovZ NSaTK/gZ2BVWWZ2sv99oPExHL/eIBlxSFPyTdMZLKv4VdiBoRYjCpR+nbYIvth0lw9 WpOjmoCt2DI8f6plbikC9XeetzS2ztRl5jcfS6Dk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id C7DE5385802E for ; Wed, 16 Jun 2021 21:28:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7DE5385802E Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-7C4CkFH7OdydOi3wnxaNUw-1; Wed, 16 Jun 2021 17:28:20 -0400 X-MC-Unique: 7C4CkFH7OdydOi3wnxaNUw-1 Received: by mail-qk1-f199.google.com with SMTP id b125-20020a3799830000b02903ad1e638ccaso605042qke.4 for ; Wed, 16 Jun 2021 14:28:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=a3mwgy9nHrHUHaS1l0oAWLC3y+YeAInbyzJef4IQQUQ=; b=L6QVnlXHrToe9jW7AGvwbbVmQOoXEPBLIDLDcxaEx0ZQQ3Kyhkvgesh3rQNShGj4qv qfWj+Z67zxwYcpemYHPeH9TZCkqxt0vry2taFoKtlamuUNXGRrotOkUCpfUH517C3i8/ 04ebqv92m499nH+vBrzfkr723PDWp6klluXJY59dXbcBX52rUG707DcD3Xeebfa3Jzh4 V4pc0ZXscAHVfkEIzdS8RDvBfim9Lwf1WbxuD2ueE4WEu2jtzrzxBKHTAmAEtYSBM4o6 snv0NIofZ5PP8hxb2dZsv0vPO3YDMhXwNjdkT7lJbnhsRUFYsAr0peN+iAZ016qqyukL n20Q== X-Gm-Message-State: AOAM531ZqO8OS9fftfIxG2YEVOWx6CM0rXirv61e53EqcqU13xtPox+v F82YQfvGARbyPZmLu4m1N2yulx1UwzlhIVo/QT6HRerNwv0e45EUFA0YsQXL4yJ3khqmk2mHNdF M/uP1iV1PQ/FdnRU9nJOF8TpCcLcoMcWh7+w+QmEEb3QbnBPn8IWAlgTENjAGktbHvA== X-Received: by 2002:a37:b3c5:: with SMTP id c188mr429337qkf.242.1623878899554; Wed, 16 Jun 2021 14:28:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNGfzAbPb6bKi4vEwYBO6WsNaTCzFV/iBSHXilwPSSaD4nr8hVYyxNsCbirHDf4D6b1FCbRQ== X-Received: by 2002:a37:b3c5:: with SMTP id c188mr429315qkf.242.1623878899187; Wed, 16 Jun 2021 14:28:19 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s11817.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id s133sm341760qke.97.2021.06.16.14.28.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:28:18 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: static memfn from non-dependent base [PR101078] Date: Wed, 16 Jun 2021 17:28:16 -0400 Message-Id: <20210616212816.2226798-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" After my patch for PR91706, or before that with the qualified call, tsubst_baselink returned a BASELINK with BASELINK_BINFO indicating a base of a still-dependent derived class. We need to look up the relevant base binfo in the substituted class. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/101078 PR c++/91706 gcc/cp/ChangeLog: * pt.c (tsubst_baselink): Update binfos in non-dependent case. gcc/testsuite/ChangeLog: * g++.dg/template/access39.C: New test. --- gcc/cp/pt.c | 15 +++++++++++++-- gcc/testsuite/g++.dg/template/access39.C | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/access39.C base-commit: 9e64426dae129cca5b62355ef6c5a3bd6137e830 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d4bb5cc5eaf..15947b2c812 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16249,8 +16249,19 @@ tsubst_baselink (tree baselink, tree object_type, fns = BASELINK_FUNCTIONS (baselink); } else - /* We're going to overwrite pieces below, make a duplicate. */ - baselink = copy_node (baselink); + { + /* We're going to overwrite pieces below, make a duplicate. */ + baselink = copy_node (baselink); + + if (qualifying_scope != BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink))) + { + /* The decl we found was from non-dependent scope, but we still need + to update the binfos for the instantiated qualifying_scope. */ + BASELINK_ACCESS_BINFO (baselink) = TYPE_BINFO (qualifying_scope); + BASELINK_BINFO (baselink) = lookup_base (qualifying_scope, binfo_type, + ba_unique, nullptr, complain); + } + } /* If lookup found a single function, mark it as used at this point. (If lookup found multiple functions the one selected later by diff --git a/gcc/testsuite/g++.dg/template/access39.C b/gcc/testsuite/g++.dg/template/access39.C new file mode 100644 index 00000000000..d941555577e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/access39.C @@ -0,0 +1,17 @@ +// PR c++/101078 + +struct A { + static void f(); +}; + +template +struct B : private A { + struct C { + void g() { f(); } + void g2() { B::f(); } + }; +}; + +int main() { + B::C().g(); +}