aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-11-20 09:33:56 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-11-20 09:33:56 +0100
commitee686729283500c330b8b920f4f8e4dcc566adde (patch)
tree749ac663fb4f1550f1ed8d1ac5b9e3376f97a7cb /gcc
parentd742b0c1a02aab7fa61b6d89eecee81b298f06c6 (diff)
downloadgcc-ee686729283500c330b8b920f4f8e4dcc566adde.zip
gcc-ee686729283500c330b8b920f4f8e4dcc566adde.tar.gz
gcc-ee686729283500c330b8b920f4f8e4dcc566adde.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/call.c5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/pr90767-1.C15
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/pr90767-2.C15
5 files changed, 45 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 34af32c..6031acf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f4dfa7b..cccb90f 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -9871,8 +9871,11 @@ complain_about_no_candidates_for_method_call (tree instance,
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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7de7a43..a6086a4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
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.
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr90767-1.C b/gcc/testsuite/g++.dg/diagnostic/pr90767-1.C
new file mode 100644
index 0000000..7d1cd3d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr90767-1.C
@@ -0,0 +1,15 @@
+// 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;
+ }
+};
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr90767-2.C b/gcc/testsuite/g++.dg/diagnostic/pr90767-2.C
new file mode 100644
index 0000000..550762b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr90767-2.C
@@ -0,0 +1,15 @@
+// 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" }
+};