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 C8DA83858C20 for ; Thu, 27 Apr 2023 15:58:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8DA83858C20 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=1682611127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q1CwGD5/Wj4p7IyCMcWEjUE29IvBKbxmjs/5OhI+m7c=; b=h9HKQwFq0rboKFTAmhhBHmUqPlQXch9KXqkzfdnSIU9yjBhgBMgdxBht7VWnFKaCytojh1 vEkZXRof12X6rkz3dbjlfqLHl1Ns54r8ODGag4LLQzlLmo8NtGSC3m3NJhgUmbRZhPFGbr t/41dTtDlPdmy3hYHGruhGL5yqhRhX4= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-77-o-K0K-Z3Mpu8p13tjIOf2Q-1; Thu, 27 Apr 2023 11:58:46 -0400 X-MC-Unique: o-K0K-Z3Mpu8p13tjIOf2Q-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-74fb912c146so308847285a.2 for ; Thu, 27 Apr 2023 08:58:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682611125; x=1685203125; 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=Q1CwGD5/Wj4p7IyCMcWEjUE29IvBKbxmjs/5OhI+m7c=; b=U9kX1rAEYlyepPQNUVrlYosc7pzgRRZ12fc717UrdHgg+wsGRCt/Bq/JJH6ryMAv5L DDvxde3ez+SMkHaq9ej4XEbnphRvHQrC1i31f/8Ddjh2xKuc+C5BrtbGFaC0r9pAcUx2 ERYc8rOJqoU7xeUzc4Tl3cj+1GhZ5ChA0bXAl8IYYqLEbytJctwF0va8k+/PNIf4HM/C xXLl8AU8zndeBRhHB8702qeyMidbNxng6YoveTLySQ63m0M6FMSSAye9OTCP05fApLWR 8BzBm2yFaSipaIStUp65Q6AyuxpWjbYKLp3wxwd8u5nWA8eb82th+CN7Kg/K6/azc1Mq 0IYQ== X-Gm-Message-State: AC+VfDxTdtNvp1uQTTkEOFeuDhywa/FqJFo4EXb6IU3UgUnoKieemEKz C/Wos2BP9ip4ZKtuG/1T2B4TSHA8Hs58lVx07v8dMQ4aihCYhxs/WKf3FoJY+C2LnmBH5tX4HjA mu9XbLPMbBsz3HVi+A/+28ztkgw5JIi2Tk0IjW8yUHGwqsHGnFnFKlwlim/2xYLDH1PTn++vfqA == X-Received: by 2002:a05:6214:23cc:b0:5e0:5ea6:69d0 with SMTP id hr12-20020a05621423cc00b005e05ea669d0mr3508554qvb.0.1682611125368; Thu, 27 Apr 2023 08:58:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LC6vG6eZSzkWePafUYtj+/kGFNd8XZe9v4QwpvOo+d2vjKXaTG1wP8Jiuh5zzVNIEOv9nIQ== X-Received: by 2002:a05:6214:23cc:b0:5e0:5ea6:69d0 with SMTP id hr12-20020a05621423cc00b005e05ea669d0mr3508498qvb.0.1682611124833; Thu, 27 Apr 2023 08:58:44 -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 q10-20020a0cf5ca000000b005dd8b934585sm5686225qvm.29.2023.04.27.08.58.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 08:58:44 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: print conversion error at candidate location Date: Thu, 27 Apr 2023 11:58:42 -0400 Message-Id: <20230427155842.699173-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- In testcases like this one, the printing of candidates in a diagnostic has been longer than necessary because it jumps back and forth between the call site and the candidate site. So here, we first say at the call site that no match was found; then we note the candidate site, and then explain why it's not suitable back at the call site, which means printing the call site line with caret again. With this patch, the conversion diagnostic is at the same location as the candidate, so we don't need to print any input line. gcc/cp/ChangeLog: * call.cc (print_conversion_rejection): Use iloc_sentinel. gcc/testsuite/ChangeLog: * g++.dg/template/copy1.C: Adjust error lines. --- gcc/cp/call.cc | 1 + gcc/testsuite/g++.dg/template/copy1.C | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index cdd7701b9e7..2a06520c0c1 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -3847,6 +3847,7 @@ print_conversion_rejection (location_t loc, struct conversion_info *info, if (info->n_arg >= 0) inform (loc, " conversion of argument %d would be ill-formed:", info->n_arg + 1); + iloc_sentinel ils = loc; perform_implicit_conversion (info->to_type, info->from, tf_warning_or_error); } diff --git a/gcc/testsuite/g++.dg/template/copy1.C b/gcc/testsuite/g++.dg/template/copy1.C index a34221df38b..eacd9e2c025 100644 --- a/gcc/testsuite/g++.dg/template/copy1.C +++ b/gcc/testsuite/g++.dg/template/copy1.C @@ -6,9 +6,10 @@ struct A { + // { dg-error "reference" "" { target c++14_down } .+1 } A(A&); // { dg-message "A::A" "" { target c++14_down } } template A(T); // { dg-message "A::A" "" { target c++14_down } } }; -A a = 0; // { dg-error "" "" { target c++14_down } } +A a = 0; // { dg-error "no match" "" { target c++14_down } } base-commit: e0cf929d99bebd9a740db6db45d69957514e0c12 -- 2.31.1