+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>
* cvt.c (ocp_convert): Use additional warning sentinel.
if (const conversion_info *conv
= 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,
- conv->from, conv->to_type,
+ from_type, conv->to_type,
candidate->fn, conv->n_arg);
return;
}
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
* gcc.c-torture/compile/pr90840.c: New test.
--- /dev/null
+// 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;
+ }
+};
--- /dev/null
+// 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" }
+};