From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 4D2FF3945056 for ; Fri, 28 Aug 2020 16:46:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4D2FF3945056 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-N-y-ZweLNNaC2wwlSA6usw-1; Fri, 28 Aug 2020 12:46:03 -0400 X-MC-Unique: N-y-ZweLNNaC2wwlSA6usw-1 Received: by mail-qv1-f71.google.com with SMTP id l18so1215557qvq.16 for ; Fri, 28 Aug 2020 09:46:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=WH3Pkk54SQiJ1p+Cta0f/k4Gdk7fhLP02o9SUE5d7u0=; b=S3kVDP/fjZrUNPQyjUJvAO1HtFFVuaa2W66FWS7x1sP0yWO2/Ez5/fWscQKNK/vDY7 KhAfmvgEx3iGlwxflLJ4ZHUGJwNqGN7dDuu0a9lzypKaCbK30/8dffSzQjaWDSdUR3mR OWI91x5DJdcXVVFF7ghBEdrnUWbro9m9geiozj4Ua3UpMAaoJc2zNqMkxvkpXvJNW5oN 6W5KRA5X4ZcQJYRNDpHe4bpLgjDnAM1DrW3x65qCkFM1BMs9dAnxdTyzVj/GMgQ5d+9I qv/UjR0tQm/Ht8Ph38uwz7Yh8+XeGckbyRX1YFOEBe3AxFwgpXZ+n7eM/Dg+djWCmde7 ehaQ== X-Gm-Message-State: AOAM530kBlqgMlKrO6M74OFUrMNoAaWRv/IrwVGfK347A4g/M+MEhQG+ Ebj6rx2AICZXcwedGfRaXm1U+e3dj1EqTfIwQOnu0GC7afVP6NAOZr7cxzx1NComaahVADI4djS LmqzLo6dqbb14i7XEoQ== X-Received: by 2002:ac8:7455:: with SMTP id h21mr2343995qtr.201.1598633159292; Fri, 28 Aug 2020 09:45:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKItx7zamm/eytNoOIlw1BQP/cK1Ce5GlO4Z3RbrDjBC53pDCleEvAgmpekSKgohYXs21OEw== X-Received: by 2002:ac8:7455:: with SMTP id h21mr2343974qtr.201.1598633159025; Fri, 28 Aug 2020 09:45:59 -0700 (PDT) Received: from [192.168.1.130] (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id s47sm1486459qtb.13.2020.08.28.09.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 09:45:58 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Fri, 28 Aug 2020 12:45:57 -0400 (EDT) To: Patrick Palka cc: gcc-patches@gcc.gnu.org, jason@redhat.com Subject: Re: [PATCH] c++: Fix resolving the address of overloaded pmf [PR96647] In-Reply-To: <20200828164052.2100771-1-ppalka@redhat.com> Message-ID: <5f76b94-415-5844-ea48-414f418b5aae@idea> References: <20200828164052.2100771-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-16.7 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 28 Aug 2020 16:46:06 -0000 (Removing libstdc++@gcc.gnu.org from CC list) On Fri, 28 Aug 2020, Patrick Palka wrote: > In resolve_address_of_overloaded_function, currently only the second > pass over the overload set (which considers just the function templates > in the overload set) checks constraints and performs return type > deduction when necessary. But as the testcases below show, we need to > do this when considering non-template functions during the first pass, > too. > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk? > > gcc/cp/ChangeLog: > > PR c++/96647 > * class.c (resolve_address_of_overloaded_function): Also check > constraints and perform return type deduction when considering > non-template functions in the overload set. > > gcc/testsuite/ChangeLog: > > PR c++/96647 > * g++.dg/cpp0x/auto-96647.C: New test. > * g++.dg/cpp2a/concepts-fn6.C: New test. > --- > gcc/cp/class.c | 16 ++++++++++++++++ > gcc/testsuite/g++.dg/cpp0x/auto-96647.C | 10 ++++++++++ > gcc/testsuite/g++.dg/cpp2a/concepts-fn6.C | 10 ++++++++++ > 3 files changed, 36 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/auto-96647.C > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-fn6.C > > diff --git a/gcc/cp/class.c b/gcc/cp/class.c > index 3479b8207d2..c15cb04c654 100644 > --- a/gcc/cp/class.c > +++ b/gcc/cp/class.c > @@ -8286,6 +8286,22 @@ resolve_address_of_overloaded_function (tree target_type, > one, or vice versa. */ > continue; > > + /* Constraints must be satisfied. This is done before > + return type deduction since that instantiates the > + function. */ > + if (!constraints_satisfied_p (fn)) > + continue; > + > + if (undeduced_auto_decl (fn)) > + { > + /* Force instantiation to do return type deduction. */ > + ++function_depth; > + instantiate_decl (fn, /*defer*/false, /*class*/false); > + --function_depth; > + > + require_deduced_type (fn); > + } > + > /* In C++17 we need the noexcept-qualifier to compare types. */ > if (flag_noexcept_type > && !maybe_instantiate_noexcept (fn, complain)) > diff --git a/gcc/testsuite/g++.dg/cpp0x/auto-96647.C b/gcc/testsuite/g++.dg/cpp0x/auto-96647.C > new file mode 100644 > index 00000000000..314b2a16ac2 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/auto-96647.C > @@ -0,0 +1,10 @@ > +// PR c++/96647 > +// { dg-do compile { target c++11 } } > + > +template > +struct Base { > + auto f(int) { } > + auto f(char) { } > +}; > + > +void (Base::*ptr)(int) = &Base::f; > diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-fn6.C b/gcc/testsuite/g++.dg/cpp2a/concepts-fn6.C > new file mode 100644 > index 00000000000..3d7941658d4 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-fn6.C > @@ -0,0 +1,10 @@ > +// PR c++/96647 > +// { dg-do compile { target c++20 } } > + > +template > +struct Base { > + auto f(int) { } > + auto f(int) requires T::fail { static_assert(T::fail); } > +}; > + > +void (Base::*ptr)(int) = &Base::f; > -- > 2.28.0.358.g20de7e7e4f > >