From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id EF3893858021 for ; Tue, 12 Mar 2024 14:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF3893858021 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF3893858021 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710253529; cv=none; b=ZtqP2uAs+m7a16RHps4zHu1IbAH5uXQpGxmIN0SdIddU4Y6roLH3pKHhnuZNnvt4Qt7VcZw4fZCY1AKGD3/R59LsrJDy3oKzt3jAaTPnSB/3wxBI8abnYOML1wr9IGjNM7GpR8D3BV5iXvFW5ej6ccndBTW4AVzBdUmmv+A7z+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710253529; c=relaxed/simple; bh=MB6gFsfy6s9iexN6kYnM+CoLX8SkT2SbYLNn2rpFtBM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=XaDkHjHfGS6+gVcMDGIzrI8NK7h+FO3syy7U2BUrJlbY6Bwxbp/bGfjTSFzGmOJvDanmB0NR74VB9ktGS9bX17D7toSr8IcMHPjXeb3WTgR2j5dfLuQBj8L9XEdrJxqI1JvONlk/4TOL8UFjdZdNIvv1B3dGeU071Z8+/bC3XlY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710253526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hHJVOvVaBwYgQkbiWGrOfQhRrQzutoTvAGe8tcj6Ie4=; b=bNVcdFpdacbeJ1nmhyAUaI807ZtgC+wBkKB6MUxdYta6KdFxJ33TqcZ0rxy4YPx1ZpgDGY Gx3fkSzPA7SPjWrUf1eI7lTo5BpMWCpobSwsGlvom7LHi7hMQWORZ2QEwWeN/wXhyEk77o uKQ0zyZZSVw9E5I4rxCou9SoeRJLqec= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-Ug1WgrVRN_y40EUvn3O6RQ-1; Tue, 12 Mar 2024 10:25:22 -0400 X-MC-Unique: Ug1WgrVRN_y40EUvn3O6RQ-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3bbc40771a9so6953110b6e.0 for ; Tue, 12 Mar 2024 07:25:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710253521; x=1710858321; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hHJVOvVaBwYgQkbiWGrOfQhRrQzutoTvAGe8tcj6Ie4=; b=vYtApFgR+MKOhad5KR74Zb/IwCYmI62hK8EnvPqaQ3DQ8bc6sEj9Uez18fg/gl/vBE dOZiG9L5nwItiW7TB2B/OTcoUTaryib0PAXt4W1UonsaDM/U4j3b82UaLhUpvwO/FzoQ +LuD2FjvCiunz5OpYHH+mENHKbxbmbZdHmEkvfwDvx4OshmEnDu604VQ+DRpjetYwxIv zLiVZQy6QEKuObic0j8wto3iuU/R2UyqU+Iwc7HBl9yyASMVTz4iciAJMaaSGK809ZMX 7t/dzvv5tpeZOJ9HVCleFY29N848z9hQ/QiHVd8EmkfAc2QwcQ/Os0vHupkcuBkNIOqP 1PKw== X-Forwarded-Encrypted: i=1; AJvYcCV2nd2DEsegxX42ZVWUqf2Vyztn4fHhSQ9QufW9jZ580MP+mnYTif9/Ae4FwtVHjLSf1yr32OJiCG3X3MYVlg62vM/I+/1C7g== X-Gm-Message-State: AOJu0YzPtOConDKGz1KJ4kpNoMGP+uIlAtpS+mQ4EioX/4J+5a174IXz IOKLY6kz8QFfmYzq759T9NATGRvS4CpKrsoqLUUG2St+UZz23f0vPX7Sj3zFe+IIPc+eT3kbUoP K5KHwBb2hod3M+nb1ZS2GxHwjMEBfV+vuwPNakP9/R+owkZMEnu42qfA9wvFi+Z8= X-Received: by 2002:a05:6808:1410:b0:3c2:3340:92ce with SMTP id w16-20020a056808141000b003c2334092cemr12704204oiv.38.1710253521433; Tue, 12 Mar 2024 07:25:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGH5hw8fOh/0X1toFP1i5bnNUiWaOExJW8UoEC4Klhl4u8fWg8YICiLe1iHa7dh3V8nu0/2iw== X-Received: by 2002:a05:6808:1410:b0:3c2:3340:92ce with SMTP id w16-20020a056808141000b003c2334092cemr12704182oiv.38.1710253521147; Tue, 12 Mar 2024 07:25:21 -0700 (PDT) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id jr18-20020a05622a801200b0042f01e612bbsm3799031qtb.37.2024.03.12.07.25.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Mar 2024 07:25:20 -0700 (PDT) Message-ID: Date: Tue, 12 Mar 2024 10:25:19 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: recalculating local specs via build_extra_args [PR114303] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20240311165307.3930810-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20240311165307.3930810-1-ppalka@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.9 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_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 3/11/24 12:53, Patrick Palka wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look > OK for trunk and release branches? > > -- >8 -- > > r13-6452-g341e6cd8d603a3 made build_extra_args walk evaluated contexts > first so that we prefer processing a local specialization in an evaluated > context even if its first use is in an unevaluated context. But this > means we need to avoid walking a tree that already has extra args/specs > saved because the list of saved specs appears to be an evaluated > context. It seems then that we should be calculating the saved specs > from scratch each time, rather than potentially walking the saved specs > list from an earlier partial instantiation when calling build_extra_args > a second time around. Makes sense, but I wonder if we want to approach that by avoiding walking into *_EXTRA_ARGS in extract_locals_r? Or do we still want to walk into any nested extra args? And if so, will we run into this same problem then? > PR c++/114303 > > gcc/cp/ChangeLog: > > * constraint.cc (tsubst_requires_expr): Clear > REQUIRES_EXPR_EXTRA_ARGS before calling build_extra_args. > * pt.cc (tsubst_stmt) : Call build_extra_args > on the new IF_STMT instead of t which might already have > IF_STMT_EXTRA_ARGS. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp1z/constexpr-if-lambda6.C: New test. > --- > gcc/cp/constraint.cc | 1 + > gcc/cp/pt.cc | 2 +- > .../g++.dg/cpp1z/constexpr-if-lambda6.C | 16 ++++++++++++++++ > 3 files changed, 18 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda6.C > > diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc > index 49de3211d4c..8a3b5d80ba7 100644 > --- a/gcc/cp/constraint.cc > +++ b/gcc/cp/constraint.cc > @@ -2362,6 +2362,7 @@ tsubst_requires_expr (tree t, tree args, sat_info info) > matching or dguide constraint rewriting), in which case we need > to partially substitute. */ > t = copy_node (t); > + REQUIRES_EXPR_EXTRA_ARGS (t) = NULL_TREE; > REQUIRES_EXPR_EXTRA_ARGS (t) = build_extra_args (t, args, info.complain); > return t; > } > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index 8cf0d5b7a8d..37f2392d035 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -18718,7 +18718,7 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl) > IF_COND (stmt) = IF_COND (t); > THEN_CLAUSE (stmt) = THEN_CLAUSE (t); > ELSE_CLAUSE (stmt) = ELSE_CLAUSE (t); > - IF_STMT_EXTRA_ARGS (stmt) = build_extra_args (t, args, complain); > + IF_STMT_EXTRA_ARGS (stmt) = build_extra_args (stmt, args, complain); > add_stmt (stmt); > break; > } > diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda6.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda6.C > new file mode 100644 > index 00000000000..038c2a41210 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda6.C > @@ -0,0 +1,16 @@ > +// PR c++/114303 > +// { dg-do compile { target c++17 } } > + > +struct A { static constexpr bool value = true; }; > + > +int main() { > + [](auto x1) { > + return [&](auto) { > + return [&](auto x3) { > + if constexpr (decltype(x3)::value) { > + static_assert(decltype(x1)::value); > + } > + }(A{}); > + }(0); > + }(A{}); > +}