Message ID | Y/XbFF0VQV9htP5E@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp465791wrd; Wed, 22 Feb 2023 01:07:36 -0800 (PST) X-Google-Smtp-Source: AK7set+vXdYQLBhhSDu3A9BC2TSfTOTA7WzIfEQevAFlpGtufN7a+2h+B6FznWcs/nPJskPdpJnJ X-Received: by 2002:a17:907:1c0e:b0:8b1:3159:2eb3 with SMTP id nc14-20020a1709071c0e00b008b131592eb3mr23637728ejc.43.1677056856282; Wed, 22 Feb 2023 01:07:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677056856; cv=none; d=google.com; s=arc-20160816; b=MQ7U1dpu9Ue25MS3xW2g7bqtHdHUz7y5qSYCHK8+syF2fnGMSB0qSTWZfFTlG3WrlK 3ZAZE3Cf9DeiS7w3OEPX0pO6SJWJ31IkTpAa6oB+0M4wp8l6ipXldYw4e+Tw84jHkT9O 4gw/CUZtPc9MYmQbxVcAq4ONYgut7tdXt9WirqRiDsADArNH3pyrn86+CbB797nBMoT2 dU06HyyfmW+GS2qwqtOkjtjm7ZCOzblK3ieiwqCTFUkTymrnY8VMSGoVhnUCd2NGWM0F Silydu96jwg4MUtx3mBkNwzksOaq5HYf38i3pkl4hyx+BBWe1eKPh9fXSo2n4X/puuxE IJvQ== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=brI0xagwqRZbZe3c+oYHJ7/JyLNzegNo0G3QtRSQkmU=; b=pcg0eWs163EzWPfZ2pztmbAUSV6Ew0b7bMsB2iU3CSK+ML3F4Xo/1h4FTvT0umI7c6 MGg/M8MTmn3a4/G2v9qFqY2b1T2AsorT5yO9pi1NO6iykKTBBkgfYhHhRCIaHbh0FfE2 nhO/jPJeE4gUHa6bwzJuHoiH+c9sdCsjpMYR+CTfEyaZ/8PvFRvZj6SDzakEIFPBv8xY qE41r7b4nW3tW7DPH+guFj8cpYhzxK+1dp4Wwb/sWGjNv1UNuo7d4b9HJ9FY4SW7zYSq Zt13uaeiDApfXTn0vryhayR14+axA2NxEnMFIPIeRu171BEkIO372H84EnvHOtomCBIz LMfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=aAFVvc4y; 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 vj16-20020a170907131000b008b19eb4252csi16874359ejb.511.2023.02.22.01.07.36 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 01:07:36 -0800 (PST) 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=aAFVvc4y; 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 5A5B13858284 for <ouuuleilei@gmail.com>; Wed, 22 Feb 2023 09:07:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A5B13858284 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677056855; bh=brI0xagwqRZbZe3c+oYHJ7/JyLNzegNo0G3QtRSQkmU=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=aAFVvc4ymVvgXyp51oW0R0x3ruh6AJLl8I1U9iGr1dV+HB/JLESAjxA1Vwz1BaeGK KWzYAst6MfF3tV2wN2+qF1HQmG+mmhqkQiXPTA252z0SlZgV/2YP+aae+6apTO8H3a 4nxJN7cItpm0KAE1A2r0LnZLhwD7AxR0y6pIdbJc= 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 812C43858D33 for <gcc-patches@gcc.gnu.org>; Wed, 22 Feb 2023 09:06:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 812C43858D33 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-403-BmaNIhJVOw69dvvC1hj2Jw-1; Wed, 22 Feb 2023 04:06:32 -0500 X-MC-Unique: BmaNIhJVOw69dvvC1hj2Jw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE4C638041DB for <gcc-patches@gcc.gnu.org>; Wed, 22 Feb 2023 09:06:31 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B27A41415113; Wed, 22 Feb 2023 09:06:31 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 31M96TKN4178251 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 22 Feb 2023 10:06:29 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31M96TrA4178250; Wed, 22 Feb 2023 10:06:29 +0100 Date: Wed, 22 Feb 2023 10:06:28 +0100 To: Jason Merrill <jason@redhat.com> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Don't recurse on DECL_INITIAL for DECL_EXPR on non-VAR_DECLs [PR108606] Message-ID: <Y/XbFF0VQV9htP5E@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758521570085716339?= X-GMAIL-MSGID: =?utf-8?q?1758521570085716339?= |
Series |
c++: Don't recurse on DECL_INITIAL for DECL_EXPR on non-VAR_DECLs [PR108606]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
Feb. 22, 2023, 9:06 a.m. UTC
Hi! The r13-2965-g73d9b0e5947e16 change changed the line touched in this patch from return RECUR (tmp, want_rval); to return RECUR (DECL_INITIAL (tmp), want_rval); This is on DECL_EXPR handling code, where tmp can be lots of different trees and DECL_INITIAL unfortunately also means different things on different trees. It is the initializer on VAR_DECL, DECL_ARG_TYPE on PARM_DECLs (though those are unlikely to have DECL_EXPRs), for FUNCTION_DECLs the body, ..., USING_DECL_DECLS on USING_DECLs and DECL_FRIENDLIST on TYPE_DECLs. The testcase below ICEs because we have a DECL_EXPR for TYPE_DECL which has non-NULL DECL_FRIENDLIST and we certainly can't recurse on the friend list. The following patch is a conditional partial reversion of r13-2965, it will recurse on DECL_INITIAL only for VAR_DECLs and for anything else keep previous behavior. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-02-22 Jakub Jelinek <jakub@redhat.com> PR c++/108606 * constexpr.cc (potential_constant_expression_1) <case DECL_EXPR>: Only recurse on DECL_INITIAL (tmp) if tmp is a VAR_DECL, otherwise recurse on tmp. * g++.dg/cpp1y/pr108606.C: New test. Jakub
Comments
On 2/22/23 04:06, Jakub Jelinek wrote: > Hi! > > The r13-2965-g73d9b0e5947e16 change changed the line touched in this patch > from > return RECUR (tmp, want_rval); > to > return RECUR (DECL_INITIAL (tmp), want_rval); > This is on DECL_EXPR handling code, where tmp can be lots of different > trees and DECL_INITIAL unfortunately also means different things on > different trees. > It is the initializer on VAR_DECL, DECL_ARG_TYPE on PARM_DECLs (though > those are unlikely to have DECL_EXPRs), for FUNCTION_DECLs the body, > ..., USING_DECL_DECLS on USING_DECLs and DECL_FRIENDLIST on TYPE_DECLs. > > The testcase below ICEs because we have a DECL_EXPR for TYPE_DECL > which has non-NULL DECL_FRIENDLIST and we certainly can't recurse on > the friend list. > > The following patch is a conditional partial reversion of r13-2965, > it will recurse on DECL_INITIAL only for VAR_DECLs and for anything > else keep previous behavior. Hmm, we can probably just return true for non-VAR_DECLs. OK either way. > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2023-02-22 Jakub Jelinek <jakub@redhat.com> > > PR c++/108606 > * constexpr.cc (potential_constant_expression_1) <case DECL_EXPR>: > Only recurse on DECL_INITIAL (tmp) if tmp is a VAR_DECL, otherwise > recurse on tmp. > > * g++.dg/cpp1y/pr108606.C: New test. > > --- gcc/cp/constexpr.cc.jj 2023-02-20 22:06:36.000000000 +0100 > +++ gcc/cp/constexpr.cc 2023-02-21 14:40:39.366910531 +0100 > @@ -9699,7 +9699,9 @@ potential_constant_expression_1 (tree t, > (tmp, /*constexpr_context_p=*/true, flags)) > return false; > } > - return RECUR (DECL_INITIAL (tmp), want_rval); > + if (VAR_P (tmp)) > + return RECUR (DECL_INITIAL (tmp), want_rval); > + return RECUR (tmp, want_rval); > > case TRY_FINALLY_EXPR: > return (RECUR (TREE_OPERAND (t, 0), want_rval) > --- gcc/testsuite/g++.dg/cpp1y/pr108606.C.jj 2023-02-21 14:44:41.292380973 +0100 > +++ gcc/testsuite/g++.dg/cpp1y/pr108606.C 2023-02-21 14:44:15.622755459 +0100 > @@ -0,0 +1,11 @@ > +// PR c++/108606 > +// { dg-do compile { target c++14 } } > + > +template <typename T> > +void bar (T) {} > + > +void > +foo () > +{ > + bar ([&] (auto x) { class C { friend void baz (); }; }); > +} > > Jakub >
--- gcc/cp/constexpr.cc.jj 2023-02-20 22:06:36.000000000 +0100 +++ gcc/cp/constexpr.cc 2023-02-21 14:40:39.366910531 +0100 @@ -9699,7 +9699,9 @@ potential_constant_expression_1 (tree t, (tmp, /*constexpr_context_p=*/true, flags)) return false; } - return RECUR (DECL_INITIAL (tmp), want_rval); + if (VAR_P (tmp)) + return RECUR (DECL_INITIAL (tmp), want_rval); + return RECUR (tmp, want_rval); case TRY_FINALLY_EXPR: return (RECUR (TREE_OPERAND (t, 0), want_rval) --- gcc/testsuite/g++.dg/cpp1y/pr108606.C.jj 2023-02-21 14:44:41.292380973 +0100 +++ gcc/testsuite/g++.dg/cpp1y/pr108606.C 2023-02-21 14:44:15.622755459 +0100 @@ -0,0 +1,11 @@ +// PR c++/108606 +// { dg-do compile { target c++14 } } + +template <typename T> +void bar (T) {} + +void +foo () +{ + bar ([&] (auto x) { class C { friend void baz (); }; }); +}