]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: print conversion error at candidate location
authorJason Merrill <jason@redhat.com>
Thu, 23 Mar 2023 14:43:58 +0000 (10:43 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 27 Apr 2023 15:54:43 +0000 (11:54 -0400)
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
gcc/testsuite/g++.dg/template/copy1.C

index cdd7701b9e77c25e7b04cf3dfb15a5698e19b860..2a06520c0c107e5b66f2caef514d445c3f66f914 100644 (file)
@@ -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);
     }
index a34221df38b649b33479f953fe0b4b0feb55f284..eacd9e2c02573038df395cee4f056f69eb06a28f 100644 (file)
@@ -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 } }