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 36BC13858D1E for ; Tue, 13 Sep 2022 13:49:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 36BC13858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663076951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1zJvcgMKQiUkIDBtJ+GzpJ993yK9HpYwlLoBNwbgYNg=; b=e4yeCZoK67GDXANVu7NMHkymArKaJBlvKjb+f9ooVZMvNIoZy+NHXrx6AY7Lgxwo9Mi/2D pj20caN9Y9euluqLShqbjBwEm1FesFG21VVw/RgwDsxo37RJXmGClTwDjZxtINBldj6DN2 Ky1tvPqCq3KHrxVmOt6cx1dKXMV7Cx8= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-144-fmGft6tZNj27Mu5HWbLXRg-1; Tue, 13 Sep 2022 09:49:11 -0400 X-MC-Unique: fmGft6tZNj27Mu5HWbLXRg-1 Received: by mail-qk1-f197.google.com with SMTP id u15-20020a05620a0c4f00b006b8b3f41303so10085550qki.8 for ; Tue, 13 Sep 2022 06:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=1zJvcgMKQiUkIDBtJ+GzpJ993yK9HpYwlLoBNwbgYNg=; b=Qu/ZXW/Mc+KUy6L7C7IqjcfGx4REk8FTeU9hVAaerzjMMuj6C039UbVfkNJ2TNZe8d R4qcR7BxFabEMKJTRLzKfRogEMu51UbfQtq9rBrywuP2ctyYWFeTXyb850Qn36OaiAVI gZO7BVUU+DGdYP9rZ7xB1KEbpshaipDLF5HSsbZcnfCfCpBSpPA7LVfHjbzxVjuC15JN lWLGDf1VDZhLHxVkz4BYuG90KLftAdpLAyETnzS/KUeVXcScWL4xyzF3Rt0hirxeNPnM I+7MHZD3+07ROAT6BfRyz/MQUtc7U5wAeJOJQFzbEawuoy3aTEuT1aV84hy9sxhAfmqe /ZbA== X-Gm-Message-State: ACgBeo1E7w/Z/T7wy5rJEqFv9thwnvrDBqhP77tlaRq+HtCEnYBTOwsn vV31rLi21d6HAPXXr2SwGtNxi0gc5ekujPgN+eh0S7qzRCS0yvnXmgqMuWbO82JtfusHQwbjCnC xIwejDlzrWyDuNGkbJw== X-Received: by 2002:a0c:c547:0:b0:4ac:9897:543f with SMTP id y7-20020a0cc547000000b004ac9897543fmr13617647qvi.17.1663076949451; Tue, 13 Sep 2022 06:49:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR729t5WyGaWhO25wwFjWLqWdEKjobPR8Fp/eKxq5vVc1lslyaVSAuD1mwqmMeV3acaG+VCtAg== X-Received: by 2002:a0c:c547:0:b0:4ac:9897:543f with SMTP id y7-20020a0cc547000000b004ac9897543fmr13617620qvi.17.1663076949102; Tue, 13 Sep 2022 06:49:09 -0700 (PDT) Received: from [192.168.1.101] (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 p13-20020a05622a13cd00b003435bb7fe9csm9433801qtk.78.2022.09.13.06.49.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Sep 2022 06:49:08 -0700 (PDT) Message-ID: <326173f2-6073-6405-e61c-307e49f5870d@redhat.com> Date: Tue, 13 Sep 2022 09:49:07 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH] c++: some missing-SFINAE fixes To: Patrick Palka Cc: gcc-patches@gcc.gnu.org References: <20220913114538.2741902-1-ppalka@redhat.com> <30bb32f6-3f08-5a45-e39a-ae8f49bc4af0@redhat.com> <4336c12a-a7e0-a2ba-c39d-55d970865649@idea> From: Jason Merrill In-Reply-To: <4336c12a-a7e0-a2ba-c39d-55d970865649@idea> 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=-13.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,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 9/13/22 09:46, Patrick Palka wrote: > On Tue, 13 Sep 2022, Jason Merrill wrote: > >> On 9/13/22 07:45, Patrick Palka wrote: >>> It looks like we aren't respecting SFINAE for: >>> >>> * an invalid/non-constant conditional explicit-specifier >>> * a non-constant conditional noexcept-specifier >>> * a non-constant argument to __integer_pack >>> >>> This patch fixes these issues in the usual way, by passing complain >>> and propagating error_mark_node appropriately. >>> >>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for >>> trunk? >>> >>> gcc/cp/ChangeLog: >>> >>> * decl.cc (build_explicit_specifier): Pass complain to >>> cxx_constant_value. >>> * except.cc (build_noexcept_spec): Likewise. >>> * pt.cc (expand_integer_pack): Likewise. >>> (tsubst_function_decl): Propagate error_mark_node returned >>> from build_explicit_specifier. >>> >>> gcc/testsuite/ChangeLog: >>> >>> * g++.dg/cpp1z/noexcept-type26.C: New test. >>> * g++.dg/cpp2a/explicit19.C: New test. >>> * g++.dg/ext/integer-pack6.C: New test. >>> --- >>> gcc/cp/decl.cc | 2 +- >>> gcc/cp/except.cc | 2 +- >>> gcc/cp/pt.cc | 6 ++++-- >>> gcc/testsuite/g++.dg/cpp1z/noexcept-type26.C | 12 ++++++++++++ >>> gcc/testsuite/g++.dg/cpp2a/explicit19.C | 12 ++++++++++++ >>> gcc/testsuite/g++.dg/ext/integer-pack6.C | 13 +++++++++++++ >>> 6 files changed, 43 insertions(+), 4 deletions(-) >>> create mode 100644 gcc/testsuite/g++.dg/cpp1z/noexcept-type26.C >>> create mode 100644 gcc/testsuite/g++.dg/cpp2a/explicit19.C >>> create mode 100644 gcc/testsuite/g++.dg/ext/integer-pack6.C >>> >>> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc >>> index 936f1cf0197..5404d7e084c 100644 >>> --- a/gcc/cp/decl.cc >>> +++ b/gcc/cp/decl.cc >>> @@ -18557,7 +18557,7 @@ build_explicit_specifier (tree expr, tsubst_flags_t >>> complain) >>> expr = build_converted_constant_bool_expr (expr, complain); >>> expr = instantiate_non_dependent_expr (expr, complain); >>> - expr = cxx_constant_value (expr); >>> + expr = cxx_constant_value (expr, NULL_TREE, complain); >> >> The patch is OK, but perhaps we want another overload that omits the object >> parameter? > > Thanks -- sounds good, like the following incremental patch? OK. > -- >8 -- > > Subject: [PATCH] c++: two-parameter version of cxx_constant_value > > Since some callers need the complain parameter but not the object > parameter, let's introduce and use an overload of cxx_constant_value > that omits the latter. > > gcc/cp/ChangeLog: > > * cp-tree.h (cxx_constant_value): Define two-parameter version > that omits the object parameter. > * decl.cc (build_explicit_specifier): Omit NULL_TREE object > argument to cxx_constant_value. > * except.cc (build_noexcept_spec): Likewise. > * pt.cc (expand_integer_pack): Likewise. > (fold_targs_r): Likewise. > * semantics.cc (finish_if_stmt_cond): Likewise. > --- > gcc/cp/cp-tree.h | 2 ++ > gcc/cp/decl.cc | 2 +- > gcc/cp/except.cc | 2 +- > gcc/cp/pt.cc | 4 ++-- > gcc/cp/semantics.cc | 2 +- > 5 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h > index 2ba44e80e20..1eb176d4a50 100644 > --- a/gcc/cp/cp-tree.h > +++ b/gcc/cp/cp-tree.h > @@ -8414,6 +8414,8 @@ extern bool require_rvalue_constant_expression (tree); > extern bool require_potential_rvalue_constant_expression (tree); > extern tree cxx_constant_value (tree, tree = NULL_TREE, > tsubst_flags_t = tf_error); > +inline tree cxx_constant_value (tree t, tsubst_flags_t complain) > +{ return cxx_constant_value (t, NULL_TREE, complain); } > extern void cxx_constant_dtor (tree, tree); > extern tree cxx_constant_init (tree, tree = NULL_TREE); > extern tree maybe_constant_value (tree, tree = NULL_TREE, bool = false); > diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc > index 5404d7e084c..006e9affcba 100644 > --- a/gcc/cp/decl.cc > +++ b/gcc/cp/decl.cc > @@ -18557,7 +18557,7 @@ build_explicit_specifier (tree expr, tsubst_flags_t complain) > > expr = build_converted_constant_bool_expr (expr, complain); > expr = instantiate_non_dependent_expr (expr, complain); > - expr = cxx_constant_value (expr, NULL_TREE, complain); > + expr = cxx_constant_value (expr, complain); > return expr; > } > > diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc > index 4d7f0ce102d..048612de400 100644 > --- a/gcc/cp/except.cc > +++ b/gcc/cp/except.cc > @@ -1257,7 +1257,7 @@ build_noexcept_spec (tree expr, tsubst_flags_t complain) > { > expr = build_converted_constant_bool_expr (expr, complain); > expr = instantiate_non_dependent_expr (expr, complain); > - expr = cxx_constant_value (expr, NULL_TREE, complain); > + expr = cxx_constant_value (expr, complain); > } > if (TREE_CODE (expr) == INTEGER_CST) > { > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index 074179288b6..db4e808adec 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -3869,7 +3869,7 @@ expand_integer_pack (tree call, tree args, tsubst_flags_t complain, > else > { > hi = instantiate_non_dependent_expr (hi, complain); > - hi = cxx_constant_value (hi, NULL_TREE, complain); > + hi = cxx_constant_value (hi, complain); > int len = valid_constant_size_p (hi) ? tree_to_shwi (hi) : -1; > > /* Calculate the largest value of len that won't make the size of the vec > @@ -20121,7 +20121,7 @@ fold_targs_r (tree targs, tsubst_flags_t complain) > && !glvalue_p (elt) > && !TREE_CONSTANT (elt)) > { > - elt = cxx_constant_value (elt, NULL_TREE, complain); > + elt = cxx_constant_value (elt, complain); > if (elt == error_mark_node) > return false; > } > diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc > index 3edefb2fca2..4f189978484 100644 > --- a/gcc/cp/semantics.cc > +++ b/gcc/cp/semantics.cc > @@ -1042,7 +1042,7 @@ finish_if_stmt_cond (tree orig_cond, tree if_stmt) > { > maybe_warn_for_constant_evaluated (cond, /*constexpr_if=*/true); > cond = instantiate_non_dependent_expr (cond); > - cond = cxx_constant_value (cond, NULL_TREE); > + cond = cxx_constant_value (cond); > } > else > {