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.129.124]) by sourceware.org (Postfix) with ESMTPS id 3A86E3858C1F for ; Wed, 12 Jul 2023 15:54:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A86E3858C1F 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=1689177286; 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: in-reply-to:in-reply-to:references:references; bh=YAa+7jxymU3DC+E86lsp0uBkaLKYdTNvxPJ1DQIlCVs=; b=J6AZetcsj9eWhYnGNdByMI7HWhmMNvqJeDoq2a7DSqUGHy3zj9ambEwLZtuV45YXPLXZHg +FwxaphQedKyd6QIh86zZSLI0oD9zp8A0iyVrAlLEyXeiIP5Hp/RxrjOYAVr0fQ76MpyaW yxoYJcgrQFjogaLQ0pQUEdfy8hOEvNs= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-81-iHG8gce5OCqI-V4l6CdXMw-1; Wed, 12 Jul 2023 11:54:45 -0400 X-MC-Unique: iHG8gce5OCqI-V4l6CdXMw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-62fe5abe808so7254966d6.1 for ; Wed, 12 Jul 2023 08:54:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689177285; x=1691769285; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YAa+7jxymU3DC+E86lsp0uBkaLKYdTNvxPJ1DQIlCVs=; b=GrBVyjv5VHMeCXgRzRx12++ENvgGy2bUflYQ5WxmMo+RniTHyHjneNuWbDjcFZtOlo g3rply3bNVdkdo6ufoMFNH0fsQjbkb1kECF1Sa3X8sWHjQpy1aAFf3cmuPems32hGESh W8x6hk+jU4R9ad3qRfnj3V8tqZjksXTor8QgLj4Ntn14iNWstniBudgtR1odk8/79Jyj kvdD3mTw0d5Jh5qsHxDVknASuxWhKfzWsLUV5a4O8wmnL+z7CEypWPC3WGdOIzBXvHIN c5+9FM/ghsLlgrQvYScnGwgeqk8/+HXH7m/gnQCd+lZuxitIZ3XAP8Hg+wEu/YW+4Fgk Wu2g== X-Gm-Message-State: ABy/qLZXOC0n8Og4Cs3edLTN3BqEMy3RkJgrpcGIgP7dzyrikWbxNAJy hL4kp2rLajs4Spce0RcYcxIvG8OtYKVthNtwG7f6mpVGqCQiKBNO+MOiZG/8IdjpmDHFZ4WeW8V 885xFzjFc7O6m24T3RQ== X-Received: by 2002:a0c:cb8f:0:b0:62d:ed86:154b with SMTP id p15-20020a0ccb8f000000b0062ded86154bmr2490316qvk.5.1689177284928; Wed, 12 Jul 2023 08:54:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEcW7ZBRIaker3ni/N54t2zV+W9suwDJnWjbly0F7MmDezdS3d//+P93OeYkFF0g1NQ+pIhUQ== X-Received: by 2002:a0c:cb8f:0:b0:62d:ed86:154b with SMTP id p15-20020a0ccb8f000000b0062ded86154bmr2490300qvk.5.1689177284670; Wed, 12 Jul 2023 08:54:44 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id g7-20020a05620a108700b00767d05117fesm2243305qkk.36.2023.07.12.08.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 08:54:44 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Wed, 12 Jul 2023 11:54:43 -0400 (EDT) To: Patrick Palka cc: gcc-patches@gcc.gnu.org, jason@redhat.com Subject: Re: [PATCH] c++: constrained surrogate calls [PR110535] In-Reply-To: <20230712154138.2837658-1-ppalka@redhat.com> Message-ID: <5ead72b2-d241-1dbc-b168-63260321683e@idea> References: <20230712154138.2837658-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.8 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,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 Wed, 12 Jul 2023, Patrick Palka wrote: > We're not checking constraints of pointer/reference-to-function conversion > functions during overload resolution, which causes us to ICE on the first > testcase and incorrectly reject the second testcase. Er, I noticed [over.call.object] doesn't exactly say that surrogate call functions inherit the constraints of the corresponding conversion function, but I reckon that's the intent? > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk/13? > > PR c++/110535 > > gcc/cp/ChangeLog: > > * call.cc (add_conv_candidate): Check constraints. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/concepts-surrogate1.C: New test. > * g++.dg/cpp2a/concepts-surrogate2.C: New test. > --- > gcc/cp/call.cc | 8 ++++++++ > gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C | 12 ++++++++++++ > gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C | 14 ++++++++++++++ > 3 files changed, 34 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C > > diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc > index 15a3d6f2a1f..81935b83908 100644 > --- a/gcc/cp/call.cc > +++ b/gcc/cp/call.cc > @@ -2588,6 +2588,14 @@ add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj, > if (*candidates && (*candidates)->fn == totype) > return NULL; > > + if (!constraints_satisfied_p (fn)) > + { > + reason = constraint_failure (); > + viable = 0; > + return add_candidate (candidates, fn, obj, arglist, len, convs, > + access_path, conversion_path, viable, reason, flags); > + } > + > for (i = 0; i < len; ++i) > { > tree arg, argtype, convert_type = NULL_TREE; > diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C > new file mode 100644 > index 00000000000..e8481a31656 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C > @@ -0,0 +1,12 @@ > +// PR c++/110535 > +// { dg-do compile { target c++20 } } > + > +using F = int(int); > + > +template > +struct A { > + operator F*() requires B; > +}; > + > +int i = A{}(0); // OK > +int j = A{}(0); // { dg-error "no match" } > diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C b/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C > new file mode 100644 > index 00000000000..8bf8364beb7 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C > @@ -0,0 +1,14 @@ > +// PR c++/110535 > +// { dg-do compile { target c++20 } } > + > +using F = int(int); > +using G = long(int); > + > +template > +struct A { > + operator F&() requires B; > + operator G&() requires (!B); > +}; > + > +int i = A{}(0); // { dg-bogus "ambiguous" } > +int j = A{}(0); // { dg-bogus "ambiguous" } > -- > 2.41.0.327.gaa9166bcc0 > >