aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2000-02-27 21:39:40 +0000
committerRichard Kenner <kenner@gcc.gnu.org>2000-02-27 16:39:40 -0500
commitfed3cef0dbbd17e3d7b8860f42cd8490f0325340 (patch)
treeda73c398c9c03435ecc0d3821031b7c0fe89911d /gcc/cp
parent43931371e2321b6c50c3e0b9095d46606ec48ce1 (diff)
downloadgcc-fed3cef0dbbd17e3d7b8860f42cd8490f0325340.zip
gcc-fed3cef0dbbd17e3d7b8860f42cd8490f0325340.tar.gz
gcc-fed3cef0dbbd17e3d7b8860f42cd8490f0325340.tar.bz2
builtins.c (c_strlen): Use size_diffop and return ssizetype value.
* builtins.c (c_strlen): Use size_diffop and return ssizetype value. (expand_builtin_strcpy): Pass correct type to size_binop. (expand_builtin_strcmp): Likewise. Clean up conditional structure. * c-decl.c (init_decl_processing): Don't call set_sizetype twice. (complete_array_type): Don't use size_binop for MAXINDEX. * c-typeck.c (c_sizeof): Use size_one_node and TYPE_SIZE_UNIT. (c_sizeof_nowarn, c_size_in_bytes): Likewise. (c_alignof): Use size_one_node. (build_unary_op): Pass arg of proper type to size_binop. (really_start_incremental_init, push_init_level): Use sizetype for constructor{,_bit,_unfilled}_index. (pop_init_label, output_init_element): Likewise. (output_pending_init_elements, process_init_element): Likewise. * calls.c (compute_argument_block_size): Field VAR is ssizetype. * expr.c (store_expr): Use size_int. (store_constructor): Use proper types for size_binop args. (get_inner_reference, expand_expr, case ARRAY_REF): Likewise. (expand_expr_unaligned): Likewise. (string_contant): Return object of sizetype. * expr.h (SUB_PARM_SIZE): Call size_diffop and pass proper types. (ARGS_SIZE_RTX): Call ARGS_SIZE_TREE. (ARGS_SIZE_TREE): Pass proper types to size_binop. * fold-const.c (int_const_binop): Refine when size_int is called. (fold_convert): Likewise. (size_int_wide): Rework to take KIND as arg, only take low order bits, handle new sizetype_tab datatype, and chain entries in size_table. (size_int_type_wide): New function. (size_binop): Validate types of arguments. (ssize_binop): Deleted. (size_diffop): New function. (extract_muldiv): Only fold division into multiplication for sizetypes. * function.c (assign_parms): Use size_diffop and make sure VAR field is of ssizetype; also pass proper type to size_binop. (locate_and_pad_parm, pad_to_arg_alignment): Likewise. (round_down): Deleted from here. * store-layout.c (sizetype_tab): Now an array. (sizetype_set, early_root_list): New variables. (variable_size): Use size_one_node. (round_up): Pass proper type to size_binop. (round_down): Moved to here and corrected as above. (layout_record): Pass proper arg types to size_binop. (layout_type): Likewise. If sizetype_set is zero, record the type just laid out. (make_unsigned_type): Don't call set_sizetype; (make_signed_type): Likewise; also, call fixup_signed_type. (initialize_sizetypes): New function. (set_sizetype): Make copy of types, set TYPE_IS_SIZETYPE, and set name of bitsizetype to "bit_size_type". Fix up type of sizes of all types made before call. * tm.texi (ROUND_TYPE_SIZE_UNIT): New macro. * tree.c (fix_sizetype): Deleted. (build_common_tree_nodes): Call initialize_sizetypes. (build_common_tree_nodes_2): Don't call fix_sizetype. * tree.h (TYPE_IS_SIZETYPE): New macro. (initialize_sizetype): New declaration. (enum size_type_kind): New type. (struct sizetype_tab): Deleted. (sizetype_tab): Now array; adjust sizetype macros. (size_diffop, size_int_type_wide): New functions. (size_int_wide): Change number of args and type; access macros changed. (ssize_int, sbitsize_int): New macros. * config/i960/i960.h (ROUND_TYPE_SIZE): Use size_int. (ROUND_TYPE_SIZE_UNIT): New macro. * ch/actions.c (chill_convert_for_assignment): Don't use size_binop for things that aren't sizes. (expand_varying_length_assignment): Likewise. * ch/convert.c (digest_array_tuple, convert): Likewise. * ch/typeck.c (build_chill_slice, smash_dummy_type): Likewise. (build_chill_slice_with_range): Likewise. (build_chill_slice_with_length): Likewise. (build_array_from_set): Adjust types for size_binop. * ch/expr.c (build_concat_expr, build_chill_repetition_op): Likewise. (build_chill_sizeof): Use TYPE_SIZE_UNIT. * ch/tree.c (build_string_type): Pass proper type to size_binop. * cp/class.c (dfs_build_vtable_offset_vtbl_entries): Don't use size_binop on things that are not sizes; ssize_binop deleted. Call size_diffop when appropriate. (dfs_build_vcall_offset_vtbl_entries): Likewise. (build_primary_vtable, build_secondary_vtable): Likewise. (dfs_set_offset_for_unshared_vbases, dfs_modify_vtables): Likewise. Variable I is HOST_WIDE_INT. (get_vfield_offset): Pass proper types to size_binop. (size_extra_vtbl_entries, layout_virtual_bases): Likewise. (finish_struct_1): Likewise. (skip_rtti_stuff): Arg N is now pointer to signed. (layout_class_type): Use size_zero_node. * cp/cp-tree.h (skip_rtti_stuff): Arg N is pointer to signed. * cp/cvt.c (cp_convert_to_pointer): Pass proper types to size_binop. * cp/decl.c (complete_arry_type): Pass proper types to size_binop. (xref_basetypes): BINFO_OFFSET is sizetype. * cp/error.c (dump_expr): Don't use size_binop non-sizes. * cp/expr.c (cplus_expand_constant): Pass proper types to size_binop. * cp/init.c (construct_virtual_bases): Fix type error. (build_vec_delete_1): Pass proper type to size_binop and don't fold result. * cp/lex.c (cp_make_lang_type): BINFO_OFFSET is sizetype. * cp/rtti.c (get_base_offset): Pass proper type to size_binop. * cp/search.c (dfs_find_vbases): Fix type error. (expand_upcast_fixups): Arg to skip_rtti_stuff is pointer to signed. (dfs_get_vbase_types): BINFO_OFFSET is sizetype. * cp/tree.c (debug_binfo): Variable N is signed. Use HOST_WIDE_INT_PRINT_DEC. * cp/typeck.c (comptypes): sizetype is same as equivalent integer type. (c_sizeof, c_sizeof_nowarn, expr_sizeof): Use TYPE_SIZE_UNIT, size_one_node and size_zero_node. (c_alignof): Use size_one_node. (build_component_addr): Pass proper types to size_binop. (expand_ptrmemfunc_cst): Don't use size_binop on non-sizes. * f/com.c (ffecom_arrayref_): Convert args to size_binop to proper type. (ffecom_tree_canonize_ptr_): Don't use size_binop for non-sizes. (ffecom_tree_canonize_ref_): Likewise. (type_for_mode): Handle TImode. * f/ste.c (ffeste_io_dofio_, ffeste_io_douio_): Use TYPE_SIZE_UNIT. (ffeste_io_ciclist_): Likewise. * java/expr.c (build_java_ret): Pass proper type to size_binop. From-SVN: r32225
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog37
-rw-r--r--gcc/cp/class.c113
-rw-r--r--gcc/cp/cp-tree.h3
-rw-r--r--gcc/cp/cvt.c3
-rw-r--r--gcc/cp/decl.c7
-rw-r--r--gcc/cp/error.c6
-rw-r--r--gcc/cp/expr.c5
-rw-r--r--gcc/cp/init.c8
-rw-r--r--gcc/cp/lex.c2
-rw-r--r--gcc/cp/rtti.c6
-rw-r--r--gcc/cp/search.c11
-rw-r--r--gcc/cp/tree.c14
-rw-r--r--gcc/cp/typeck.c84
13 files changed, 170 insertions, 129 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f5c9bcf..14ba119 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,40 @@
+Sun Feb 27 16:40:33 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
+
+ * class.c (dfs_build_vtable_offset_vtbl_entries): Don't use size_binop
+ on things that are not sizes; ssize_binop deleted.
+ Call size_diffop when appropriate.
+ (dfs_build_vcall_offset_vtbl_entries): Likewise.
+ (build_primary_vtable, build_secondary_vtable): Likewise.
+ (dfs_set_offset_for_unshared_vbases, dfs_modify_vtables): Likewise.
+ Variable I is HOST_WIDE_INT.
+ (get_vfield_offset): Pass proper types to size_binop.
+ (size_extra_vtbl_entries, layout_virtual_bases): Likewise.
+ (finish_struct_1): Likewise.
+ (skip_rtti_stuff): Arg N is now pointer to signed.
+ (layout_class_type): Use size_zero_node.
+ * cp-tree.h (skip_rtti_stuff): Arg N is pointer to signed.
+ * cvt.c (cp_convert_to_pointer): Pass proper types to size_binop.
+ * decl.c (complete_arry_type): Pass proper types to size_binop.
+ (xref_basetypes): BINFO_OFFSET is sizetype.
+ * error.c (dump_expr): Don't use size_binop non-sizes.
+ * expr.c (cplus_expand_constant): Pass proper types to size_binop.
+ * init.c (construct_virtual_bases): Fix type error.
+ (build_vec_delete_1): Pass proper type to size_binop and don't
+ fold result.
+ * lex.c (cp_make_lang_type): BINFO_OFFSET is sizetype.
+ * rtti.c (get_base_offset): Pass proper type to size_binop.
+ * search.c (dfs_find_vbases): Fix type error.
+ (expand_upcast_fixups): Arg to skip_rtti_stuff is pointer to signed.
+ (dfs_get_vbase_types): BINFO_OFFSET is sizetype.
+ * tree.c (debug_binfo): Variable N is signed.
+ Use HOST_WIDE_INT_PRINT_DEC.
+ * typeck.c (comptypes): sizetype is same as equivalent integer type.
+ (c_sizeof, c_sizeof_nowarn, expr_sizeof): Use TYPE_SIZE_UNIT,
+ size_one_node and size_zero_node.
+ (c_alignof): Use size_one_node.
+ (build_component_addr): Pass proper types to size_binop.
+ (expand_ptrmemfunc_cst): Don't use size_binop on non-sizes.
+
2000-02-26 Jason Merrill <jason@casey.cygnus.com>
Implement class scope using-declarations for functions.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index d186027..5b0ab16 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -274,17 +274,16 @@ dfs_build_vbase_offset_vtbl_entries (binfo, data)
else
{
BINFO_VPTR_FIELD (vbase) = TREE_PURPOSE (TREE_VALUE (list));
- BINFO_VPTR_FIELD (vbase) = ssize_binop (MINUS_EXPR,
- BINFO_VPTR_FIELD (vbase),
- integer_one_node);
+ BINFO_VPTR_FIELD (vbase)
+ = fold (build (MINUS_EXPR, integer_type_node,
+ BINFO_VPTR_FIELD (vbase), integer_one_node));
}
/* And record the offset at which this virtual base lies in the
vtable. */
init = BINFO_OFFSET (binfo);
TREE_VALUE (list) = tree_cons (BINFO_VPTR_FIELD (vbase),
- init,
- TREE_VALUE (list));
+ init, TREE_VALUE (list));
}
SET_BINFO_VTABLE_PATH_MARKED (binfo);
@@ -338,17 +337,14 @@ build_vbase_offset_vtbl_entries (binfo, t)
object, and we need offsets from this BINFO. */
for (init = inits; init; init = TREE_CHAIN (init))
{
- tree exp = TREE_VALUE (init);
-
- exp = ssize_binop (MINUS_EXPR, exp, BINFO_OFFSET (binfo));
- exp = build1 (NOP_EXPR, vtable_entry_type, exp);
- exp = fold (exp);
- TREE_CONSTANT (exp) = 1;
/* The dfs_build_vbase_offset_vtbl_entries routine uses the
TREE_PURPOSE to scribble in. But, we need to clear it now so
that the values are not perceived as labeled initializers. */
TREE_PURPOSE (init) = NULL_TREE;
- TREE_VALUE (init) = exp;
+ TREE_VALUE (init)
+ = fold (build1 (NOP_EXPR, vtable_entry_type,
+ size_diffop (TREE_VALUE (init),
+ BINFO_OFFSET (binfo))));
}
return inits;
@@ -406,25 +402,19 @@ dfs_build_vcall_offset_vtbl_entries (binfo, data)
virtuals;
virtuals = TREE_CHAIN (virtuals))
{
- tree fn;
- tree base;
- tree base_binfo;
- tree offset;
-
/* Figure out what function we're looking at. */
- fn = TREE_VALUE (virtuals);
- base = DECL_CONTEXT (fn);
-
+ tree fn = TREE_VALUE (virtuals);
+ tree base = DECL_CONTEXT (fn);
/* The FN comes from BASE. So, we must caculate the adjustment
from the virtual base that derived from BINFO to BASE. */
- base_binfo = get_binfo (base, vod->derived, /*protect=*/0);
- offset = ssize_binop (MINUS_EXPR,
- BINFO_OFFSET (base_binfo),
- BINFO_OFFSET (vod->vbase));
- offset = build1 (NOP_EXPR, vtable_entry_type, offset);
- offset = fold (offset);
- TREE_CONSTANT (offset) = 1;
- binfo_inits = tree_cons (NULL_TREE, offset, binfo_inits);
+ tree base_binfo = get_binfo (base, vod->derived, /*protect=*/0);
+
+ binfo_inits
+ = tree_cons (NULL_TREE,
+ fold (build1 (NOP_EXPR, vtable_entry_type,
+ size_diffop (BINFO_OFFSET (base_binfo),
+ BINFO_OFFSET (vod->vbase)))),
+ binfo_inits);
}
/* Now add the initializers we've just created to the list that will
@@ -634,11 +624,10 @@ build_vbase_path (code, type, expr, path, nonnull)
if (changed)
{
tree intype = TREE_TYPE (TREE_TYPE (expr));
+
if (TYPE_MAIN_VARIANT (intype) != BINFO_TYPE (last))
- {
- tree binfo = get_binfo (last, TYPE_MAIN_VARIANT (intype), 0);
- offset = BINFO_OFFSET (binfo);
- }
+ offset
+ = BINFO_OFFSET (get_binfo (last, TYPE_MAIN_VARIANT (intype), 0));
}
else
offset = BINFO_OFFSET (last);
@@ -647,10 +636,6 @@ build_vbase_path (code, type, expr, path, nonnull)
{
/* Bash types to make the backend happy. */
offset = cp_convert (type, offset);
-#if 0
- /* This shouldn't be necessary. (mrs) */
- expr = build1 (NOP_EXPR, type, expr);
-#endif
/* If expr might be 0, we need to preserve that zeroness. */
if (nonnull == 0)
@@ -921,16 +906,18 @@ get_vfield_offset (binfo)
tree tmp
= size_binop (FLOOR_DIV_EXPR,
DECL_FIELD_BITPOS (TYPE_VFIELD (BINFO_TYPE (binfo))),
- size_int (BITS_PER_UNIT));
- tmp = convert (sizetype, tmp);
- return size_binop (PLUS_EXPR, tmp, BINFO_OFFSET (binfo));
+ bitsize_int (BITS_PER_UNIT));
+
+ return size_binop (PLUS_EXPR, convert (sizetype, tmp),
+ BINFO_OFFSET (binfo));
}
/* Get the offset to the start of the original binfo that we derived
this binfo from. If we find TYPE first, return the offset only
that far. The shortened search is useful because the this pointer
on method calling is expected to point to a DECL_CONTEXT (fndecl)
- object, and not a baseclass of it. */
+ object, and not a baseclass of it. */
+
static tree
get_derived_offset (binfo, type)
@@ -939,14 +926,16 @@ get_derived_offset (binfo, type)
tree offset1 = get_vfield_offset (TYPE_BINFO (BINFO_TYPE (binfo)));
tree offset2;
int i;
+
while (BINFO_BASETYPES (binfo)
- && (i=CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo))) != -1)
+ && (i = CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo))) != -1)
{
tree binfos = BINFO_BASETYPES (binfo);
if (BINFO_TYPE (binfo) == type)
break;
binfo = TREE_VEC_ELT (binfos, i);
}
+
offset2 = get_vfield_offset (TYPE_BINFO (BINFO_TYPE (binfo)));
return size_binop (MINUS_EXPR, offset1, offset2);
}
@@ -1085,7 +1074,7 @@ build_primary_vtable (binfo, type)
/* Now do rtti stuff. */
offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE);
- offset = ssize_binop (MINUS_EXPR, integer_zero_node, offset);
+ offset = size_diffop (size_zero_node, offset);
set_rtti_entry (virtuals, offset, type);
}
else
@@ -1175,7 +1164,7 @@ build_secondary_vtable (binfo, for_type)
offset = BINFO_OFFSET (binfo);
set_rtti_entry (BINFO_VIRTUALS (binfo),
- ssize_binop (MINUS_EXPR, integer_zero_node, offset),
+ size_diffop (size_zero_node, offset),
for_type);
/* In the new ABI, secondary vtables are laid out as part of the
@@ -2620,12 +2609,8 @@ tree
size_extra_vtbl_entries (binfo)
tree binfo;
{
- tree offset;
-
- offset = size_binop (EXACT_DIV_EXPR,
- TYPE_SIZE (vtable_entry_type),
- size_int (BITS_PER_UNIT));
- offset = size_binop (MULT_EXPR, offset, num_extra_vtbl_entries (binfo));
+ tree offset = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (vtable_entry_type),
+ num_extra_vtbl_entries (binfo));
return fold (offset);
}
@@ -3039,7 +3024,7 @@ tree
skip_rtti_stuff (binfo, t, n)
tree binfo;
tree t;
- unsigned HOST_WIDE_INT *n;
+ HOST_WIDE_INT *n;
{
tree virtuals;
@@ -3121,7 +3106,7 @@ dfs_modify_vtables (binfo, data)
tree overrider;
tree vindex;
tree delta;
- int i;
+ HOST_WIDE_INT i;
/* Find the function which originally caused this vtable
entry to be present. */
@@ -3151,9 +3136,7 @@ dfs_modify_vtables (binfo, data)
get_derived_offset (binfo,
DECL_VIRTUAL_CONTEXT (fn)),
BINFO_OFFSET (binfo));
- delta = ssize_binop (MINUS_EXPR,
- BINFO_OFFSET (TREE_VALUE (overrider)),
- delta);
+ delta = size_diffop (BINFO_OFFSET (TREE_VALUE (overrider)), delta);
modify_vtable_entry (t,
binfo,
@@ -4568,8 +4551,7 @@ dfs_propagate_binfo_offsets (binfo, data)
tree offset = (tree) data;
/* Update the BINFO_OFFSET for this base. */
- BINFO_OFFSET (binfo)
- = size_binop (PLUS_EXPR, BINFO_OFFSET (binfo), offset);
+ BINFO_OFFSET (binfo) = size_binop (PLUS_EXPR, BINFO_OFFSET (binfo), offset);
SET_BINFO_MARKED (binfo);
@@ -4714,9 +4696,8 @@ dfs_set_offset_for_unshared_vbases (binfo, data)
tree offset;
vbase = BINFO_FOR_VBASE (BINFO_TYPE (binfo), t);
- offset = ssize_binop (MINUS_EXPR,
- BINFO_OFFSET (vbase),
- BINFO_OFFSET (binfo));
+ offset = size_binop (MINUS_EXPR,
+ BINFO_OFFSET (vbase), BINFO_OFFSET (binfo));
propagate_binfo_offsets (binfo, offset);
}
@@ -4789,9 +4770,10 @@ layout_virtual_bases (t)
/* Now, make sure that the total size of the type is a multiple of
its alignment. */
dsize = CEIL (dsize, TYPE_ALIGN (t)) * TYPE_ALIGN (t);
- TYPE_SIZE (t) = size_int (dsize);
- TYPE_SIZE_UNIT (t) = size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (t),
- size_int (BITS_PER_UNIT));
+ TYPE_SIZE (t) = bitsize_int (dsize);
+ TYPE_SIZE_UNIT (t) = convert (sizetype,
+ size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (t),
+ bitsize_int (BITS_PER_UNIT)));
}
/* Finish the work of layout_record, now taking virtual bases into account.
@@ -4915,7 +4897,7 @@ layout_class_type (t, empty_p, has_virtual_p,
if (*empty_p && flag_new_abi)
{
CLASSTYPE_SIZE (t) = bitsize_int (0);
- CLASSTYPE_SIZE_UNIT (t) = size_int (0);
+ CLASSTYPE_SIZE_UNIT (t) = size_zero_node;
}
else if (flag_new_abi && TYPE_HAS_COMPLEX_INIT_REF (t)
&& TYPE_HAS_COMPLEX_ASSIGN_REF (t))
@@ -5026,13 +5008,14 @@ finish_struct_1 (t)
&& DECL_FIELD_CONTEXT (vfield) != t)
{
tree binfo = get_binfo (DECL_FIELD_CONTEXT (vfield), t, 0);
- tree offset = BINFO_OFFSET (binfo);
+ tree offset = convert (bitsizetype, BINFO_OFFSET (binfo));
vfield = copy_node (vfield);
copy_lang_decl (vfield);
if (! integer_zerop (offset))
- offset = size_binop (MULT_EXPR, offset, size_int (BITS_PER_UNIT));
+ offset = size_binop (MULT_EXPR, offset, bitsize_int (BITS_PER_UNIT));
+
DECL_FIELD_CONTEXT (vfield) = t;
DECL_FIELD_BITPOS (vfield)
= size_binop (PLUS_EXPR, offset, DECL_FIELD_BITPOS (vfield));
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index f320918..c1ae4d2 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3618,7 +3618,8 @@ extern void push_lang_context PARAMS ((tree));
extern void pop_lang_context PARAMS ((void));
extern tree instantiate_type PARAMS ((tree, tree, int));
extern void print_class_statistics PARAMS ((void));
-extern tree skip_rtti_stuff PARAMS ((tree, tree, unsigned HOST_WIDE_INT *));
+extern tree skip_rtti_stuff PARAMS ((tree, tree,
+ HOST_WIDE_INT *));
extern void build_self_reference PARAMS ((void));
extern void warn_hidden PARAMS ((tree));
extern tree get_enclosing_class PARAMS ((tree));
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 6902232..9743f37 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -211,7 +211,8 @@ cp_convert_to_pointer (type, expr)
expr = cplus_expand_constant (expr);
if (binfo && ! TREE_VIA_VIRTUAL (binfo))
- expr = size_binop (code, expr, BINFO_OFFSET (binfo));
+ expr = size_binop (code, convert (sizetype,expr),
+ BINFO_OFFSET (binfo));
}
else if (TYPE_PTRMEMFUNC_P (type))
{
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index cafe393..548aa82 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8244,13 +8244,14 @@ complete_array_type (type, initial_value, do_default)
else if (TREE_CODE (initial_value) == CONSTRUCTOR)
{
tree elts = CONSTRUCTOR_ELTS (initial_value);
- maxindex = size_binop (MINUS_EXPR, integer_zero_node, size_one_node);
+
+ maxindex = ssize_int (-1);
for (; elts; elts = TREE_CHAIN (elts))
{
if (TREE_PURPOSE (elts))
maxindex = TREE_PURPOSE (elts);
else
- maxindex = size_binop (PLUS_EXPR, maxindex, size_one_node);
+ maxindex = size_binop (PLUS_EXPR, maxindex, ssize_int (1));
}
maxindex = copy_node (maxindex);
}
@@ -12481,7 +12482,7 @@ xref_basetypes (code_type_node, name, ref, binfo)
the `accessibility' of that particular inheritance is.) */
base_binfo
- = make_binfo (integer_zero_node, basetype,
+ = make_binfo (size_zero_node, basetype,
CLASS_TYPE_P (basetype)
? TYPE_BINFO_VTABLE (basetype) : NULL_TREE,
CLASS_TYPE_P (basetype)
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index c15657a..ae6b511 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -2,7 +2,6 @@
This code is non-reentrant.
Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
Free Software Foundation, Inc.
-
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
@@ -1651,8 +1650,9 @@ dump_expr (t, flags)
if (TREE_CODE (type) == ARRAY_REF)
type = build_cplus_array_type
(TREE_OPERAND (type, 0),
- build_index_type (size_binop (MINUS_EXPR, TREE_OPERAND (type, 1),
- integer_one_node)));
+ build_index_type (fold (build (MINUS_EXPR, integer_type_node,
+ TREE_OPERAND (type, 1),
+ integer_one_node))));
dump_type (type, flags);
if (TREE_OPERAND (t, 2))
{
diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c
index 041a7a0..05411e3 100644
--- a/gcc/cp/expr.c
+++ b/gcc/cp/expr.c
@@ -63,13 +63,12 @@ cplus_expand_constant (cst)
offset = convert (sizetype,
size_binop (EASY_DIV_EXPR,
DECL_FIELD_BITPOS (member),
- size_int (BITS_PER_UNIT)));
+ bitsize_int (BITS_PER_UNIT)));
/* We offset all pointer to data members by 1 so that we
can distinguish between a null pointer to data member
and the first data member of a structure. */
- offset = size_binop (PLUS_EXPR, offset, size_int (1));
-
+ offset = size_binop (PLUS_EXPR, offset, size_one_node);
cst = cp_convert (type, offset);
}
else
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 69a4e3a..1f2eff4 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -801,7 +801,7 @@ construct_virtual_bases (type, this_ref, this_ptr, init_list, flag)
exp = build (PLUS_EXPR,
TREE_TYPE (this_ptr),
this_ptr,
- BINFO_OFFSET (vbases));
+ fold (build1 (NOP_EXPR, this_ptr, BINFO_OFFSET (vbases))));
exp = build1 (NOP_EXPR,
build_pointer_type (BINFO_TYPE (vbases)),
exp);
@@ -2482,7 +2482,8 @@ build_vec_delete_1 (base, maxindex, type, auto_delete_vec, use_global_delete)
}
/* The below is short by BI_header_size */
- virtual_size = fold (size_binop (MULT_EXPR, size_exp, maxindex));
+ virtual_size = size_binop (MULT_EXPR, size_exp,
+ convert (sizetype, maxindex));
tbase = create_temporary_var (ptype);
tbase_init = build_modify_expr (tbase, NOP_EXPR,
@@ -2525,7 +2526,8 @@ build_vec_delete_1 (base, maxindex, type, auto_delete_vec, use_global_delete)
tree base_tbd;
/* The below is short by BI_header_size */
- virtual_size = fold (size_binop (MULT_EXPR, size_exp, maxindex));
+ virtual_size = size_binop (MULT_EXPR, size_exp,
+ convert (sizetype, maxindex));
if (! TYPE_VEC_NEW_USES_COOKIE (type))
/* no header */
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index f522031..2e5a2e6 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -4792,7 +4792,7 @@ cp_make_lang_type (code)
canonical binfo for them. Ideally, this would be done lazily for
all types. */
if (IS_AGGR_TYPE_CODE (code) || code == TEMPLATE_TYPE_PARM)
- TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE);
+ TYPE_BINFO (t) = make_binfo (size_zero_node, t, NULL_TREE, NULL_TREE);
return t;
}
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 0896fe2..cd83081 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -1,6 +1,6 @@
/* RunTime Type Identification
- Copyright (C) 1995, 1996, 1997, 1998,
- 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
+ Free Software Foundation, Inc.
Mostly written by Jason Merrill (jason@cygnus.com).
This file is part of GNU CC.
@@ -559,7 +559,7 @@ get_base_offset (binfo, parent)
field = lookup_field (parent, get_identifier (name), 0, 0);
offset = size_binop (FLOOR_DIV_EXPR,
DECL_FIELD_BITPOS (field),
- size_int (BITS_PER_UNIT));
+ bitsize_int (BITS_PER_UNIT));
offset = convert (sizetype, offset);
}
else
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 4b604eb..1a9b13f 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -1,6 +1,6 @@
/* Breadth-first and depth-first routines for
searching multiple-inheritance lattice for GNU C++.
- Copyright (C) 1987, 89, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
@@ -2704,10 +2704,11 @@ dfs_find_vbases (binfo, data)
{
tree vbase = BINFO_TYPE (base_binfo);
tree binfo = binfo_member (vbase, vi->vbase_types);
+ tree ptr_type = build_pointer_type (vbase);
CLASSTYPE_SEARCH_SLOT (vbase)
- = build (PLUS_EXPR, build_pointer_type (vbase),
- vi->decl_ptr, BINFO_OFFSET (binfo));
+ = build (PLUS_EXPR, ptr_type, vi->decl_ptr,
+ convert (ptr_type, BINFO_OFFSET (binfo)));
}
}
SET_BINFO_VTABLE_PATH_MARKED (binfo);
@@ -2895,7 +2896,7 @@ expand_upcast_fixups (binfo, addr, orig_addr, vbase, vbase_addr, t,
tree virtuals;
tree vc;
tree delta;
- unsigned HOST_WIDE_INT n;
+ HOST_WIDE_INT n;
while (BINFO_PRIMARY_MARKED_P (binfo))
{
@@ -3153,7 +3154,7 @@ dfs_get_vbase_types (binfo, data)
if (TREE_VIA_VIRTUAL (binfo) && ! BINFO_VBASE_MARKED (binfo))
{
- tree new_vbase = make_binfo (integer_zero_node,
+ tree new_vbase = make_binfo (size_zero_node,
BINFO_TYPE (binfo),
BINFO_VTABLE (binfo),
BINFO_VIRTUALS (binfo));
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 6097302..c739db7 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -910,16 +910,18 @@ void
debug_binfo (elem)
tree elem;
{
- unsigned HOST_WIDE_INT n;
+ HOST_WIDE_INT n;
tree virtuals;
- fprintf (stderr, "type \"%s\"; offset = %ld\n",
- TYPE_NAME_STRING (BINFO_TYPE (elem)),
- (long) TREE_INT_CST_LOW (BINFO_OFFSET (elem)));
- fprintf (stderr, "vtable type:\n");
+ fprintf (stderr, "type \"%s\", offset = ",
+ TYPE_NAME_STRING (BINFO_TYPE (elem)));
+ fprintf (stderr, HOST_WIDE_INT_PRINT_DEC,
+ TREE_INT_CST_LOW (BINFO_OFFSET (elem)));
+ fprintf (stderr, "\nvtable type:\n");
debug_tree (BINFO_TYPE (elem));
if (BINFO_VTABLE (elem))
- fprintf (stderr, "vtable decl \"%s\"\n", IDENTIFIER_POINTER (DECL_NAME (BINFO_VTABLE (elem))));
+ fprintf (stderr, "vtable decl \"%s\"\n",
+ IDENTIFIER_POINTER (DECL_NAME (BINFO_VTABLE (elem))));
else
fprintf (stderr, "no vtable decl yet\n");
fprintf (stderr, "virtuals:\n");
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index ae01800..bb2de74 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -934,6 +934,18 @@ comptypes (t1, t2, strict)
if (t2 == error_mark_node)
return 0;
+ /* If this is a strict comparison with a sizetype, the actual types
+ won't be the same (since we need to set TYPE_IS_SIZETYPE, so verify
+ if they are both the same size and signedness. */
+ if (strict == COMPARE_STRICT
+ && TREE_CODE (t2) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t2)
+ && TREE_CODE (t1) == INTEGER_TYPE
+ && TREE_UNSIGNED (t1) == TREE_UNSIGNED (t2)
+ && TYPE_MODE (t1) == TYPE_MODE (t2)
+ && TYPE_MIN_VALUE (t1) == TYPE_MIN_VALUE (t2)
+ && TYPE_MAX_VALUE (t1) == TYPE_MAX_VALUE (t2))
+ return 1;
+
if (strict & COMPARE_RELAXED)
{
/* Treat an enum type as the unsigned integer type of the same width. */
@@ -1539,7 +1551,6 @@ c_sizeof (type)
tree type;
{
enum tree_code code = TREE_CODE (type);
- tree t;
if (processing_template_decl)
return build_min (SIZEOF_EXPR, sizetype, type);
@@ -1548,22 +1559,22 @@ c_sizeof (type)
{
if (pedantic || warn_pointer_arith)
pedwarn ("ISO C++ forbids applying `sizeof' to a function type");
- return size_int (1);
+ return size_one_node;
}
if (code == METHOD_TYPE)
{
if (pedantic || warn_pointer_arith)
pedwarn ("ISO C++ forbids applying `sizeof' to a member function");
- return size_int (1);
+ return size_one_node;
}
if (code == VOID_TYPE)
{
if (pedantic || warn_pointer_arith)
pedwarn ("ISO C++ forbids applying `sizeof' to type `void' which is an incomplete type");
- return size_int (1);
+ return size_one_node;
}
if (code == ERROR_MARK)
- return size_int (1);
+ return size_one_node;
/* ARM $5.3.2: ``When applied to a reference, the result is the size of the
referenced object.'' */
@@ -1573,23 +1584,19 @@ c_sizeof (type)
if (code == OFFSET_TYPE)
{
cp_error ("`sizeof' applied to non-static member");
- return size_int (0);
+ return size_zero_node;
}
if (TYPE_SIZE (complete_type (type)) == 0)
{
cp_error ("`sizeof' applied to incomplete type `%T'", type);
- return size_int (0);
+ return size_zero_node;
}
/* Convert in case a char is more than one unit. */
- t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type),
- size_int (TYPE_PRECISION (char_type_node)));
- t = convert (sizetype, t);
- /* size_binop does not put the constant in range, so do it now. */
- if (TREE_CODE (t) == INTEGER_CST && force_fit_type (t, 0))
- TREE_CONSTANT_OVERFLOW (t) = TREE_OVERFLOW (t) = 1;
- return t;
+ return size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
+ size_int (TYPE_PRECISION (char_type_node)
+ / BITS_PER_UNIT));
}
tree
@@ -1605,12 +1612,12 @@ expr_sizeof (e)
if (is_overloaded_fn (e))
{
pedwarn ("ISO C++ forbids applying `sizeof' to an expression of function type");
- return size_int (1);
+ return size_one_node;
}
else if (type_unknown_p (e))
{
incomplete_type_error (e, TREE_TYPE (e));
- return size_int (1);
+ return size_one_node;
}
/* It's illegal to say `sizeof (X::i)' for `i' a non-static data
member unless you're in a non-static member of X. So hand off to
@@ -1629,25 +1636,23 @@ c_sizeof_nowarn (type)
tree type;
{
enum tree_code code = TREE_CODE (type);
- tree t;
if (code == FUNCTION_TYPE
|| code == METHOD_TYPE
|| code == VOID_TYPE
|| code == ERROR_MARK)
- return size_int (1);
+ return size_one_node;
+
if (code == REFERENCE_TYPE)
type = TREE_TYPE (type);
if (TYPE_SIZE (type) == 0)
- return size_int (0);
+ return size_zero_node;
/* Convert in case a char is more than one unit. */
- t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type),
- size_int (TYPE_PRECISION (char_type_node)));
- t = convert (sizetype, t);
- force_fit_type (t, 0);
- return t;
+ return size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
+ size_int (TYPE_PRECISION (char_type_node)
+ / BITS_PER_UNIT));
}
/* Implement the __alignof keyword: Return the minimum required
@@ -1667,7 +1672,7 @@ c_alignof (type)
return size_int (FUNCTION_BOUNDARY / BITS_PER_UNIT);
if (code == VOID_TYPE || code == ERROR_MARK)
- return size_int (1);
+ return size_one_node;
/* C++: this is really correct! */
if (code == REFERENCE_TYPE)
@@ -4301,7 +4306,7 @@ build_component_addr (arg, argtype)
if (! integer_zerop (DECL_FIELD_BITPOS (field)))
{
tree offset = size_binop (EASY_DIV_EXPR, DECL_FIELD_BITPOS (field),
- size_int (BITS_PER_UNIT));
+ bitsize_int (BITS_PER_UNIT));
int flag = TREE_CONSTANT (rval);
offset = convert (sizetype, offset);
rval = fold (build (PLUS_EXPR, argtype,
@@ -6287,7 +6292,11 @@ build_ptrmemfunc (type, pfn, force)
}
/* Return the DELTA, IDX, PFN, and DELTA2 values for the PTRMEM_CST
- given by CST. */
+ given by CST.
+
+ ??? There is no consistency as to the types returned for the above
+ values. Some code acts as if its a sizetype and some as if its
+ integer_type_node. */
void
expand_ptrmemfunc_cst (cst, delta, idx, pfn, delta2)
@@ -6315,7 +6324,7 @@ expand_ptrmemfunc_cst (cst, delta, idx, pfn, delta2)
if (!DECL_VIRTUAL_P (fn))
{
if (!flag_new_abi)
- *idx = size_binop (MINUS_EXPR, integer_zero_node, integer_one_node);
+ *idx = convert (TYPE_PTRMEMFUNC_FN_TYPE (type), build_int_2 (-1, -1));
else
*idx = NULL_TREE;
*pfn = convert (TYPE_PTRMEMFUNC_FN_TYPE (type), build_addr_func (fn));
@@ -6328,12 +6337,14 @@ expand_ptrmemfunc_cst (cst, delta, idx, pfn, delta2)
fn; the call will do the opposite adjustment. */
tree orig_class = DECL_VIRTUAL_CONTEXT (fn);
tree binfo = binfo_or_else (orig_class, fn_class);
- *delta = size_binop (PLUS_EXPR, *delta, BINFO_OFFSET (binfo));
+ *delta = fold (build (PLUS_EXPR, TREE_TYPE (*delta),
+ *delta, BINFO_OFFSET (binfo)));
if (!flag_new_abi)
{
/* Map everything down one to make room for the null PMF. */
- *idx = size_binop (PLUS_EXPR, DECL_VINDEX (fn), integer_one_node);
+ *idx = fold (build (PLUS_EXPR, integer_type_node,
+ DECL_VINDEX (fn), integer_one_node));
*pfn = NULL_TREE;
}
else
@@ -6341,14 +6352,17 @@ expand_ptrmemfunc_cst (cst, delta, idx, pfn, delta2)
/* Under the new ABI, we set PFN to twice the index, plus
one. */
*idx = NULL_TREE;
- *pfn = size_binop (MULT_EXPR, DECL_VINDEX (fn), integer_two_node);
- *pfn = size_binop (PLUS_EXPR, *pfn, integer_one_node);
- *pfn = build1 (NOP_EXPR, TYPE_PTRMEMFUNC_FN_TYPE (type), *pfn);
+ *pfn = fold (build (MULT_EXPR, integer_type_node,
+ DECL_VINDEX (fn), integer_two_node));
+ *pfn = fold (build (PLUS_EXPR, integer_type_node, *pfn,
+ integer_one_node));
+ *pfn = fold (build1 (NOP_EXPR, TYPE_PTRMEMFUNC_FN_TYPE (type),
+ *pfn));
}
/* Offset from an object of PTR_CLASS to the vptr for ORIG_CLASS. */
- *delta2 = size_binop (PLUS_EXPR, *delta,
- get_vfield_offset (TYPE_BINFO (orig_class)));
+ *delta2 = fold (build (PLUS_EXPR, integer_type_node, *delta,
+ get_vfield_offset (TYPE_BINFO (orig_class))));
}
}