public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-309] c++: print conversion error at candidate location
Date: Thu, 27 Apr 2023 15:58:54 +0000 (GMT)	[thread overview]
Message-ID: <20230427155854.2475938582BD@sourceware.org> (raw)

https://gcc.gnu.org/g:14e881eb0305090e5b184806b917d492373d32ea

commit r14-309-g14e881eb0305090e5b184806b917d492373d32ea
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 23 10:43:58 2023 -0400

    c++: print conversion error at candidate location
    
    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.

Diff:
---
 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 <class T> 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 } }

                 reply	other threads:[~2023-04-27 15:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230427155854.2475938582BD@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).