This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
(C++) patch for g++.bugs/900215_02.C
- To: egcs-patches at cygnus dot com
- Subject: (C++) patch for g++.bugs/900215_02.C
- From: Jason Merrill <jason at cygnus dot com>
- Date: Fri, 16 Oct 1998 03:34:32 -0700
Applied. We weren't diagnosing '*ptm'.
1998-10-16 Jason Merrill <jason@yorick.cygnus.com>
* typeck.c (build_indirect_ref): Complain about a pointer to data
member, too.
* typeck2.c (build_m_component_ref): Don't indirect a pointer to
data member.
* init.c (resolve_offset_ref): Don't undo the above.
Index: init.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/init.c,v
retrieving revision 1.68
diff -c -p -r1.68 init.c
*** init.c 1998/10/06 14:19:58 1.68
--- init.c 1998/10/16 10:31:23
*************** resolve_offset_ref (exp)
*** 1740,1746 ****
}
if ((TREE_CODE (member) == VAR_DECL
! && ! TYPE_PTRMEMFUNC_P (TREE_TYPE (member)))
|| TREE_CODE (TREE_TYPE (member)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (member)) == METHOD_TYPE)
{
--- 1740,1747 ----
}
if ((TREE_CODE (member) == VAR_DECL
! && ! TYPE_PTRMEMFUNC_P (TREE_TYPE (member))
! && ! TYPE_PTRMEM_P (TREE_TYPE (member)))
|| TREE_CODE (TREE_TYPE (member)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (member)) == METHOD_TYPE)
{
*************** resolve_offset_ref (exp)
*** 1824,1830 ****
for the dereferenced pointer-to-member construct. */
addr = build_unary_op (ADDR_EXPR, base, 0);
! if (TREE_CODE (TREE_TYPE (member)) == OFFSET_TYPE)
{
if (addr == error_mark_node)
{
--- 1825,1831 ----
for the dereferenced pointer-to-member construct. */
addr = build_unary_op (ADDR_EXPR, base, 0);
! if (TYPE_PTRMEM_P (TREE_TYPE (member)))
{
if (addr == error_mark_node)
{
*************** resolve_offset_ref (exp)
*** 1832,1841 ****
return error_mark_node;
}
! basetype = TYPE_OFFSET_BASETYPE (TREE_TYPE (member));
addr = convert_pointer_to (basetype, addr);
! member = cp_convert (ptrdiff_type_node,
! build_unary_op (ADDR_EXPR, member, 0));
/* Pointer to data members are offset by one, so that a null
pointer with a real value of 0 is distinguishable from an
--- 1833,1841 ----
return error_mark_node;
}
! basetype = TYPE_OFFSET_BASETYPE (TREE_TYPE (TREE_TYPE (member)));
addr = convert_pointer_to (basetype, addr);
! member = cp_convert (ptrdiff_type_node, member);
/* Pointer to data members are offset by one, so that a null
pointer with a real value of 0 is distinguishable from an
Index: typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.115
diff -c -p -r1.115 typeck.c
*** typeck.c 1998/10/08 05:04:57 1.115
--- typeck.c 1998/10/16 10:31:25
*************** build_indirect_ref (ptr, errorstring)
*** 2291,2297 ****
if (ptr == current_class_ptr)
return current_class_ref;
! if (TREE_CODE (type) == POINTER_TYPE || TREE_CODE (type) == REFERENCE_TYPE)
{
/* [expr.unary.op]
--- 2291,2297 ----
if (ptr == current_class_ptr)
return current_class_ref;
! if (TYPE_PTR_P (type) || TREE_CODE (type) == REFERENCE_TYPE)
{
/* [expr.unary.op]
*************** build_indirect_ref (ptr, errorstring)
*** 2326,2333 ****
}
/* `pointer' won't be an error_mark_node if we were given a
pointer to member, so it's cool to check for this here. */
! else if (TYPE_PTRMEMFUNC_P (type))
! error ("invalid use of `%s' on pointer to member function", errorstring);
else if (TREE_CODE (type) == RECORD_TYPE
&& (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type)))
error ("cannot dereference signature pointer/reference");
--- 2326,2333 ----
}
/* `pointer' won't be an error_mark_node if we were given a
pointer to member, so it's cool to check for this here. */
! else if (TYPE_PTRMEM_P (type) || TYPE_PTRMEMFUNC_P (type))
! error ("invalid use of `%s' on pointer to member", errorstring);
else if (TREE_CODE (type) == RECORD_TYPE
&& (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type)))
error ("cannot dereference signature pointer/reference");
Index: typeck2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck2.c,v
retrieving revision 1.32
diff -c -p -r1.32 typeck2.c
*** typeck2.c 1998/10/12 02:08:18 1.32
--- typeck2.c 1998/10/16 10:31:25
*************** build_m_component_ref (datum, component)
*** 1393,1400 ****
}
else
{
! component = build_indirect_ref (component, NULL_PTR);
! type = TREE_TYPE (component);
rettype = TREE_TYPE (type);
}
--- 1393,1399 ----
}
else
{
! type = TREE_TYPE (TREE_TYPE (component));
rettype = TREE_TYPE (type);
}