On 11/19/23 13:36, waffl3x wrote:
I'm having trouble fixing the error for this case, the control flow
when the functions are overloaded is much more complex.

struct S {
   void f(this S&) {}
   void f(this S&, int)

   void g() {
     void (*fp)(S&) = &f;
   }
};

This seemed to have fixed the non overloaded case, but I'm also not
very happy with it, it feels kind of icky. Especially since the expr's
location isn't available here, although, it just occurred to me that
the expr's location is probably stored in the node.

typeck.cc:cp_build_addr_expr_1
```
     case BASELINK:
       arg = BASELINK_FUNCTIONS (arg);
       if (DECL_XOBJ_MEMBER_FUNC_P (
         {
           error ("You must qualify taking address of xobj member functions");
          return error_mark_node;
         }

The loc variable was set earlier in the function, you can use that.

The overloaded case we want to handle here in resolve_address_of_overloaded_function:

  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn)
      && !(complain & tf_ptrmem_ok) && !flag_ms_extensions)
    {
      static int explained;

      if (!(complain & tf_error))
        return error_mark_node;

      auto_diagnostic_group d;
      if (permerror (input_location, "assuming pointer to member %qD", fn)
          && !explained)
        {
          inform (input_location, "(a pointer to member can only be "
                  "formed with %<&%E%>)", fn);
          explained = 1;
        }
    }

Jason

Reply via email to