aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>1998-09-03 20:17:16 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-09-03 20:17:16 +0000
commit5bb1b56949670af2cbbdc4b6d769978515a979cb (patch)
tree28e2aedc4e9b35486b54be81eba8c1f68016e8eb
parentc6a54ad592ca215acc85adff4d616d91c0e7be63 (diff)
downloadgcc-5bb1b56949670af2cbbdc4b6d769978515a979cb.zip
gcc-5bb1b56949670af2cbbdc4b6d769978515a979cb.tar.gz
gcc-5bb1b56949670af2cbbdc4b6d769978515a979cb.tar.bz2
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
-rw-r--r--gcc/cp/init.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index e96f7e5..0c15675 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1798,7 +1798,9 @@ resolve_offset_ref (exp)
|| (TREE_CODE (base) == NOP_EXPR
&& 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)
basetype = TYPE_OFFSET_BASETYPE (type);
@@ -1816,22 +1818,23 @@ resolve_offset_ref (exp)
convert_pointer_to will bash it. */
access = compute_access (basetype_path, member);
addr = convert_pointer_to (basetype, base);
- if (access == access_public_node)
- return build (COMPONENT_REF, TREE_TYPE (member),
- build_indirect_ref (addr, NULL_PTR), member);
- 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)
+
+ /* Issue errors if there was an access violation. */
+ if (access != access_public_node)
{
- cp_error_at ("member `%D' is private", member);
- error ("in this context");
- return error_mark_node;
- }
- my_friendly_abort (55);
+ cp_error_at ("member `%D' is %s",
+ access == access_private_node
+ ? "private" : "protected",
+ member);
+ cp_error ("in this context");
+ }
+
+ /* 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. */
@@ -1839,13 +1842,11 @@ resolve_offset_ref (exp)
&& TREE_OPERAND (base, 0) == error_mark_node)
addr = error_mark_node;
else
- {
- /* If this is a reference to a member function, then return the
- address of the member function (which may involve going
- through the object's vtable), otherwise, return an expression
- for the dereferenced pointer-to-member construct. */
- addr = build_unary_op (ADDR_EXPR, base, 0);
- }
+ /* If this is a reference to a member function, then return the
+ address of the member function (which may involve going
+ through the object's vtable), otherwise, return an expression
+ for the dereferenced pointer-to-member construct. */
+ addr = build_unary_op (ADDR_EXPR, base, 0);
if (TREE_CODE (TREE_TYPE (member)) == OFFSET_TYPE)
{