parameter. That must be done before the FN is transformed
because we depend on the form of FN. */
make_args_non_dependent (*args);
- object = build_non_dependent_expr (object);
- if (TREE_CODE (fn) == DOTSTAR_EXPR)
- object = cp_build_addr_expr (object, tf_warning_or_error);
- VEC_safe_insert (tree, gc, *args, 0, object);
+ if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE)
+ {
+ object = build_non_dependent_expr (object);
+ if (TREE_CODE (fn) == DOTSTAR_EXPR)
+ object = cp_build_addr_expr (object, tf_warning_or_error);
+ VEC_safe_insert (tree, gc, *args, 0, object);
+ }
/* Now that the arguments are done, transform FN. */
fn = build_non_dependent_expr (fn);
}
VEC_safe_insert (tree, gc, *args, 0, object_addr);
}
- expr = cp_build_function_call_vec (fn, args, tf_warning_or_error);
+ if (CLASS_TYPE_P (TREE_TYPE (fn)))
+ expr = build_op_call (fn, args, tf_warning_or_error);
+ else
+ expr = cp_build_function_call_vec (fn, args, tf_warning_or_error);
if (processing_template_decl && expr != error_mark_node)
expr = build_min_non_dep_call_vec (expr, orig_fn, orig_args);
--- /dev/null
+// PR c++/48594
+// Test for uses of (X->*Y)() that don't actually involve a
+// pointer to member function.
+
+struct A { } a;
+struct B { } b;
+struct C * cp;
+
+struct Func { void operator()(); };
+Func operator->* (A, int);
+
+typedef void (*pfn)();
+pfn operator->* (B, int);
+
+pfn C::*cpfn;
+Func C::*cfunc;
+
+template <class T>
+void f()
+{
+ (a->*1)();
+ (b->*1)();
+ (cp->*cpfn)();
+ (cp->*cfunc)();
+}