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: 156352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1341564vqb; Fri, 20 Oct 2023 14:51:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEI3xscQoh9X9pHqkQopO3xLJsh7VAAJvsY1vVgW2+SPoR1/RGPMfff1+rPQ9MABwjiaZPH X-Received: by 2002:a05:620a:6288:b0:778:a9f4:bba with SMTP id ov8-20020a05620a628800b00778a9f40bbamr3008410qkn.2.1697838673979; Fri, 20 Oct 2023 14:51:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697838673; cv=pass; d=google.com; s=arc-20160816; b=dp513BIzlATZLaRwnvulwXUSM79JYNZnchdp+qs/Xg0SBmWznzaM4QdInC1kFJgSOj aEhze30O7p2S20uOTm1IQhVZKBYtlQUku9MFvcI03ZPvAyT7ombYr4KxpFCl8qVKYoyk E2EeYj9Ekdb+dk/0cF3hbYUCwAKguzgx+hksjvg2ViJGioTFuVfTzUSNV0I9mSNlDjn1 LHOMCWzjmQhaHyBX4YUsfsaspMzzqDueNjAM3W3VINEv+VzYJ3SOwt6oOklwQIoq4NNt i1JJQb1i2yJVzOC/sJEXlHlYuyOILUdlHF+K8nXmwI+id610UPueQSnB0uS21oVAU901 tvgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=D/ck7Jm+mIjxwPWs2MQeNHr2zNt8QJleSVf9I6LUBys=; fh=BOTBd3nUR/j4Pyjej4ZDmy7+z+dlfAzU1weMgvsimDY=; b=KpNpv2U6b2pMNHfinHDb5LOFzKYicCEk+wd8RvTYJHxTh7X+BcYnvZ4BWeWCO764ac X8X3TurJZ+B+2VQySWYmyfoeCppvn1D3WUcO+z8F1D30iV9gwYiAyn4fdENupK4gNRSt zEcb0QmjgeSDuRXNlF6nLbWl/Iil3DjGf3ugZQf7xmr3+r5hFhhZ5nYHQdSTv1+BHAxY XvWt4+xk0GrqIERBwQDfH+9/NMGBzT5sW0SDJeiZvuNbNEpLNrNb551EWFM/lS848SMX jQZquEkTxue4OO1s+gCqPtXOkle5r/ikopsNGdcPSEaXZCEE2+B5V6sqWCmq1pcoHmH+ CEFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bfPkyJTQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qr21-20020a05620a391500b00778b0f5d4c0si1001234qkn.566.2023.10.20.14.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 14:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bfPkyJTQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B967738618CF for ; Fri, 20 Oct 2023 21:51:13 +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-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780312885481570929 X-GMAIL-MSGID: 1780312885481570929 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" } }