From patchwork Fri Oct 20 21:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1852838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bfPkyJTQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SByvX2LGtz23jM for ; Sat, 21 Oct 2023 08:51:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A938386187F for ; Fri, 20 Oct 2023 21:51:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 008393858C00 for ; Fri, 20 Oct 2023 21:50:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 008393858C00 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 008393858C00 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697838650; cv=none; b=JTa0FTb1C3lUAOzfHDLsJWaetZVHz/Oe663XIat/VKoDCIKW+wmaditlOv0rXixCUEuYl8c5r2BrBLCwohbfYy79jEugaLy86nKp8VEITHboSITqkkaRTSg91vTGsQe+qRn6YIXUoTv75RqvAPNT5vTu6rhL/HbBrRgBOQyzEas= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697838650; c=relaxed/simple; bh=9TWWFM/A7lf4JdoylunudY3F+9ZVawTINn5Tv6Zg/No=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IPrlDs48DbWJusU3Oj8aibvgNkCo71+hInWjDUsVYI/7WnO9+QT2mbH4cOvlADM8C1Be85Q9Pr5zqIoOMxv7xv0eySvTf6cJjiT2KtWdSW4O9171q9DG5SWly6e2llryV5RlAsL45cmuBdy2Kdc8w1NEscVCw4+EEr6RsPkdimE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697838648; 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; bh=D/ck7Jm+mIjxwPWs2MQeNHr2zNt8QJleSVf9I6LUBys=; b=bfPkyJTQoeJyF99tEofpgpDqUvVnxiwvVzKE1K3vz5zGskxoc3uFtZC6SXGQxrLlDQ6yAD ys94Lpv5HFxekdRc0qNpp5bWS47fNSLG/SGmJ3UnUoGT7mn4jR1rygATALWeLvUdecFEWn uphdw3q3TSDyZg8smWvmS6Y/aXVDN+E= Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153--Oa_g0OSMHmv8lWnX0rmfA-1; Fri, 20 Oct 2023 17:50:47 -0400 X-MC-Unique: -Oa_g0OSMHmv8lWnX0rmfA-1 Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-1e9a324c12fso1981335fac.2 for ; Fri, 20 Oct 2023 14:50:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697838646; x=1698443446; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D/ck7Jm+mIjxwPWs2MQeNHr2zNt8QJleSVf9I6LUBys=; b=Tw67keJ7i3v76803hdqUc5MwCpjNsK6BnKlaZK4Rex/1VDX0w3iL3R9RLxp1eBhJGl Q7Tgx7JD7QjfpJpADPmsYkjstGuEQF3RiZkxNtIpIHII/7a449YqU+nRj568tTJsL7dz H8WiF/OayMDI5SJYKy2GkU2//2FFptulqt4k7oLSm9INKirltGpgrV16mxFINHrEsgdK 58sAIRlz8MEmF7JzXNNxT97nMHmzlecbajM2aidgA/yEz1+YpECyob4FwMsKsZgBnu5d /hvUgPpVXEnS+IW5MJ8nr2MrH3ti+lXi7//zBLM1HfA8k07/VrLQ6E7uh676oOrFSNWz l8pw== X-Gm-Message-State: AOJu0YwSVTg2Q2wmVdV+dLdDW4aUlja8rPQ2Jss8tinb/FJVTrs16hw3 y1Xho1CEz+sdPbaFlatocDuUQMakQ3ejjsCj1lw/sFNd5p8/oXzxA3/hT5EFGe6ilq0eaHQxpxu BcqQhxaZus09YxKHHFhnfUPW1uhi2GAX4YU2q/tZv49RjvkbvZSopi74xqltZoWuGGPGrz6zrXQ == X-Received: by 2002:a05:6870:90cd:b0:1e9:b860:96df with SMTP id s13-20020a05687090cd00b001e9b86096dfmr3686839oab.7.1697838646607; Fri, 20 Oct 2023 14:50:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYOSM3Fmfh8Vs9+HqDUN+Z1ad5fvbjNZLKjFuzWjbfNP07N21oXLPMM+4KY1EwdRtMWPCvZg== X-Received: by 2002:a05:6870:90cd:b0:1e9:b860:96df with SMTP id s13-20020a05687090cd00b001e9b86096dfmr3686823oab.7.1697838646207; Fri, 20 Oct 2023 14:50:46 -0700 (PDT) Received: from jason.com (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 o14-20020a05620a110e00b00775ab978009sm922725qkk.36.2023.10.20.14.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 14:50:45 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: Jonathan Wakely Subject: [pushed] c++: abstract class and overload resolution Date: Fri, 20 Oct 2023 17:50:43 -0400 Message-Id: <20231020215043.2277730-1-jason@redhat.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- In my implementation of P0929 I treated a conversion to an rvalue of abstract class type as a bad conversion, but that's still too soon to check it; we need to wait until we're done with overload resolution. gcc/cp/ChangeLog: * call.cc (implicit_conversion_1): Rename... (implicit_conversion): ...to this. Remove the old wrapper. gcc/testsuite/ChangeLog: * g++.dg/template/sfinae-dr657.C: Adjust. --- gcc/cp/call.cc | 30 ++++---------------- gcc/testsuite/g++.dg/template/sfinae-dr657.C | 7 ++--- 2 files changed, 9 insertions(+), 28 deletions(-) base-commit: 7d4e99131606badcdc343cce62691245dac11bb4 diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index a49fde949d5..2eb54b5b6ed 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -2032,12 +2032,14 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags, return conv; } -/* Most of the implementation of implicit_conversion, with the same - parameters. */ +/* Returns the implicit conversion sequence (see [over.ics]) from type + FROM to type TO. The optional expression EXPR may affect the + conversion. FLAGS are the usual overloading flags. If C_CAST_P is + true, this conversion is coming from a C-style cast. */ static conversion * -implicit_conversion_1 (tree to, tree from, tree expr, bool c_cast_p, - int flags, tsubst_flags_t complain) +implicit_conversion (tree to, tree from, tree expr, bool c_cast_p, + int flags, tsubst_flags_t complain) { conversion *conv; @@ -2167,26 +2169,6 @@ implicit_conversion_1 (tree to, tree from, tree expr, bool c_cast_p, return NULL; } -/* Returns the implicit conversion sequence (see [over.ics]) from type - FROM to type TO. The optional expression EXPR may affect the - conversion. FLAGS are the usual overloading flags. If C_CAST_P is - true, this conversion is coming from a C-style cast. */ - -static conversion * -implicit_conversion (tree to, tree from, tree expr, bool c_cast_p, - int flags, tsubst_flags_t complain) -{ - conversion *conv = implicit_conversion_1 (to, from, expr, c_cast_p, - flags, complain); - if (!conv || conv->bad_p) - return conv; - if (conv_is_prvalue (conv) - && CLASS_TYPE_P (conv->type) - && CLASSTYPE_PURE_VIRTUALS (conv->type)) - conv->bad_p = true; - return conv; -} - /* Like implicit_conversion, but return NULL if the conversion is bad. This is not static so that check_non_deducible_conversion can call it within diff --git a/gcc/testsuite/g++.dg/template/sfinae-dr657.C b/gcc/testsuite/g++.dg/template/sfinae-dr657.C index 36c11e65918..bb19108c5d8 100644 --- a/gcc/testsuite/g++.dg/template/sfinae-dr657.C +++ b/gcc/testsuite/g++.dg/template/sfinae-dr657.C @@ -1,7 +1,6 @@ -// DR 657 SUPERSEDED BY DR 1646 +// DR 657 SUPERSEDED BY P0929 // Test that a return or parameter type with abstract class type DOES NOT cause -// a deduction failure, but there is no implicit conversion sequence for -// a parameter of abstract class type. +// a deduction failure or conversion failure. struct A { @@ -19,5 +18,5 @@ template int arg(...); int main() { int i = declval(); // { dg-error "ambiguous" } - i = arg(1); + i = arg(1); // { dg-error "abstract" } }