From patchwork Thu Mar 16 22:11:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 70984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp21826wrt; Thu, 16 Mar 2023 15:12:14 -0700 (PDT) X-Google-Smtp-Source: AK7set/X85iOKVPxS4ZlZtBKPi82Iln8hhpyD1QLGcTIOx9F9ahgaqxa1Wdzkg1WCSdUzjYW3flD X-Received: by 2002:a05:6402:d7:b0:4fc:5d56:f91d with SMTP id i23-20020a05640200d700b004fc5d56f91dmr936452edu.18.1679004734769; Thu, 16 Mar 2023 15:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679004734; cv=none; d=google.com; s=arc-20160816; b=0HdInn0R/LMmyt5+720PG5U9/EKgzI1OBuMpKTildNHR3oIj4QgvjbPuwZM20BtnZM /7QEKKcxR05PAFGwRcs9X8PeN7OwRoYBuBJmkJhrjNqrB6jNMrd4QDJXXHNIDxgKIwFp l/ILA1ikDN5CK/lL1ck0B100mMw54cAJ9zQf0e/KAP4pRbWS3e1bT41Xo9bRnRn+kvbL 5TwEaqkzGZXruf/cQTGVWwnzCDxxnH/Z0rvzFrFadaXXIlE5O6ibUSFIzw2koK0ub7DE FzcasLH/1ctalPZ+d+4XHLC+Dess1h89K1XOBFd4gFAoWrGSJ6TesgcqTilC/w9rF4G0 skKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=k4uJInslcfa87z6Vvscq63HWKcfv/Ri8+jmxQEce6lg=; b=NE+8dkHnuMYRJoSwP5S2yw13k9QzQJIE8vaY6V0KFERlnIwSIzClNwnXD5m6eVm3BZ OBk8511Xi5UDQ/7sezQ3tSPiGZ4/SN/P3h9anXviRXazhux7QpZr1+I7z1VNntU5/izw +y1bZyi5lDaU1xbcalCkqZy8FEoKkF1rcJMnHe776G53Ppf4jXF7CBt4hx37zUeqT1rQ jfesatN014TGlwNfyQcEAQI9+QJmtuOBKC8x5uftH82X8ggU1rexBBIk0iYXqLrtGmL6 KvK5QOfGpcaoCoKEsS/4t7Nqkj0tQIF+cHxhFlRMx/6iuULCqgp9Qcc+vAWQ64pbA99F 2mJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kXYel8oh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id k13-20020aa7d8cd000000b004acb24be0d2si707440eds.315.2023.03.16.15.12.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 15:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kXYel8oh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 993613851145 for ; Thu, 16 Mar 2023 22:11:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 993613851145 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679004718; bh=k4uJInslcfa87z6Vvscq63HWKcfv/Ri8+jmxQEce6lg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kXYel8oh3vUZj4RQDqwlRD54/E1pLb0BfOy1KGjb01l4+b0Lza5EUg9IJvy7hJbm5 1rPzxaACPlIF6hBx2jJas3I5TYWNGaV//KEBfil7Fl/kLHN+atrrKyTjjDH3l/zg3N z4bSPNTW+sAz85GeGeHwNjW7CeOHC24snCFQllmI= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id F2ECF385783F for ; Thu, 16 Mar 2023 22:11:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2ECF385783F Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-oEtS9R5-MbqD198VpujSLw-1; Thu, 16 Mar 2023 18:11:12 -0400 X-MC-Unique: oEtS9R5-MbqD198VpujSLw-1 Received: by mail-qv1-f71.google.com with SMTP id ke14-20020a056214300e00b005abcdd36f47so1818150qvb.21 for ; Thu, 16 Mar 2023 15:11:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679004672; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k4uJInslcfa87z6Vvscq63HWKcfv/Ri8+jmxQEce6lg=; b=ysnmG5Z0y1SgPBrzo8o2ZL59YLBpglWBSbxAk+pARbldCxOPQxg1GDkl0XzGxg5h+V 79c+w/4jhwcilrraX65HQCX1qxT3NaFH+o3eC4jzlsFhthvLqS1naE1CDHIFtiAaB+19 8MYyPka2dkk7uCThw5TlHp1qUnaMZt2hg49ZD69qlvjcZoeaSZA4eg1itMafGAwZBOgh KqCMWhPhWFDdig1EurJh0weI7fGtsEGEeZrNlae0Ivdk8XMqKrZO9glTYmxycxYzRK4d yp1K3r6NY2m2VBF+n3fTMneun8aa6Zb18mJWfw6/tfmVQsfFZwtmsLflLebd9Aq2fsSA BILw== X-Gm-Message-State: AO0yUKU5kHo5HVLoo2h+st+PWgWMSL+iJeTKXPa+1tpgeBNoD3p+tOQC FY7yqdZQBDymo8xkSIR21nHXoxW2VPdA7le0GN7G0dpI8nw/yw1EaGxoT8UMLkjrJE+10ebD/hg UhtLHWAqIinGedoJk9+6F4DmXZyg3bYuEo6265KDDpdjczOE4JemMWQK1dsJCKYYL2gEas4sv+A == X-Received: by 2002:ad4:4ee2:0:b0:570:bf43:480 with SMTP id dv2-20020ad44ee2000000b00570bf430480mr39874385qvb.4.1679004671750; Thu, 16 Mar 2023 15:11:11 -0700 (PDT) X-Received: by 2002:ad4:4ee2:0:b0:570:bf43:480 with SMTP id dv2-20020ad44ee2000000b00570bf430480mr39874332qvb.4.1679004671314; Thu, 16 Mar 2023 15:11:11 -0700 (PDT) Received: from jason.cygnus.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id bl28-20020a05620a1a9c00b007339c5114a9sm373952qkb.103.2023.03.16.15.11.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 15:11:10 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: generic lambda, local class, __func__ [PR108242] Date: Thu, 16 Mar 2023 18:11:08 -0400 Message-Id: <20230316221108.1138412-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760564068836343868?= X-GMAIL-MSGID: =?utf-8?q?1760564068836343868?= Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Here we are trying to do name lookup in a deferred instantiation of t() and failing to find __func__. tsubst_expr already tries to instantiate members of local classes, but was failing with the partial instantiation of generic lambdas. PR c++/108242 gcc/cp/ChangeLog: * pt.cc (tsubst_expr) [TAG_DEFN]: Handle partial instantiation. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/lambda-generic-func2.C: New test. --- gcc/cp/pt.cc | 5 ++++- .../g++.dg/cpp1y/lambda-generic-func2.C | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-func2.C base-commit: 1cc8814098bb46f9fca58a0b831fbf9a8574bdc9 diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ddbd73371b9..1072882e1a8 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -19341,7 +19341,10 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) case TAG_DEFN: tmp = tsubst (TREE_TYPE (t), args, complain, NULL_TREE); - if (CLASS_TYPE_P (tmp)) + if (dependent_type_p (tmp)) + /* This is a partial instantiation, try again when full. */ + add_stmt (build_min (TAG_DEFN, tmp)); + else if (CLASS_TYPE_P (tmp)) { /* Local classes are not independent templates; they are instantiated along with their containing function. And this diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func2.C new file mode 100644 index 00000000000..ed541c7812f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func2.C @@ -0,0 +1,18 @@ +// PR c++/108242 +// { dg-do compile { target c++14 } } + +template +void my_fun() +{ + [&](auto) { + static constexpr char const* fun_name = __func__; + struct t + { + t() { fun_name; }; + } t1; + }(12); +} + +int main() { + my_fun<1>(); +}