Commit 5bb1b569 by Mark Mitchell

cp-tree.h (finish_globally_qualified_member_call_expr): Rename to ...

	* cp-tree.h (finish_globally_qualified_member_call_expr):
	Rename to ...
	(finish_qualified_call_expr).
	* semantics.c: Likewise.
	* parse.y (primary): Use it.
	* method.c (hack_identifier): Remove redundant code.
	* init.c (resolve_offset_ref): Call convert_from_reference to
 	handle members of reference type.  Improve error recovery.

From-SVN: r22224
parent c6a54ad5
...@@ -1798,7 +1798,9 @@ resolve_offset_ref (exp) ...@@ -1798,7 +1798,9 @@ resolve_offset_ref (exp)
|| (TREE_CODE (base) == NOP_EXPR || (TREE_CODE (base) == NOP_EXPR
&& TREE_OPERAND (base, 0) == error_mark_node))) && TREE_OPERAND (base, 0) == error_mark_node)))
{ {
tree basetype_path, access; tree basetype_path;
tree access;
tree expr;
if (TREE_CODE (exp) == OFFSET_REF && TREE_CODE (type) == OFFSET_TYPE) if (TREE_CODE (exp) == OFFSET_REF && TREE_CODE (type) == OFFSET_TYPE)
basetype = TYPE_OFFSET_BASETYPE (type); basetype = TYPE_OFFSET_BASETYPE (type);
...@@ -1816,22 +1818,23 @@ resolve_offset_ref (exp) ...@@ -1816,22 +1818,23 @@ resolve_offset_ref (exp)
convert_pointer_to will bash it. */ convert_pointer_to will bash it. */
access = compute_access (basetype_path, member); access = compute_access (basetype_path, member);
addr = convert_pointer_to (basetype, base); addr = convert_pointer_to (basetype, base);
if (access == access_public_node)
return build (COMPONENT_REF, TREE_TYPE (member), /* Issue errors if there was an access violation. */
build_indirect_ref (addr, NULL_PTR), member); if (access != access_public_node)
if (access == access_protected_node)
{
cp_error_at ("member `%D' is protected", member);
error ("in this context");
return error_mark_node;
}
if (access == access_private_node)
{ {
cp_error_at ("member `%D' is private", member); cp_error_at ("member `%D' is %s",
error ("in this context"); access == access_private_node
return error_mark_node; ? "private" : "protected",
member);
cp_error ("in this context");
} }
my_friendly_abort (55);
/* Even in the case of illegal access, we form the
COMPONENT_REF; that will allow better error recovery than
just feeding back error_mark_node. */
expr = build (COMPONENT_REF, TREE_TYPE (member),
build_indirect_ref (addr, NULL_PTR), member);
return convert_from_reference (expr);
} }
/* Ensure that we have an object. */ /* Ensure that we have an object. */
...@@ -1839,13 +1842,11 @@ resolve_offset_ref (exp) ...@@ -1839,13 +1842,11 @@ resolve_offset_ref (exp)
&& TREE_OPERAND (base, 0) == error_mark_node) && TREE_OPERAND (base, 0) == error_mark_node)
addr = error_mark_node; addr = error_mark_node;
else else
{
/* If this is a reference to a member function, then return the /* If this is a reference to a member function, then return the
address of the member function (which may involve going address of the member function (which may involve going
through the object's vtable), otherwise, return an expression through the object's vtable), otherwise, return an expression
for the dereferenced pointer-to-member construct. */ for the dereferenced pointer-to-member construct. */
addr = build_unary_op (ADDR_EXPR, base, 0); addr = build_unary_op (ADDR_EXPR, base, 0);
}
if (TREE_CODE (TREE_TYPE (member)) == OFFSET_TYPE) if (TREE_CODE (TREE_TYPE (member)) == OFFSET_TYPE)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment