From patchwork Wed May 10 21:07:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 92294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3920656vqo; Wed, 10 May 2023 14:08:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TH1DzlOFhZ0HG9wTHC8wvOdNnwU4DfYzw/2qzZY8FFnyPgCKljXNT3+fpawg6wCs0Mrcy X-Received: by 2002:aa7:da95:0:b0:50b:d553:3822 with SMTP id q21-20020aa7da95000000b0050bd5533822mr12669881eds.7.1683752902673; Wed, 10 May 2023 14:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683752902; cv=none; d=google.com; s=arc-20160816; b=Kp+3f1Hkr3DfkMviO4PMAxJ9qzXFgNpjJlmURJa3OGe1/dR1qtp5VfF01c+t9dbJuz E8O7fH2Q0Wfn/CU12GX1qZJ8Cun4+jHhQx+c0TScHW25oh3tvIV4b5lBfWtV8rf0UIqP CVkelr0u0hEvNBmEwuUk/GrXNfqMueU2ETiBQI9pYZYB/c7qr8ZJBRGoeMpsDddABw2Z o2Q6sFPUJdbICCZqP/BHrqXpFObTlfIG9hp9O8T8HK1l30d2Wq8BMYhalLuV5ZzFPsQx uf1PdCXt80yKvtJYig4x9EEQRgk84cwZFZeqXz4C1iFTVN2+BqhhZmCqJf7nN3avdjzy GNGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Ydnz32YiihfkOO7ny8NgVFbQM+kmC8gn6QRutgYKaXo=; b=Kshbdox9MyW6EMM1OusO8qi9ko/e8bQeL6BydLyLiNsIn8sFZVedw7KhLo8yOA5nSy us+vKb2X5mF9dNwjk4bS486wqlQFAhWFZ+NI9RW5zU8lF+tzxkH1JPXKBXs/J4LaVY6O 9S+w35D09g+wTZpiUs8U5+a8gIWRti2C0bNqOKFYQCMD2NFYY6TJ4SiiYCCvCxF8nU44 XiyFlSZ+mlSIxiCNhFO/Ufp9PwkPxr83hRJs+ClOOp/MSHXu5l5RUyLjG7xGVoYXowBE AaHi3YHLAXBinL8YK8TWEXbNwvooq0c1E6aTv+fX5E2yNmgg9o436gJ1gYISVuarqBBK W5bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UFpy4sZt; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h2-20020aa7c602000000b0050c0e683b3bsi3417737edq.98.2023.05.10.14.08.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 14:08:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UFpy4sZt; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 950E8385609A for ; Wed, 10 May 2023 21:08:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 950E8385609A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683752901; bh=Ydnz32YiihfkOO7ny8NgVFbQM+kmC8gn6QRutgYKaXo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=UFpy4sZtHwaIhkKppQdDc4IvnJw34uIvuZPBRNW2NgC0vn04QaLq75i3GxV1xaViK YwbU9Fkb9rFN3TjbU7B1Ow4cZ922YbHuyLa1YhwjAuRwhgsq6ps9VwGDXvGeKWrZf8 ULZH5+jFqnQbJuKH8QvM+8QMVAtzkQPgLKciBx7M= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 25B473857036 for ; Wed, 10 May 2023 21:07:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 25B473857036 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-nMNWIVruPUORIsxOZ5yrEg-1; Wed, 10 May 2023 17:07:36 -0400 X-MC-Unique: nMNWIVruPUORIsxOZ5yrEg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-61b7313c804so44545856d6.0 for ; Wed, 10 May 2023 14:07:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683752855; x=1686344855; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ydnz32YiihfkOO7ny8NgVFbQM+kmC8gn6QRutgYKaXo=; b=lvMyfXfSHnWNZXQf1koGQrNMsMiNz9BWuH+rWgmAc55v7CdItsoH3sGViOo3EV7rJw ng+irE2IJIK69wJL/JUTqYClHFH28/bp5lj1423qQigzvGvdva6u8z/0lakFEuhehq6f m+azzz1Tf7Tq9vQerLpPBrc6crv8X7pKNMc94+NrqywTWWBBAywErcKQLdVwMN6DAYeT kNwyfuppZnqwPZraLLwwwfFvtWhBNQ0BViRmwSPSkclBTQ9zGgJm3e/3Y3gREZ4V5bIb uKK2NbHBRMYh1cAYvDHKqAtGH16n/CqhtXv8ZlUlnzMPCtcpttTWyTbARnWd7IG8/Sgs VkWw== X-Gm-Message-State: AC+VfDxLmmwQT2P1pTP+Bybm/+x0KvrPd+PoCYb662YFUa56y9ENI0rM e/JGk2uDq9QI/8v0eQoialQ5U8EqxUIQZIPIWfUfhK1RWixLNdj4WRtnEez8joGr0DkFnOipDE2 KaKS27SVht1XExC8P5OWv/F5pfuU38ORN8TsSLYOYN7INZ4AsjIVQ+94CJB8Sa309GvAwUix63g == X-Received: by 2002:a05:6214:5015:b0:61b:7680:1283 with SMTP id jo21-20020a056214501500b0061b76801283mr28390513qvb.16.1683752855769; Wed, 10 May 2023 14:07:35 -0700 (PDT) X-Received: by 2002:a05:6214:5015:b0:61b:7680:1283 with SMTP id jo21-20020a056214501500b0061b76801283mr28390484qvb.16.1683752855411; Wed, 10 May 2023 14:07:35 -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 f3-20020a0cf3c3000000b0062075f40f61sm1797312qvm.73.2023.05.10.14.07.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 14:07:34 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: adjust conversion diagnostics Date: Wed, 10 May 2023 17:07:31 -0400 Message-Id: <20230510210731.975161-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 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_H2, 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 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-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765542883880751315?= X-GMAIL-MSGID: =?utf-8?q?1765542883880751315?= Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- While looking at PR109247 I made this change to improve diagnostics. I don't think I'm going ahead with that patch, but this still seems like a worthy cleanup. gcc/cp/ChangeLog: * call.cc (convert_like_internal): Share ck_ref_bind handling between all bad conversions. --- gcc/cp/call.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) base-commit: 8d46516a61a83d24ba89086071f65a194d82ce4e diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 2a06520c0c1..48611bb16a3 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -8360,15 +8360,6 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, /*issue_conversion_warnings=*/false, /*c_cast_p=*/false, /*nested_p=*/true, complain); - if (convs->kind == ck_ref_bind) - expr = convert_to_reference (totype, expr, CONV_IMPLICIT, - LOOKUP_NORMAL, NULL_TREE, - complain); - else - expr = cp_convert (totype, expr, complain); - if (complained) - maybe_inform_about_fndecl_for_bogus_argument_init (fn, argnum); - return expr; } else if (t->kind == ck_user || !t->bad_p) { @@ -8376,6 +8367,8 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, /*issue_conversion_warnings=*/false, /*c_cast_p=*/false, /*nested_p=*/true, complain); + if (t->bad_p) + complained = 1; break; } else if (t->kind == ck_ambig) @@ -8394,10 +8387,15 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, "invalid conversion from %qH to %qI", TREE_TYPE (expr), totype); } + if (convs->kind == ck_ref_bind) + expr = convert_to_reference (totype, expr, CONV_IMPLICIT, + LOOKUP_NORMAL, NULL_TREE, + complain); + else + expr = cp_convert (totype, expr, complain); if (complained == 1) maybe_inform_about_fndecl_for_bogus_argument_init (fn, argnum); - - return cp_convert (totype, expr, complain); + return expr; } if (issue_conversion_warnings && (complain & tf_warning))