Hi,
this tries to implement what Jason suggested in the audit trail: do not
refer to an argument and use instead 'cannot convert...", like, eg, in
cvt.c.
Tested x86_64-linux.
Thanks,
Paolo.
//////////////////////
/cp
2011-10-19 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/13657
* class.c (instantiate_type): Fix error message.
/testsuite
2011-10-19 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/13657
* g++.dg/parse/error42.C: New.
Index: testsuite/g++.dg/parse/error42.C
===================================================================
--- testsuite/g++.dg/parse/error42.C (revision 0)
+++ testsuite/g++.dg/parse/error42.C (revision 0)
@@ -0,0 +1,4 @@
+// PR c++/13657
+
+class C { public: int (*f())(); int bar(); };
+int (*C::f())() { return C::bar; } // { dg-error "cannot convert 'C::bar'" }
Index: cp/class.c
===================================================================
--- cp/class.c (revision 180208)
+++ cp/class.c (working copy)
@@ -6867,8 +6867,8 @@ instantiate_type (tree lhstype, tree rhs, tsubst_f
else
{
if (flags & tf_error)
- error ("argument of type %qT does not match %qT",
- TREE_TYPE (rhs), lhstype);
+ error ("cannot convert %qE from type %qT to type %qT",
+ rhs, TREE_TYPE (rhs), lhstype);
return error_mark_node;
}
}