===================================================================
@@ -2901,20 +2901,24 @@ cp_build_indirect_ref (tree ptr, ref_ope
{
case RO_ARRAY_INDEXING:
error ("invalid use of array indexing on pointer to member");
break;
case RO_UNARY_STAR:
error ("invalid use of unary %<*%> on pointer to member");
break;
case RO_IMPLICIT_CONVERSION:
error ("invalid use of implicit conversion on pointer to member");
break;
+ case RO_ARROW_PM:
+ error ("left hand operand of %<->*%> must be a pointer to class, "
+ "but is a pointer to member of type %qT", type);
+ break;
default:
gcc_unreachable ();
}
else if (pointer != error_mark_node)
invalid_indirection_error (input_location, type, errorstring);
return error_mark_node;
}
/* This handles expressions of the form "a[i]", which denotes
===================================================================
@@ -5302,21 +5302,21 @@ build_new_op_1 (location_t loc, enum tre
case POSTDECREMENT_EXPR:
case REALPART_EXPR:
case IMAGPART_EXPR:
case ABS_EXPR:
return cp_build_unary_op (code, arg1, candidates != 0, complain);
case ARRAY_REF:
return cp_build_array_ref (input_location, arg1, arg2, complain);
case MEMBER_REF:
- return build_m_component_ref (cp_build_indirect_ref (arg1, RO_NULL,
+ return build_m_component_ref (cp_build_indirect_ref (arg1, RO_ARROW_PM,
complain),
arg2, complain);
/* The caller will deal with these. */
case ADDR_EXPR:
case COMPONENT_REF:
case COMPOUND_EXPR:
return NULL_TREE;
default:
===================================================================
@@ -470,21 +470,23 @@ extern c_language_kind c_language;
typedef enum ref_operator {
/* NULL */
RO_NULL,
/* array indexing */
RO_ARRAY_INDEXING,
/* unary * */
RO_UNARY_STAR,
/* -> */
RO_ARROW,
/* implicit conversion */
- RO_IMPLICIT_CONVERSION
+ RO_IMPLICIT_CONVERSION,
+ /* ->* */
+ RO_ARROW_PM
} ref_operator;
/* Information about a statement tree. */
struct GTY(()) stmt_tree_s {
/* A stack of statement lists being collected. */
VEC(tree,gc) *x_cur_stmt_list;
/* In C++, Nonzero if we should treat statements as full
expressions. In particular, this variable is non-zero if at the
===================================================================
@@ -0,0 +1,5 @@
+// PR c++/53055
+// { dg-do compile }
+
+struct A A :: * p ;
+int i = p ->* p ; // { dg-error "" }