https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66130
--- Comment #10 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Paolo Carlini from comment #9) > But the error message is about l->*ptr, not about ptr per se. Yes, but the location should already point to l->*ptr. I'm thinking in cases such as: struct Local { void f(); int z; }; Local *l; void (Local::*j)(); int Local::*i; decltype((l->*j)) x; where printing "invalid use of non-static member function 'void (Local::*j)()'" seems more useful than "invalid use of non-static member function 'l->*j'" in order to spot the typo (i vs j). > that in such cases using dump_type (or %qT at the call site) on TREE_TYPE > (t) (TREE_TYPE (expr)) should be Ok. Yes! @@ -1826,11 +1826,16 @@ invalid_nonstatic_memfn_p (tree expr, ts if (is_overloaded_fn (expr) && !really_overloaded_fn (expr)) expr = get_first_fn (expr); if (DECL_NONSTATIC_MEMBER_FUNCTION_P (expr)) { if (complain & tf_error) - error ("invalid use of non-static member function"); + { + if (DECL_P (expr)) + error_at (loc, "invalid use of non-static member function %qD", expr); + else + error_at (loc, "invalid use of non-static member function %qT", TREE_TYPE (expr)); + } return true; } return false; } prints: test.cc:10:17: error: invalid use of non-static member function ‘void (Local::)()’ decltype((l->*j)) x; ^ which looks fine to me, except for the column location, but that seems harder to fix. We could also print a "note: declared here" to be extra helpful, but I'll leave that to whoever gets to finish this ;-)