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 319D93858D28 for ; Sun, 10 Dec 2023 19:32:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 319D93858D28 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 319D93858D28 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=1702236758; cv=none; b=YLMg3phOcU8WfXmPKMoymPQDI83lPNzxZG4WUEninnEG+UXGNwgIX8u5u7YPByZgTtfi4hdhvg+9OV8pM9Puj1pEp1TQKfY6JIyD62dFCamZVSeXzrdNywVt5LEpEaEML5sIOuF9lVccIjn6+f/OehhDm+XKnpAxaocw2LFRRd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702236758; c=relaxed/simple; bh=RajF9FhKHNkMLN/o/bRVDzbMs9h+yRlJsQ+sERA09FQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=fauflL7Gno7NNCBEZtH17WzLNRpYMEZ4yAqyqeubu9BhU5f+LVggZ7wjd8NaIzOgB+g9bGYJasKzDLcDWtwHtZR92ayhtGqHSLc20ijbj9H2oAhYuaV0XuZ6n3Xbg5dQn8ZuVUXDfXUY15eX2KrEmcF8A4Ch64AFC1nUyNygfSs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702236755; 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: in-reply-to:in-reply-to:references:references; bh=70xABQjK1YS+pzQa8tkjaTJ5sRMlocn8iWh1fbDW8gc=; b=KPa0q0uWisItXZ11Lox/UjxWP9qVZMnJh6a4XPuc5clvfeNBe8eVc3ZAhKA/SjrYQZEXj5 51cPSEmUb+kxYsppNqVxyqyJsqwFwlQjOEq4J0IVK7+7SnukX0/wkiH5QXpraZlOY1TYKj gvmcAleieQQUhYFTvRX2+UpJi/YOqv4= 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-377-ir20lmvSPKWYuAguyDTtEQ-1; Sun, 10 Dec 2023 14:32:34 -0500 X-MC-Unique: ir20lmvSPKWYuAguyDTtEQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-67add991c9bso49208866d6.1 for ; Sun, 10 Dec 2023 11:32:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702236753; x=1702841553; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=70xABQjK1YS+pzQa8tkjaTJ5sRMlocn8iWh1fbDW8gc=; b=IyvULjVlJk7sb8gE8DK1SU5yCU1hhfwzC3rAaR6YWosq+BYFJBk8S0LJUH2Z4b+occ l5mxwDrfGNoequSs7MaD7Ncw28yXSRk9BScojUnZg7RTVdKP0OB8z/h/3a9LHGUyYTkJ C0x7Gde0ooyqVNT2/Fa5ofsnuNuWiq0zafrwV2rBBqNPayFcrKh0vh4+heK+4a7rzpcc oOd+ouPuuoPIayHZlk0/iz0+APH1+IJ79HB5Xsd74MnXKFiubMsE1ScZp7FRgHIjMQ0A s5lnSwDpMMmsXJ5zEJUH7Ouh8jUvU5JiXCJ0534qC1L9ofECwJyyoHhsAA+T+MZZ1D89 FMKg== X-Gm-Message-State: AOJu0YzLkt1th+ID0MKbzbQW2zlfn2teC5DIYVA4NoMTvuoNqB7km8tb 3qEX9ZV0f2NCuNt0QnA4dMdAfdb0O+W3liIeSiaNMdnpskD7AFl2Y2dKG1qLv0OK6iIz/isc3nZ ctK7KRC3kjVN7oUda0JPFC6fDGg== X-Received: by 2002:a0c:fb42:0:b0:67b:b7fe:85a7 with SMTP id b2-20020a0cfb42000000b0067bb7fe85a7mr4383844qvq.115.1702236753208; Sun, 10 Dec 2023 11:32:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrUYmIHAqM6xUWBCVhrnFD1XpztlyMksZxcvas0s+KwHvJCo4JBXRYYTcb68RrCy9QBhOguw== X-Received: by 2002:a0c:fb42:0:b0:67b:b7fe:85a7 with SMTP id b2-20020a0cfb42000000b0067bb7fe85a7mr4383834qvq.115.1702236752885; Sun, 10 Dec 2023 11:32:32 -0800 (PST) Received: from [192.168.1.108] (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 s6-20020a0cf646000000b0067ec9faed23sm736135qvm.142.2023.12.10.11.32.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Dec 2023 11:32:32 -0800 (PST) Message-ID: <6c089ef1-0e7b-4e3b-bfd2-fc32c1c11c46@redhat.com> Date: Sun, 10 Dec 2023 14:32:31 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/3] c++: note other candidates when diagnosing deletedness To: Patrick Palka Cc: gcc-patches@gcc.gnu.org References: <20231027195532.2566822-1-ppalka@redhat.com> <20231027195532.2566822-3-ppalka@redhat.com> <35674d69-7c49-4b2d-99fb-977cf34e7e9a@redhat.com> <4ed7c5e7-6707-a679-aa83-d72736e0806a@idea> <3cfbf151-f87b-49bc-11a0-a96034f9eabb@idea> From: Jason Merrill In-Reply-To: <3cfbf151-f87b-49bc-11a0-a96034f9eabb@idea> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 11/30/23 10:46, Patrick Palka wrote: > On Fri, 27 Oct 2023, Patrick Palka wrote: >> On Fri, 27 Oct 2023, Jason Merrill wrote: >>> On 10/27/23 15:55, Patrick Palka wrote: >>>> With the previous two patches in place, we can now extend our >>>> deletedness diagnostic to note the other considered candidates, e.g.: >>>> >>>> deleted16.C: In function 'int main()': >>>> deleted16.C:10:4: error: use of deleted function 'void f(int)' >>>> 10 | f(0); >>>> | ~^~~ >>>> deleted16.C:5:6: note: declared here >>>> 5 | void f(int) = delete; >>>> | ^ >>>> deleted16.C:5:6: note: candidate: 'void f(int)' (deleted) >>>> deleted16.C:6:6: note: candidate: 'void f(...)' >>>> 6 | void f(...); >>>> | ^ >>>> deleted16.C:7:6: note: candidate: 'void f(int, int)' >>>> 7 | void f(int, int); >>>> | ^ >>>> deleted16.C:7:6: note: candidate expects 2 arguments, 1 provided >>>> >>>> These notes are controlled by a new command line flag -fnote-all-cands, >>>> which also controls whether we note ignored candidates more generally. >>>> >>>> gcc/ChangeLog: >>>> >>>> * doc/invoke.texi (C++ Dialect Options): Document -fnote-all-cands. >>>> >>>> gcc/c-family/ChangeLog: >>>> >>>> * c.opt: Add -fnote-all-cands. >>>> >>>> gcc/cp/ChangeLog: >>>> >>>> * call.cc (print_z_candidates): Only print ignored candidates >>>> when -fnote-all-cands is set. >>>> (build_over_call): When diagnosing deletedness, call >>>> print_z_candidates if -fnote-all-cands is set. >>> >>> My suggestion was also to suggest using the flag in cases where it would make >>> a difference, e.g. >>> >>> note: some candidates omitted, use '-fnote-all-cands' to display them >> >> Ah thanks, fixed. That'll help a lot with discoverability of the flag. >> >>> >>> Maybe "-fdiagnostics-all-candidates"? >> >> Nice, that's a better name indeed :) >> >> How does the following look? Full bootstrap/regtest in progress. >> >> Here's the output of e.g. deleted16a.C. I think I'd prefer to not print >> the source line when emitting the suggestion, but I don't know how to do >> that properly (aside from e.g. emitting the note at UNKNOWN_LOCATION). >> >> In file included from gcc/testsuite/g++.dg/cpp0x/deleted16a.C:4: >> gcc/testsuite/g++.dg/cpp0x/deleted16.C: In function ‘int main()’: >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:21:4: error: use of deleted function ‘void f(int)’ >> 21 | f(0); // { dg-error "deleted" } >> | ~^~~ >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:6:6: note: declared here >> 6 | void f(int) = delete; // { dg-message "declared here" } >> | ^ >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:21:4: note: use ‘-fdiagnostics-all-candidates’ to display considered candidates >> 21 | f(0); // { dg-error "deleted" } >> | ~^~~ >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:22:4: error: use of deleted function ‘void g(int)’ >> 22 | g(0); // { dg-error "deleted" } >> | ~^~~ >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:12:6: note: declared here >> 12 | void g(int) = delete; // { dg-message "declared here" } >> | ^ >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:22:4: note: use ‘-fdiagnostics-all-candidates’ to display considered candidates >> 22 | g(0); // { dg-error "deleted" } >> | ~^~~ >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:23:4: error: use of deleted function ‘void h(T, T) [with T = int]’ >> 23 | h(1, 1); // { dg-error "deleted" } >> | ~^~~~~~ >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:17:24: note: declared here >> 17 | template void h(T, T) = delete; // { dg-message "declared here|candidate" } >> | ^ >> gcc/testsuite/g++.dg/cpp0x/deleted16.C:23:4: note: use ‘-fdiagnostics-all-candidates’ to display considered candidates >> 23 | h(1, 1); // { dg-error "deleted" } >> | ~^~~~~~ >> >> -- >8 -- >> >> >> Subject: [PATCH 3/3] c++: note other candidates when diagnosing deletedness >> >> With the previous two patches in place, we can now extend our >> deletedness diagnostic to note the other considered candidates, e.g.: >> >> deleted16.C: In function 'int main()': >> deleted16.C:10:4: error: use of deleted function 'void f(int)' >> 10 | f(0); >> | ~^~~ >> deleted16.C:5:6: note: declared here >> 5 | void f(int) = delete; >> | ^ >> deleted16.C:5:6: note: candidate: 'void f(int)' (deleted) >> deleted16.C:6:6: note: candidate: 'void f(...)' >> 6 | void f(...); >> | ^ >> deleted16.C:7:6: note: candidate: 'void f(int, int)' >> 7 | void f(int, int); >> | ^ >> deleted16.C:7:6: note: candidate expects 2 arguments, 1 provided >> >> These notes are controlled by a new command line flag >> -fdiagnostics-all-candidates which also controls whether we note >> ignored candidates more generally. >> >> gcc/ChangeLog: >> >> * doc/invoke.texi (C++ Dialect Options): Document >> -fdiagnostics-all-candidates. >> >> gcc/c-family/ChangeLog: >> >> * c.opt: Add -fdiagnostics-all-candidates. >> >> gcc/cp/ChangeLog: >> >> * call.cc (print_z_candidates): Only print ignored candidates >> when -fdiagnostics-all-candidates is set, otherwise suggest >> the flag. >> (build_over_call): When diagnosing deletedness, note >> other candidates only if -fdiagnostics-all-candidates is >> set, otherwise suggest the flag. >> >> gcc/testsuite/ChangeLog: >> >> * g++.dg/overload/error6.C: Pass -fdiagnostics-all-candidates. >> * g++.dg/cpp0x/deleted16.C: New test. >> * g++.dg/cpp0x/deleted16a.C: New test. >> * g++.dg/overload/error6a.C: New test. > > Ping. OK. Jason