* 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
+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>
PR c++/9162
error ("type of `%E' does not match destructor type `%T' (type was `%T')",
exp, basetype, type);
- return cp_convert (void_type_node, exp);
+ return convert_to_void (exp, /*implicit=*/NULL);
}
}
if (TREE_CODE (name) == BIT_NOT_EXPR)
{
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,
sfk_complete_destructor,
TREE_OPERAND (name, 0), 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_ptr = build_unary_op (ADDR_EXPR, instance, 0);
return build_delete (build_pointer_type (object_type),
type = build_pointer_type (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)
continue;
tree
convert_from_reference (tree val)
{
- tree type = TREE_TYPE (val);
-
- if (TREE_CODE (type) == OFFSET_TYPE)
- type = TREE_TYPE (type);
- if (TREE_CODE (type) == REFERENCE_TYPE)
+ if (TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE)
return build_indirect_ref (val, NULL);
return val;
}
return build_min (ARRAY_REF, type ? TREE_TYPE (type) : NULL_TREE,
array_expr, index_exp);
- if (type == NULL_TREE)
- {
- /* 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;
- }
+ my_friendly_assert (type, 20030626);
- if (TREE_CODE (type) == OFFSET_TYPE
- || TREE_CODE (type) == REFERENCE_TYPE)
+ if (TREE_CODE (type) == REFERENCE_TYPE)
type = TREE_TYPE (type);
/* If they have an `operator[]', use that. */
right, we can end up with such things without a type. */
if (!type)
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:
return false;
case UNION_TYPE:
case ENUMERAL_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:
/* The basetype is referenced in the first arg type, so just
fall through. */
tree
build_offset_ref (tree type, tree name)
{
- tree decl, t = error_mark_node;
+ tree decl;
tree member;
tree basebinfo = NULL_TREE;
tree orig_name = name;
/* Handle namespace names fully here. */
if (TREE_CODE (type) == NAMESPACE_DECL)
{
- t = lookup_namespace_name (type, name);
+ tree t = lookup_namespace_name (type, name);
if (t == error_mark_node)
return t;
if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
{
/* Go from the TREE_BASELINK to the member function info. */
tree fnfields = member;
- t = BASELINK_FUNCTIONS (fnfields);
+ tree t = BASELINK_FUNCTIONS (fnfields);
if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
{
return t;
}
- t = member;
-
- if (t == NULL_TREE)
+ if (member == NULL_TREE)
{
error ("`%D' is not a member of type `%T'", name, type);
return error_mark_node;
}
- if (TREE_CODE (t) == TYPE_DECL)
+ if (TREE_CODE (member) == TYPE_DECL)
{
- TREE_USED (t) = 1;
- return t;
+ TREE_USED (member) = 1;
+ return member;
}
/* static class members and class-specific enum
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);
- return convert_from_reference (t);
+ mark_used (member);
+ 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;
}
/* static class functions too. */
- if (TREE_CODE (t) == FUNCTION_DECL
- && TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
+ if (TREE_CODE (member) == FUNCTION_DECL
+ && TREE_CODE (TREE_TYPE (member)) == FUNCTION_TYPE)
abort ();
/* In member functions, the form `type::name' is no longer
equivalent to `this->type::name', at least not until
resolve_offset_ref. */
- t = build (OFFSET_REF, build_offset_type (type, TREE_TYPE (t)), decl, t);
- PTRMEM_OK_P (t) = 1;
- return t;
+ member = build (OFFSET_REF, build_offset_type (type, TREE_TYPE (member)),
+ decl, member);
+ PTRMEM_OK_P (member) = 1;
+ return member;
}
/* If a OFFSET_REF made it through to here, then it did
/* Pre-evaluate the SAVE_EXPR outside of the BIND_EXPR. */
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. */
/* See through any typedefs. */
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 BOOLEAN_TYPE:
break;
case POINTER_TYPE:
- /* A pointer-to-member variable is represented by a POINTER_TYPE
- to an OFFSET_TYPE, so check for this first. */
- if (TYPE_PTRMEM_P (type))
- write_pointer_to_member_type (type);
- else
- {
- write_char ('P');
- write_type (TREE_TYPE (type));
- }
+ write_char ('P');
+ write_type (TREE_TYPE (type));
break;
case REFERENCE_TYPE:
(TI_ARGS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (type)));
break;
- case OFFSET_TYPE:
- write_pointer_to_member_type (build_pointer_type (type));
- break;
-
case VECTOR_TYPE:
write_string ("U8__vector");
write_type (TREE_TYPE (type));