Hi,
while working on improving the locations of cp_build_indirect_ref_1 &
co, I noticed this nit which seems a separate issue.
In a nutshell, at variance with many other cases, in build_x_arrow we
don't immediately check for error_mark_node the return value of
decay_conversion. Then, for the testcase, after a sensible:
error: invalid use of member function ‘C* C::f()’ (did you forget the
‘()’ ?)
we also issue:
error: base operand of ‘->’ is not a pointer
which is certainly redundant and a bit misleading, is talking about the
'f' mentioned in the first message. The amended behavior is also
consistent with EDG and CLANG.
Tested x86_64-linux, as usual.
Thanks, Paolo.
//////////////////////////
/gcc
2019-11-20 Paolo Carlini <paolo.carl...@oracle.com>
* typeck2.c (build_x_arrow): Early return if decay_conversion
returns error_mark_node.
/testsuite
2019-11-20 Paolo Carlini <paolo.carl...@oracle.com>
* g++.dg/parse/error43.C: Adjust expected error.
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c (revision 278499)
+++ cp/typeck2.c (working copy)
@@ -2044,7 +2044,11 @@ build_x_arrow (location_t loc, tree expr, tsubst_f
last_rval = convert_from_reference (last_rval);
}
else
- last_rval = decay_conversion (expr, complain);
+ {
+ last_rval = decay_conversion (expr, complain);
+ if (last_rval == error_mark_node)
+ return error_mark_node;
+ }
if (TYPE_PTR_P (TREE_TYPE (last_rval)))
{
Index: testsuite/g++.dg/parse/error43.C
===================================================================
--- testsuite/g++.dg/parse/error43.C (revision 278499)
+++ testsuite/g++.dg/parse/error43.C (working copy)
@@ -2,4 +2,4 @@
// { dg-options "" }
class C { public: C* f(); int get(); };
-int f(C* p) { return p->f->get(); } // { dg-error "forget the '\\(\\)'|base
operand" }
+int f(C* p) { return p->f->get(); } // { dg-error "25:invalid use of member
function" }