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 17C3D385DC1F for ; Wed, 6 Apr 2022 15:19:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 17C3D385DC1F Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-74-8g098502M-KPmIC8UEBoIg-1; Wed, 06 Apr 2022 11:19:39 -0400 X-MC-Unique: 8g098502M-KPmIC8UEBoIg-1 Received: by mail-qv1-f69.google.com with SMTP id kl16-20020a056214519000b004439e99963bso3938710qvb.3 for ; Wed, 06 Apr 2022 08:19:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=DkH8rxy0X5qfdVPlTge4mnSJOSfhVt6U30mwuaF9bW8=; b=jmC+yJG2JfaPdYJ6yDoercGOc1R/SrhsIL9HXLCV9Uz6IGl5fGPprySsq8vEOlL8NP 8qm206H1b4BoehD21Gy82+vJOoBxIPV6kFRA+zs9xe4BeoO2L5dI7vKkLMorDM52Mr4O D0uDPkRL7gZghE+KRWMaxLrMA/KIQqeZMg4b+Xa1f61vZEE1qfHUr5aRormm41CobRtR Mpm0JYtoXbtjRXbuRZX3lx7kwxS45MeYR9dO/VV5XcPAiTnJO/jmz1hh0oo2tu1fGxAt Hk58AIWCDQwagwPEDkHH+b1I0vH/TXMs1I46EslWHij9w7MBQBwA87w/OBGcdAvf/wPF U7ig== X-Gm-Message-State: AOAM532AUOd8Ub8vBqhl76DEHVhxoMehvnL89/L1YmH2o3wgLNcGFXmT nGgFItBThwrZZ3eE6rxRqK4C4M+gfYlg5LTOQUi/h/TzQ2+RU96d31QewxQnwlCk1RvzNa15Nxn TgUx0brxhulV1N//Bdg== X-Received: by 2002:a05:6214:2a82:b0:443:a395:cc23 with SMTP id jr2-20020a0562142a8200b00443a395cc23mr7603642qvb.67.1649258378908; Wed, 06 Apr 2022 08:19:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8Y5rEPCqB2tRZA8UzOzRLe2CuKukAJdM6LC8wnNVUkcsv0ieJvMQknMugrrrY0gldW0c6Qw== X-Received: by 2002:a05:6214:2a82:b0:443:a395:cc23 with SMTP id jr2-20020a0562142a8200b00443a395cc23mr7603627qvb.67.1649258378576; Wed, 06 Apr 2022 08:19:38 -0700 (PDT) Received: from [192.168.1.149] (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 p2-20020a05620a15e200b0067d2c0455bcsm9743838qkm.36.2022.04.06.08.19.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Apr 2022 08:19:37 -0700 (PDT) Message-ID: <16676b57-4562-dd74-2800-7a0373f7a19b@redhat.com> Date: Wed, 6 Apr 2022 11:19:37 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] c++: respect complain for -Wctad-maybe-unsupported [PR105143] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20220406151158.3381793-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20220406151158.3381793-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=-14.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, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Wed, 06 Apr 2022 15:19:42 -0000 On 4/6/22 11:11, Patrick Palka wrote: > We were attempting to issue a -Wctad-maybe-unsupported warning even when > complain=tf_none, which led to a crash in the first testcase below and a > bogus error during SFINAE in the second testcase. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk/11? OK. > PR c++/105143 > > gcc/cp/ChangeLog: > > * pt.cc (do_class_deduction): Check complain before issuing a > -Wctad-maybe-unsupported warning. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/nodiscard1.C: New test. > * g++.dg/warn/Wctad-maybe-unsupported4.C: New test. > --- > gcc/cp/pt.cc | 2 +- > gcc/testsuite/g++.dg/cpp2a/nodiscard1.C | 13 +++++++++++++ > .../g++.dg/warn/Wctad-maybe-unsupported4.C | 12 ++++++++++++ > 3 files changed, 26 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/nodiscard1.C > create mode 100644 gcc/testsuite/g++.dg/warn/Wctad-maybe-unsupported4.C > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index 1f0231f70e6..1805fa68440 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -30075,7 +30075,7 @@ do_class_deduction (tree ptype, tree tmpl, tree init, > > /* If CTAD succeeded but the type doesn't have any explicit deduction > guides, this deduction might not be what the user intended. */ > - if (fndecl != error_mark_node && !any_dguides_p) > + if ((complain & tf_warning) && fndecl != error_mark_node && !any_dguides_p) > { > if ((!DECL_IN_SYSTEM_HEADER (fndecl) > || global_dc->dc_warn_system_headers) > diff --git a/gcc/testsuite/g++.dg/cpp2a/nodiscard1.C b/gcc/testsuite/g++.dg/cpp2a/nodiscard1.C > new file mode 100644 > index 00000000000..c3c5094b619 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/nodiscard1.C > @@ -0,0 +1,13 @@ > +// PR c++/105143 > +// { dg-do compile { target c++20 } } > +// We used to crash here with "Error reporting routines re-entered". > + > +template struct A { }; > + > +template using type = int; > + > +template [[nodiscard]] type get(); > + > +int main() { > + get<{}>(); // { dg-warning "nodiscard" } > +} > diff --git a/gcc/testsuite/g++.dg/warn/Wctad-maybe-unsupported4.C b/gcc/testsuite/g++.dg/warn/Wctad-maybe-unsupported4.C > new file mode 100644 > index 00000000000..0d0e2fb45eb > --- /dev/null > +++ b/gcc/testsuite/g++.dg/warn/Wctad-maybe-unsupported4.C > @@ -0,0 +1,12 @@ > +// PR c++/105143 > +// { dg-do compile { target c++17 } } > +// { dg-additional-options "-Werror=ctad-maybe-unsupported" } > + > +template struct A { }; > + > +template class TT> auto f(...) -> decltype(TT()); // #1 > +template class TT> void f(int); // #2 > + > +int main() { > + f(0); // Calls #2 without issuing a -Wctad-maybe-unsupported diagnostic. > +}