This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to resolve_offset_ref
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 05 Dec 2001 16:45:44 +0000
- Subject: C++ PATCH to resolve_offset_ref
This patch fixes a problem with Nathan's earlier fix for PR 3145; when
converting to a base class in order to access one of its fields, the
conversion should not be affected by access control, or access/using
declarations would be meaningless.
Test in g++.dg/inherit/access1.C.
Tested i686-pc-linux-gnu.
2001-12-04 Jason Merrill <jason@redhat.com>
* init.c (resolve_offset_ref): Don't check access for the base
conversion to access a FIELD_DECL.
*** ./gcc/cp/init.c.~1~ Mon Dec 3 02:44:39 2001
--- ./gcc/cp/init.c Tue Dec 4 13:46:34 2001
*************** resolve_offset_ref (exp)
*** 1830,1838 ****
if (TREE_CODE (exp) == OFFSET_REF && TREE_CODE (type) == OFFSET_TYPE)
base = build_scoped_ref (base, TYPE_OFFSET_BASETYPE (type));
! basetype = lookup_base (TREE_TYPE (base), basetype, ba_check, NULL);
expr = build_base_path (PLUS_EXPR, base, basetype, 1);
!
if (expr == error_mark_node)
return error_mark_node;
--- 1830,1841 ----
if (TREE_CODE (exp) == OFFSET_REF && TREE_CODE (type) == OFFSET_TYPE)
base = build_scoped_ref (base, TYPE_OFFSET_BASETYPE (type));
! /* Don't check access on the conversion; we might be after a member
! promoted by an access- or using-declaration, and we have already
! checked access for the member itself. */
! basetype = lookup_base (TREE_TYPE (base), basetype, ba_ignore, NULL);
expr = build_base_path (PLUS_EXPR, base, basetype, 1);
!
if (expr == error_mark_node)
return error_mark_node;