Commit ee686729 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/90767 (jumbled error message with this and const)

	PR c++/90767
	* call.c (complain_about_no_candidates_for_method_call): If
	conv->from is not a type, pass to complain_about_bad_argument
	lvalue_type of conv->from.

	* g++.dg/diagnostic/pr90767-1.C: New test.
	* g++.dg/diagnostic/pr90767-2.C: New test.

From-SVN: r278484
parent d742b0c1
2019-11-20 Jakub Jelinek <jakub@redhat.com>
PR c++/90767
* call.c (complain_about_no_candidates_for_method_call): If
conv->from is not a type, pass to complain_about_bad_argument
lvalue_type of conv->from.
2019-11-20 Paolo Carlini <paolo.carlini@oracle.com> 2019-11-20 Paolo Carlini <paolo.carlini@oracle.com>
* cvt.c (ocp_convert): Use additional warning sentinel. * cvt.c (ocp_convert): Use additional warning sentinel.
......
...@@ -9871,8 +9871,11 @@ complain_about_no_candidates_for_method_call (tree instance, ...@@ -9871,8 +9871,11 @@ complain_about_no_candidates_for_method_call (tree instance,
if (const conversion_info *conv if (const conversion_info *conv
= maybe_get_bad_conversion_for_unmatched_call (candidate)) = maybe_get_bad_conversion_for_unmatched_call (candidate))
{ {
tree from_type = conv->from;
if (!TYPE_P (conv->from))
from_type = lvalue_type (conv->from);
complain_about_bad_argument (conv->loc, complain_about_bad_argument (conv->loc,
conv->from, conv->to_type, from_type, conv->to_type,
candidate->fn, conv->n_arg); candidate->fn, conv->n_arg);
return; return;
} }
......
2019-11-20 Jakub Jelinek <jakub@redhat.com> 2019-11-20 Jakub Jelinek <jakub@redhat.com>
PR c++/90767
* g++.dg/diagnostic/pr90767-1.C: New test.
* g++.dg/diagnostic/pr90767-2.C: New test.
PR middle-end/90840 PR middle-end/90840
* gcc.c-torture/compile/pr90840.c: New test. * gcc.c-torture/compile/pr90840.c: New test.
......
// PR c++/90767
// { dg-do compile }
struct X {
int n;
void foo (); // { dg-message "initializing argument 'this'" }
template<typename T>
operator T () const
{
if (n == 0)
foo (); // { dg-error "cannot convert 'const X\\*' to 'X\\*'" }
return n;
}
};
// PR c++/90767
// { dg-do compile }
struct A {
struct B { B (int) {} };
template <typename T>
void foo ()
{
int x = 0;
bar (x); // { dg-error "cannot convert 'int' to 'A::B&'" }
}
void bar (B &arg) {} // { dg-message "initializing argument 1" }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment