Commit fe66170d by Paolo Carlini Committed by Paolo Carlini

re PR c++/31423 (Improve upon "invalid use of member (did you forget the '&' ?)")

/cp
2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/31423
	* typeck2.c (cxx_incomplete_type_diagnostic): Improve error message
	for invalid use of member function.

/testsuite
2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/31423
	* g++.dg/parse/error43.C: New.
	* g++.dg/parse/error44.C: Likewise.

From-SVN: r180309
parent c1a330ef
2011-10-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/31423
* typeck2.c (cxx_incomplete_type_diagnostic): Improve error message
for invalid use of member function.
2011-10-21 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/50811
......
......@@ -428,8 +428,15 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
case OFFSET_TYPE:
bad_member:
emit_diagnostic (diag_kind, input_location, 0,
"invalid use of member (did you forget the %<&%> ?)");
if (DECL_FUNCTION_MEMBER_P (TREE_OPERAND (value, 1))
&& ! flag_ms_extensions)
emit_diagnostic (diag_kind, input_location, 0,
"invalid use of member function "
"(did you forget the %<()%> ?)");
else
emit_diagnostic (diag_kind, input_location, 0,
"invalid use of member "
"(did you forget the %<&%> ?)");
break;
case TEMPLATE_TYPE_PARM:
......
2011-10-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/31423
* g++.dg/parse/error43.C: New.
* g++.dg/parse/error44.C: Likewise.
2011-10-21 H.J. Lu <hongjiu.lu@intel.com>
Kirill Yukhin <kirill.yukhin@intel.com>
......
// PR c++/31423
// { dg-options "" }
class C { public: C* f(); int get(); };
int f(C* p) { return p->f->get(); } // { dg-error "forget the '\\(\\)'|base operand" }
// PR c++/31423
// { dg-options "-fms-extensions" }
struct C {
int f() { return 1; }
int g() { return 2; }
};
int f(C& c) {
return c.g == &c.f; // { dg-error "forget the '&'" }
}
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