aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorSteven Bosscher <steven@gcc.gnu.org>2005-03-24 07:20:42 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2005-03-24 07:20:42 +0000
commit7866705a8b405a8e870973260399950a4349b314 (patch)
tree5e7a25d8aa7a9331ab052a5f2209c65c048a4ef2 /gcc/cp
parent29ae384381fd7b3e8bb465b3345a4b91c9ff4582 (diff)
downloadgcc-7866705a8b405a8e870973260399950a4349b314.zip
gcc-7866705a8b405a8e870973260399950a4349b314.tar.gz
gcc-7866705a8b405a8e870973260399950a4349b314.tar.bz2
typeck.c (comptypes): First determine if the types are compatible from a target-independent point of view.
* typeck.c (comptypes): First determine if the types are compatible from a target-independent point of view. Check target attributes last. * class.c (build_base_path): (build_vbase_offset_vtbl_entries): (add_vcall_offset): Replace fold (buildN (...)) with fold_buildN. * error.c (dump_expr): Likewise. * init.c (build_zero_init, expand_cleanup_for_base, build_vec_delete_1): Likewise. * mangle.c (write_integer_cst): Likewise. * method.c (thunk_adjust): Likewise. * pt.c (convert_nontype_argument, tsubst, unify): Likewise. * tree.c (cxx_print_statistics, array_type_nelts_total): Likewise. * typeck.c (build_ptrmemfunc_access_expr, (get_member_function_from_ptrfunc): Likewise. From-SVN: r96985
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog21
-rw-r--r--gcc/cp/class.c20
-rw-r--r--gcc/cp/error.c6
-rw-r--r--gcc/cp/init.c26
-rw-r--r--gcc/cp/mangle.c8
-rw-r--r--gcc/cp/method.c10
-rw-r--r--gcc/cp/pt.c14
-rw-r--r--gcc/cp/tree.c8
-rw-r--r--gcc/cp/typeck.c78
9 files changed, 113 insertions, 78 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2b3a99b..ae435c1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,22 @@
+2005-03-24 Steven Bosscher <stevenb@suse.de>
+
+ * typeck.c (comptypes): First determine if the types are compatible
+ from a target-independent point of view. Check target attributes
+ last.
+
+ * class.c (build_base_path):
+ (build_vbase_offset_vtbl_entries):
+ (add_vcall_offset): Replace fold (buildN (...)) with fold_buildN.
+ * error.c (dump_expr): Likewise.
+ * init.c (build_zero_init, expand_cleanup_for_base,
+ build_vec_delete_1): Likewise.
+ * mangle.c (write_integer_cst): Likewise.
+ * method.c (thunk_adjust): Likewise.
+ * pt.c (convert_nontype_argument, tsubst, unify): Likewise.
+ * tree.c (cxx_print_statistics, array_type_nelts_total): Likewise.
+ * typeck.c (build_ptrmemfunc_access_expr,
+ (get_member_function_from_ptrfunc): Likewise.
+
2005-03-23 Joseph S. Myers <joseph@codesourcery.com>
* cp-objcp-common.h (LANG_HOOKS_TRUTHVALUE_CONVERSION): Remove.
@@ -290,7 +309,7 @@
Add qualifiers when declaring a typedef of a function type.
Member function pointers pick up the qualifiers of the typedef
used to declare them.
- Don't complain about creating cv-qualified function types.
+ Don't complain about creating cv-qualified function types.
Complain about qualified function typedefs that are used to
declare non-static member functions or free functions.
Use cp_apply_type_quals_to_decl.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 89346d6..c684e81 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -296,8 +296,8 @@ build_base_path (enum tree_code code,
if (null_test)
{
tree zero = cp_convert (TREE_TYPE (expr), integer_zero_node);
- null_test = fold (build2 (NE_EXPR, boolean_type_node,
- expr, zero));
+ null_test = fold_build2 (NE_EXPR, boolean_type_node,
+ expr, zero);
}
/* If this is a simple base reference, express it as a COMPONENT_REF. */
@@ -388,9 +388,9 @@ build_base_path (enum tree_code code,
out:
if (null_test)
- expr = fold (build3 (COND_EXPR, target_type, null_test, expr,
- fold (build1 (NOP_EXPR, target_type,
- integer_zero_node))));
+ expr = fold_build3 (COND_EXPR, target_type, null_test, expr,
+ fold_build1 (NOP_EXPR, target_type,
+ integer_zero_node));
return expr;
}
@@ -7406,9 +7406,9 @@ build_vbase_offset_vtbl_entries (tree binfo, vtbl_init_data* vid)
*vid->last_init
= build_tree_list (NULL_TREE,
- fold (build1 (NOP_EXPR,
- vtable_entry_type,
- delta)));
+ fold_build1 (NOP_EXPR,
+ vtable_entry_type,
+ delta));
vid->last_init = &TREE_CHAIN (*vid->last_init);
}
}
@@ -7633,8 +7633,8 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid)
BINFO_OFFSET from vid->binfo. */
vcall_offset = size_diffop (BINFO_OFFSET (base),
BINFO_OFFSET (vid->binfo));
- vcall_offset = fold (build1 (NOP_EXPR, vtable_entry_type,
- vcall_offset));
+ vcall_offset = fold_build1 (NOP_EXPR, vtable_entry_type,
+ vcall_offset);
}
/* Add the initializer to the vtable. */
*vid->last_init = build_tree_list (NULL_TREE, vcall_offset);
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index c53e032..1748fe0 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1413,9 +1413,9 @@ dump_expr (tree t, int flags)
if (TREE_CODE (type) == ARRAY_REF)
type = build_cplus_array_type
(TREE_OPERAND (type, 0),
- build_index_type (fold (build2 (MINUS_EXPR, integer_type_node,
- TREE_OPERAND (type, 1),
- integer_one_node))));
+ build_index_type (fold_build2 (MINUS_EXPR, integer_type_node,
+ TREE_OPERAND (type, 1),
+ integer_one_node)));
dump_type (type, flags);
if (init)
{
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index ddf39bf..69089fe 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -222,8 +222,8 @@ build_zero_init (tree type, tree nelts, bool static_storage_p)
/* Iterate over the array elements, building initializations. */
inits = NULL_TREE;
if (nelts)
- max_index = fold (build2 (MINUS_EXPR, TREE_TYPE (nelts),
- nelts, integer_one_node));
+ max_index = fold_build2 (MINUS_EXPR, TREE_TYPE (nelts),
+ nelts, integer_one_node);
else
max_index = array_type_nelts (type);
gcc_assert (TREE_CODE (max_index) == INTEGER_CST);
@@ -826,9 +826,9 @@ expand_cleanup_for_base (tree binfo, tree flag)
binfo,
LOOKUP_NORMAL | LOOKUP_NONVIRTUAL);
if (flag)
- expr = fold (build3 (COND_EXPR, void_type_node,
- c_common_truthvalue_conversion (flag),
- expr, integer_zero_node));
+ expr = fold_build3 (COND_EXPR, void_type_node,
+ c_common_truthvalue_conversion (flag),
+ expr, integer_zero_node);
finish_eh_cleanup (expr);
}
@@ -2241,9 +2241,9 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
tbase = create_temporary_var (ptype);
tbase_init = build_modify_expr (tbase, NOP_EXPR,
- fold (build2 (PLUS_EXPR, ptype,
- base,
- virtual_size)));
+ fold_build2 (PLUS_EXPR, ptype,
+ base,
+ virtual_size));
DECL_REGISTER (tbase) = 1;
controller = build3 (BIND_EXPR, void_type_node, tbase,
NULL_TREE, NULL_TREE);
@@ -2308,11 +2308,11 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
body = integer_zero_node;
/* Outermost wrapper: If pointer is null, punt. */
- body = fold (build3 (COND_EXPR, void_type_node,
- fold (build2 (NE_EXPR, boolean_type_node, base,
- convert (TREE_TYPE (base),
- integer_zero_node))),
- body, integer_zero_node));
+ body = fold_build3 (COND_EXPR, void_type_node,
+ fold_build2 (NE_EXPR, boolean_type_node, base,
+ convert (TREE_TYPE (base),
+ integer_zero_node)),
+ body, integer_zero_node);
body = build1 (NOP_EXPR, void_type_node, body);
if (controller)
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 1d49490..0f358cd 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -1249,16 +1249,16 @@ write_integer_cst (const tree cst)
if (sign < 0)
{
write_char ('n');
- n = fold (build1 (NEGATE_EXPR, type, n));
+ n = fold_build1 (NEGATE_EXPR, type, n);
}
do
{
- tree d = fold (build2 (FLOOR_DIV_EXPR, type, n, base));
- tree tmp = fold (build2 (MULT_EXPR, type, d, base));
+ tree d = fold_build2 (FLOOR_DIV_EXPR, type, n, base);
+ tree tmp = fold_build2 (MULT_EXPR, type, d, base);
unsigned c;
done = integer_zerop (d);
- tmp = fold (build2 (MINUS_EXPR, type, n, tmp));
+ tmp = fold_build2 (MINUS_EXPR, type, n, tmp);
c = hwint_to_ascii (TREE_INT_CST_LOW (tmp), 10, ptr,
done ? 1 : chunk_digits);
ptr -= c;
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 7a99c26..70d6642 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -220,8 +220,8 @@ thunk_adjust (tree ptr, bool this_adjusting,
{
if (this_adjusting)
/* Adjust the pointer by the constant. */
- ptr = fold (build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr,
- ssize_int (fixed_offset)));
+ ptr = fold_build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr,
+ ssize_int (fixed_offset));
/* If there's a virtual offset, look up that value in the vtable and
adjust the pointer again. */
@@ -242,13 +242,13 @@ thunk_adjust (tree ptr, bool this_adjusting,
/* Get the offset itself. */
vtable = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (vtable)), vtable);
/* Adjust the `this' pointer. */
- ptr = fold (build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr, vtable));
+ ptr = fold_build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr, vtable);
}
if (!this_adjusting)
/* Adjust the pointer by the constant. */
- ptr = fold (build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr,
- ssize_int (fixed_offset)));
+ ptr = fold_build2 (PLUS_EXPR, TREE_TYPE (ptr), ptr,
+ ssize_int (fixed_offset));
return ptr;
}
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 77ca2b9..d5514f3 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3612,7 +3612,7 @@ convert_nontype_argument (tree type, tree expr)
if (!expr || expr == error_mark_node)
return expr;
- expr = build_nop(type, build_address (expr));
+ expr = build_nop (type, build_address (expr));
}
/* [temp.arg.nontype]/5, bullet 6
@@ -7342,7 +7342,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (e1 == error_mark_node || e2 == error_mark_node)
return error_mark_node;
- return fold (build2 (TREE_CODE (t), TREE_TYPE (t), e1, e2));
+ return fold_build2 (TREE_CODE (t), TREE_TYPE (t), e1, e2);
}
case NEGATE_EXPR:
@@ -7352,7 +7352,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (e == error_mark_node)
return error_mark_node;
- return fold (build1 (TREE_CODE (t), TREE_TYPE (t), e));
+ return fold_build1 (TREE_CODE (t), TREE_TYPE (t), e);
}
case TYPENAME_TYPE:
@@ -10158,10 +10158,10 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
not an integer constant. */
if (TREE_CODE (parm_max) == MINUS_EXPR)
{
- arg_max = fold (build2 (PLUS_EXPR,
- integer_type_node,
- arg_max,
- TREE_OPERAND (parm_max, 1)));
+ arg_max = fold_build2 (PLUS_EXPR,
+ integer_type_node,
+ arg_max,
+ TREE_OPERAND (parm_max, 1));
parm_max = TREE_OPERAND (parm_max, 0);
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 1af7191..8b0d9aa 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1112,9 +1112,9 @@ cxx_print_statistics (void)
tree
array_type_nelts_top (tree type)
{
- return fold (build2 (PLUS_EXPR, sizetype,
- array_type_nelts (type),
- integer_one_node));
+ return fold_build2 (PLUS_EXPR, sizetype,
+ array_type_nelts (type),
+ integer_one_node);
}
/* Return, as an INTEGER_CST node, the number of elements for TYPE
@@ -1129,7 +1129,7 @@ array_type_nelts_total (tree type)
while (TREE_CODE (type) == ARRAY_TYPE)
{
tree n = array_type_nelts_top (type);
- sz = fold (build2 (MULT_EXPR, sizetype, sz, n));
+ sz = fold_build2 (MULT_EXPR, sizetype, sz, n);
type = TREE_TYPE (type);
}
return sz;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 0ddf8f2..e2cb1f8 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -905,8 +905,6 @@ comp_array_types (tree t1, tree t2, bool allow_redeclaration)
bool
comptypes (tree t1, tree t2, int strict)
{
- int retval;
-
if (t1 == t2)
return true;
@@ -969,9 +967,7 @@ comptypes (tree t1, tree t2, int strict)
&& TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
return true;
- if (!(*targetm.comp_type_attributes) (t1, t2))
- return false;
-
+ /* Compare the types. Break out if they could be the same. */
switch (TREE_CODE (t1))
{
case TEMPLATE_TEMPLATE_PARM:
@@ -984,7 +980,7 @@ comptypes (tree t1, tree t2, int strict)
DECL_TEMPLATE_PARMS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t2))))
return false;
if (TREE_CODE (t1) == TEMPLATE_TEMPLATE_PARM)
- return true;
+ break;
/* Don't check inheritance. */
strict = COMPARE_STRICT;
/* Fall through. */
@@ -995,18 +991,17 @@ comptypes (tree t1, tree t2, int strict)
&& (TYPE_TI_TEMPLATE (t1) == TYPE_TI_TEMPLATE (t2)
|| TREE_CODE (t1) == BOUND_TEMPLATE_TEMPLATE_PARM)
&& comp_template_args (TYPE_TI_ARGS (t1), TYPE_TI_ARGS (t2)))
- return true;
+ break;
if ((strict & COMPARE_BASE) && DERIVED_FROM_P (t1, t2))
- return true;
+ break;
else if ((strict & COMPARE_DERIVED) && DERIVED_FROM_P (t2, t1))
- return true;
+ break;
- /* We may be dealing with Objective-C instances... */
+ /* We may be dealing with Objective-C instances. */
if (TREE_CODE (t1) == RECORD_TYPE
- && ((retval = objc_comptypes (t1, t2, 0)) >= 0))
- return retval;
- /* ...but fall through if we are not. */
+ && objc_comptypes (t1, t2, 0) > 0)
+ break;
return false;
@@ -1014,51 +1009,72 @@ comptypes (tree t1, tree t2, int strict)
if (!comptypes (TYPE_OFFSET_BASETYPE (t1), TYPE_OFFSET_BASETYPE (t2),
strict & ~COMPARE_REDECLARATION))
return false;
- return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+ if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+ return false;
+ break;
case POINTER_TYPE:
case REFERENCE_TYPE:
- return TYPE_MODE (t1) == TYPE_MODE (t2)
- && TYPE_REF_CAN_ALIAS_ALL (t1) == TYPE_REF_CAN_ALIAS_ALL (t2)
- && same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+ if (TYPE_MODE (t1) != TYPE_MODE (t2)
+ || TYPE_REF_CAN_ALIAS_ALL (t1) != TYPE_REF_CAN_ALIAS_ALL (t2)
+ || !same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+ return false;
+ break;
case METHOD_TYPE:
case FUNCTION_TYPE:
if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
return false;
- return compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2));
+ if (!compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2)))
+ return false;
+ break;
case ARRAY_TYPE:
/* Target types must match incl. qualifiers. */
- return comp_array_types (t1, t2, !!(strict & COMPARE_REDECLARATION));
+ if (!comp_array_types (t1, t2, !!(strict & COMPARE_REDECLARATION)))
+ return false;
+ break;
case TEMPLATE_TYPE_PARM:
- return (TEMPLATE_TYPE_IDX (t1) == TEMPLATE_TYPE_IDX (t2)
- && TEMPLATE_TYPE_LEVEL (t1) == TEMPLATE_TYPE_LEVEL (t2));
+ if (TEMPLATE_TYPE_IDX (t1) != TEMPLATE_TYPE_IDX (t2)
+ || TEMPLATE_TYPE_LEVEL (t1) != TEMPLATE_TYPE_LEVEL (t2))
+ return false;
+ break;
case TYPENAME_TYPE:
if (!cp_tree_equal (TYPENAME_TYPE_FULLNAME (t1),
TYPENAME_TYPE_FULLNAME (t2)))
return false;
- return same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2));
+ if (!same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2)))
+ return false;
+ break;
case UNBOUND_CLASS_TEMPLATE:
if (!cp_tree_equal (TYPE_IDENTIFIER (t1), TYPE_IDENTIFIER (t2)))
return false;
- return same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2));
+ if (!same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2)))
+ return false;
+ break;
case COMPLEX_TYPE:
- return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+ if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+ return false;
+ break;
case VECTOR_TYPE:
- return TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2)
- && same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+ if (TYPE_VECTOR_SUBPARTS (t1) != TYPE_VECTOR_SUBPARTS (t2)
+ || !same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+ return false;
break;
default:
- break;
+ return false;
}
- return false;
+
+ /* If we get here, we know that from a target independent POV the
+ types are the same. Make sure the target attributes are also
+ the same. */
+ return targetm.comp_type_attributes (t1, t2);
}
/* Returns 1 if TYPE1 is at least as qualified as TYPE2. */
@@ -1995,8 +2011,8 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree member_name)
/*want_type=*/false);
member_type = cp_build_qualified_type (TREE_TYPE (member),
cp_type_quals (ptrmem_type));
- return fold (build3 (COMPONENT_REF, member_type,
- ptrmem, member, NULL_TREE));
+ return fold_build3 (COMPONENT_REF, member_type,
+ ptrmem, member, NULL_TREE);
}
/* Given an expression PTR for a pointer, return an expression
@@ -2343,7 +2359,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function)
vtbl = build_indirect_ref (vtbl, NULL);
/* Finally, extract the function pointer from the vtable. */
- e2 = fold (build2 (PLUS_EXPR, TREE_TYPE (vtbl), vtbl, idx));
+ e2 = fold_build2 (PLUS_EXPR, TREE_TYPE (vtbl), vtbl, idx);
e2 = build_indirect_ref (e2, NULL);
TREE_CONSTANT (e2) = 1;
TREE_INVARIANT (e2) = 1;