Commit 8d245821 by Mark Mitchell Committed by Mark Mitchell

call.c (build_scoped_method_call): Use convert_to_void.

	* call.c (build_scoped_method_call): Use convert_to_void.
	(build_method_call): Likewise.
	* class.c (check_field_decls): Remove dead code.
	* cvt.c (convert_from_reference): Remove OFFSET_TYPE handling.
	* decl2.c (grok_array_decl): Remove dead code.
	(arg_assoc_type): Avoid relying on POINTER_TYPE over OFFSET_TYPE
	as pointer-to-member representation.
	* init.c (build_offset_ref): Tidy.
	(build_vec_delete_1): Use convert_to_void.
	* mangle.c (write_type): Avoid relying on POINTER_TYPE over OFFSET_TYPE
	as pointer-to-member representation.

From-SVN: r68895
parent ee41cff4
2003-07-03 Mark Mitchell <mark@codesourcery.com>
* call.c (build_scoped_method_call): Use convert_to_void.
(build_method_call): Likewise.
* class.c (check_field_decls): Remove dead code.
* cvt.c (convert_from_reference): Remove OFFSET_TYPE handling.
* decl2.c (grok_array_decl): Remove dead code.
(arg_assoc_type): Avoid relying on POINTER_TYPE over OFFSET_TYPE
as pointer-to-member representation.
* init.c (build_offset_ref): Tidy.
(build_vec_delete_1): Use convert_to_void.
* mangle.c (write_type): Avoid relying on POINTER_TYPE over OFFSET_TYPE
as pointer-to-member representation.
2003-07-03 Nathan Sidwell <nathan@codesourcery.com> 2003-07-03 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9162 PR c++/9162
......
...@@ -263,7 +263,7 @@ build_scoped_method_call (tree exp, tree basetype, tree name, tree parms) ...@@ -263,7 +263,7 @@ build_scoped_method_call (tree exp, tree basetype, tree name, tree parms)
error ("type of `%E' does not match destructor type `%T' (type was `%T')", error ("type of `%E' does not match destructor type `%T' (type was `%T')",
exp, basetype, type); exp, basetype, type);
return cp_convert (void_type_node, exp); return convert_to_void (exp, /*implicit=*/NULL);
} }
} }
...@@ -290,7 +290,7 @@ build_scoped_method_call (tree exp, tree basetype, tree name, tree parms) ...@@ -290,7 +290,7 @@ build_scoped_method_call (tree exp, tree basetype, tree name, tree parms)
if (TREE_CODE (name) == BIT_NOT_EXPR) if (TREE_CODE (name) == BIT_NOT_EXPR)
{ {
if (! TYPE_HAS_DESTRUCTOR (TREE_TYPE (decl))) if (! TYPE_HAS_DESTRUCTOR (TREE_TYPE (decl)))
return cp_convert (void_type_node, exp); return convert_to_void (exp, /*implicit=*/NULL);
return build_delete (TREE_TYPE (decl), decl, return build_delete (TREE_TYPE (decl), decl,
sfk_complete_destructor, sfk_complete_destructor,
...@@ -496,7 +496,7 @@ build_method_call (tree instance, tree name, tree parms, ...@@ -496,7 +496,7 @@ build_method_call (tree instance, tree name, tree parms,
TREE_OPERAND (name, 0), object_type); TREE_OPERAND (name, 0), object_type);
if (! TYPE_HAS_DESTRUCTOR (complete_type (object_type))) if (! TYPE_HAS_DESTRUCTOR (complete_type (object_type)))
return cp_convert (void_type_node, instance); return convert_to_void (instance, /*implicit=*/NULL);
instance = default_conversion (instance); instance = default_conversion (instance);
instance_ptr = build_unary_op (ADDR_EXPR, instance, 0); instance_ptr = build_unary_op (ADDR_EXPR, instance, 0);
return build_delete (build_pointer_type (object_type), return build_delete (build_pointer_type (object_type),
......
...@@ -3091,12 +3091,6 @@ check_field_decls (tree t, tree *access_decls, ...@@ -3091,12 +3091,6 @@ check_field_decls (tree t, tree *access_decls,
type = build_pointer_type (type); type = build_pointer_type (type);
TREE_TYPE (x) = type; TREE_TYPE (x) = type;
} }
else if (TREE_CODE (type) == OFFSET_TYPE)
{
cp_error_at ("field `%D' invalidly declared offset type", x);
type = build_pointer_type (type);
TREE_TYPE (x) = type;
}
if (type == error_mark_node) if (type == error_mark_node)
continue; continue;
......
...@@ -552,11 +552,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, ...@@ -552,11 +552,7 @@ convert_to_reference (tree reftype, tree expr, int convtype,
tree tree
convert_from_reference (tree val) convert_from_reference (tree val)
{ {
tree type = TREE_TYPE (val); if (TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE)
if (TREE_CODE (type) == OFFSET_TYPE)
type = TREE_TYPE (type);
if (TREE_CODE (type) == REFERENCE_TYPE)
return build_indirect_ref (val, NULL); return build_indirect_ref (val, NULL);
return val; return val;
} }
......
...@@ -407,16 +407,9 @@ grok_array_decl (tree array_expr, tree index_exp) ...@@ -407,16 +407,9 @@ grok_array_decl (tree array_expr, tree index_exp)
return build_min (ARRAY_REF, type ? TREE_TYPE (type) : NULL_TREE, return build_min (ARRAY_REF, type ? TREE_TYPE (type) : NULL_TREE,
array_expr, index_exp); array_expr, index_exp);
if (type == NULL_TREE) my_friendly_assert (type, 20030626);
{
/* Something has gone very wrong. Assume we are mistakenly reducing
an expression instead of a declaration. */
error ("parser may be lost: is there a '{' missing somewhere?");
return NULL_TREE;
}
if (TREE_CODE (type) == OFFSET_TYPE if (TREE_CODE (type) == REFERENCE_TYPE)
|| TREE_CODE (type) == REFERENCE_TYPE)
type = TREE_TYPE (type); type = TREE_TYPE (type);
/* If they have an `operator[]', use that. */ /* If they have an `operator[]', use that. */
...@@ -4069,8 +4062,15 @@ arg_assoc_type (struct arg_lookup *k, tree type) ...@@ -4069,8 +4062,15 @@ arg_assoc_type (struct arg_lookup *k, tree type)
right, we can end up with such things without a type. */ right, we can end up with such things without a type. */
if (!type) if (!type)
return false; return false;
switch (TREE_CODE (type)) if (TYPE_PTRMEM_P (type))
{
/* Pointer to member: associate class type and value type. */
if (arg_assoc_type (k, TYPE_PTRMEM_CLASS_TYPE (type)))
return true;
return arg_assoc_type (k, TYPE_PTRMEM_POINTED_TO_TYPE (type));
}
else switch (TREE_CODE (type))
{ {
case ERROR_MARK: case ERROR_MARK:
return false; return false;
...@@ -4093,11 +4093,6 @@ arg_assoc_type (struct arg_lookup *k, tree type) ...@@ -4093,11 +4093,6 @@ arg_assoc_type (struct arg_lookup *k, tree type)
case UNION_TYPE: case UNION_TYPE:
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
return arg_assoc_namespace (k, decl_namespace (TYPE_MAIN_DECL (type))); return arg_assoc_namespace (k, decl_namespace (TYPE_MAIN_DECL (type)));
case OFFSET_TYPE:
/* Pointer to member: associate class type and value type. */
if (arg_assoc_type (k, TYPE_OFFSET_BASETYPE (type)))
return true;
return arg_assoc_type (k, TREE_TYPE (type));
case METHOD_TYPE: case METHOD_TYPE:
/* The basetype is referenced in the first arg type, so just /* The basetype is referenced in the first arg type, so just
fall through. */ fall through. */
......
...@@ -1501,7 +1501,7 @@ build_member_call (tree type, tree name, tree parmlist) ...@@ -1501,7 +1501,7 @@ build_member_call (tree type, tree name, tree parmlist)
tree tree
build_offset_ref (tree type, tree name) build_offset_ref (tree type, tree name)
{ {
tree decl, t = error_mark_node; tree decl;
tree member; tree member;
tree basebinfo = NULL_TREE; tree basebinfo = NULL_TREE;
tree orig_name = name; tree orig_name = name;
...@@ -1546,7 +1546,7 @@ build_offset_ref (tree type, tree name) ...@@ -1546,7 +1546,7 @@ build_offset_ref (tree type, tree name)
/* Handle namespace names fully here. */ /* Handle namespace names fully here. */
if (TREE_CODE (type) == NAMESPACE_DECL) if (TREE_CODE (type) == NAMESPACE_DECL)
{ {
t = lookup_namespace_name (type, name); tree t = lookup_namespace_name (type, name);
if (t == error_mark_node) if (t == error_mark_node)
return t; return t;
if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR) if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
...@@ -1597,7 +1597,7 @@ build_offset_ref (tree type, tree name) ...@@ -1597,7 +1597,7 @@ build_offset_ref (tree type, tree name)
{ {
/* Go from the TREE_BASELINK to the member function info. */ /* Go from the TREE_BASELINK to the member function info. */
tree fnfields = member; tree fnfields = member;
t = BASELINK_FUNCTIONS (fnfields); tree t = BASELINK_FUNCTIONS (fnfields);
if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR) if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
{ {
...@@ -1644,44 +1644,43 @@ build_offset_ref (tree type, tree name) ...@@ -1644,44 +1644,43 @@ build_offset_ref (tree type, tree name)
return t; return t;
} }
t = member; if (member == NULL_TREE)
if (t == NULL_TREE)
{ {
error ("`%D' is not a member of type `%T'", name, type); error ("`%D' is not a member of type `%T'", name, type);
return error_mark_node; return error_mark_node;
} }
if (TREE_CODE (t) == TYPE_DECL) if (TREE_CODE (member) == TYPE_DECL)
{ {
TREE_USED (t) = 1; TREE_USED (member) = 1;
return t; return member;
} }
/* static class members and class-specific enum /* static class members and class-specific enum
values can be returned without further ado. */ values can be returned without further ado. */
if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == CONST_DECL) if (TREE_CODE (member) == VAR_DECL || TREE_CODE (member) == CONST_DECL)
{ {
mark_used (t); mark_used (member);
return convert_from_reference (t); return convert_from_reference (member);
} }
if (TREE_CODE (t) == FIELD_DECL && DECL_C_BIT_FIELD (t)) if (TREE_CODE (member) == FIELD_DECL && DECL_C_BIT_FIELD (member))
{ {
error ("invalid pointer to bit-field `%D'", t); error ("invalid pointer to bit-field `%D'", member);
return error_mark_node; return error_mark_node;
} }
/* static class functions too. */ /* static class functions too. */
if (TREE_CODE (t) == FUNCTION_DECL if (TREE_CODE (member) == FUNCTION_DECL
&& TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) && TREE_CODE (TREE_TYPE (member)) == FUNCTION_TYPE)
abort (); abort ();
/* In member functions, the form `type::name' is no longer /* In member functions, the form `type::name' is no longer
equivalent to `this->type::name', at least not until equivalent to `this->type::name', at least not until
resolve_offset_ref. */ resolve_offset_ref. */
t = build (OFFSET_REF, build_offset_type (type, TREE_TYPE (t)), decl, t); member = build (OFFSET_REF, build_offset_type (type, TREE_TYPE (member)),
PTRMEM_OK_P (t) = 1; decl, member);
return t; PTRMEM_OK_P (member) = 1;
return member;
} }
/* If a OFFSET_REF made it through to here, then it did /* If a OFFSET_REF made it through to here, then it did
...@@ -2625,7 +2624,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, ...@@ -2625,7 +2624,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
/* Pre-evaluate the SAVE_EXPR outside of the BIND_EXPR. */ /* Pre-evaluate the SAVE_EXPR outside of the BIND_EXPR. */
body = build (COMPOUND_EXPR, void_type_node, base, body); body = build (COMPOUND_EXPR, void_type_node, base, body);
return cp_convert (void_type_node, body); return convert_to_void (body, /*implicit=*/NULL);
} }
/* Create an unnamed variable of the indicated TYPE. */ /* Create an unnamed variable of the indicated TYPE. */
......
...@@ -1441,7 +1441,9 @@ write_type (tree type) ...@@ -1441,7 +1441,9 @@ write_type (tree type)
/* See through any typedefs. */ /* See through any typedefs. */
type = TYPE_MAIN_VARIANT (type); type = TYPE_MAIN_VARIANT (type);
switch (TREE_CODE (type)) if (TYPE_PTRMEM_P (type))
write_pointer_to_member_type (type);
else switch (TREE_CODE (type))
{ {
case VOID_TYPE: case VOID_TYPE:
case BOOLEAN_TYPE: case BOOLEAN_TYPE:
...@@ -1483,15 +1485,8 @@ write_type (tree type) ...@@ -1483,15 +1485,8 @@ write_type (tree type)
break; break;
case POINTER_TYPE: case POINTER_TYPE:
/* A pointer-to-member variable is represented by a POINTER_TYPE write_char ('P');
to an OFFSET_TYPE, so check for this first. */ write_type (TREE_TYPE (type));
if (TYPE_PTRMEM_P (type))
write_pointer_to_member_type (type);
else
{
write_char ('P');
write_type (TREE_TYPE (type));
}
break; break;
case REFERENCE_TYPE: case REFERENCE_TYPE:
...@@ -1514,10 +1509,6 @@ write_type (tree type) ...@@ -1514,10 +1509,6 @@ write_type (tree type)
(TI_ARGS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (type))); (TI_ARGS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (type)));
break; break;
case OFFSET_TYPE:
write_pointer_to_member_type (build_pointer_type (type));
break;
case VECTOR_TYPE: case VECTOR_TYPE:
write_string ("U8__vector"); write_string ("U8__vector");
write_type (TREE_TYPE (type)); write_type (TREE_TYPE (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