https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89537

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
With this patch

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index fb67d905acd..d9073d7c23d 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4246,7 +4246,7 @@ resolve_args (vec<tree, va_gc> *args, tsubst_flags_t
complain)
        error ("invalid use of void expression");
      return NULL;
    }
-      else if (invalid_nonstatic_memfn_p (arg->exp.locus, arg, complain))
+      else if (invalid_nonstatic_memfn_p (EXPR_LOCATION (arg), arg, complain))
    return NULL;
     }
   return args;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 1db9333b5ff..1bf9ad88141 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2562,7 +2562,8 @@ build_class_member_access_expr (cp_expr object, tree
member,
    type = unknown_type_node;
       /* Note that we do not convert OBJECT to the BASELINK_BINFO
     base.  That will happen when the function is called.  */
-      result = build3 (COMPONENT_REF, type, object, member, NULL_TREE);
+      result = build3_loc (input_location, COMPONENT_REF, type, object,
member,
+              NULL_TREE);
     }
   else if (TREE_CODE (member) == CONST_DECL)
     {

we get

89537.C:9:18: error: invalid use of non-static member function ‘void B<
<template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>,
<template-parameter-1-4> >::keys() [with _Tp = int; <template-parameter-1-2> =
int; <template-parameter-1-3> = A<int>; <template-parameter-1-4> = A<int>]’
    9 |       : keys(p1->keys), values(p1->values) {}
      |              ~~~~^~~~
89537.C:28:8: note: declared here
   28 |   void keys();
      |        ^~~~


so I guess it'd be an improvement.

Reply via email to