aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cvt.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-09-28 02:56:11 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-09-28 02:56:11 +0000
commit455f19cb1cc13e726b806d792a8808f55aaa9a07 (patch)
tree36630ae2e63d9c79e59704bfce96a6e0b3b33f2c /gcc/cp/cvt.c
parent081077002d07ddac4094b11b1edd5f8d1175bddd (diff)
downloadgcc-455f19cb1cc13e726b806d792a8808f55aaa9a07.zip
gcc-455f19cb1cc13e726b806d792a8808f55aaa9a07.tar.gz
gcc-455f19cb1cc13e726b806d792a8808f55aaa9a07.tar.bz2
re PR c++/17642 (internal compiler error: in invert_truthvalue, at fold-const.c:2997)
PR c++/17642 * stor-layout.c (layout_decl): Use fold_convert, not convert. (bit_from_pos): Likewise. (byte_from_pos): Likewise. (pos_from_bit): Likewise. (normalize_offset): Likewise. (place_field): Likewise. (finalize_type_size): Likewise. (layout_type): Likewise. * tree.c (build_index_type): Likewise. PR c++/17642 * cp-tree.h (fold_if_not_in_template): New function. * call.c (build_conditional_expr): Use fold_if_not_in_template. (build_cxx_call): Likewise. * cvt.c (convert_to_complex): Likewise. (ocp_convert): Likewise. (convert): Likewise. (convert_force): Likewise. * decl.c (compute_array_index_type): Clear processing_template_decl while folding array bounds. * pt.c (convert_nontype_argument): Clear processing_template_decl while processing non-type argument initialization. * tree.c (fold_if_not_in_template): New function. * typeck.c (build_class_member_access_expr): Use fold_if_not_in_template. (build_array_ref): Likewise. (build_binary_op): Likewise. Do not try to optimize computations when processing templates. (cp_pointer_int_sum): Use fold_if_not_in_template. (pointer_diff): Likewise. (build_unary_op): Likewise. (build_reinterpret_cast): Likewise. (get_delta_difference): Likewise. (expand_ptrmemfunc_cst): Likewise. (dubious_conversion_warnings): Likewise. * g++.dg/template/crash23.C: New test. From-SVN: r88217
Diffstat (limited to 'gcc/cp/cvt.c')
-rw-r--r--gcc/cp/cvt.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index d93351e..a5d42e4 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -643,7 +643,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
/* For complex data types, we need to perform componentwise
conversion. */
else if (TREE_CODE (type) == COMPLEX_TYPE)
- return fold (convert_to_complex (type, e));
+ return fold_if_not_in_template (convert_to_complex (type, e));
else if (TREE_CODE (e) == TARGET_EXPR)
{
/* Don't build a NOP_EXPR of class type. Instead, change the
@@ -659,7 +659,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
/* We shouldn't be treating objects of ADDRESSABLE type as
rvalues. */
gcc_assert (!TREE_ADDRESSABLE (type));
- return fold (build1 (NOP_EXPR, type, e));
+ return fold_if_not_in_template (build_nop (type, e));
}
}
@@ -696,10 +696,10 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
if (code == BOOLEAN_TYPE)
return cp_truthvalue_conversion (e);
- return fold (convert_to_integer (type, e));
+ return fold_if_not_in_template (convert_to_integer (type, e));
}
if (POINTER_TYPE_P (type) || TYPE_PTR_TO_MEMBER_P (type))
- return fold (cp_convert_to_pointer (type, e, false));
+ return fold_if_not_in_template (cp_convert_to_pointer (type, e, false));
if (code == VECTOR_TYPE)
{
tree in_vtype = TREE_TYPE (e);
@@ -713,7 +713,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
error ("`%#T' used where a `%T' was expected", in_vtype, type);
return error_mark_node;
}
- return fold (convert_to_vector (type, e));
+ return fold_if_not_in_template (convert_to_vector (type, e));
}
if (code == REAL_TYPE || code == COMPLEX_TYPE)
{
@@ -729,9 +729,9 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
TREE_TYPE (e));
}
if (code == REAL_TYPE)
- return fold (convert_to_real (type, e));
+ return fold_if_not_in_template (convert_to_real (type, e));
else if (code == COMPLEX_TYPE)
- return fold (convert_to_complex (type, e));
+ return fold_if_not_in_template (convert_to_complex (type, e));
}
/* New C++ semantics: since assignment is now based on
@@ -945,7 +945,7 @@ convert (tree type, tree expr)
if (POINTER_TYPE_P (type) && POINTER_TYPE_P (intype))
{
expr = decl_constant_value (expr);
- return fold (build1 (NOP_EXPR, type, expr));
+ return fold_if_not_in_template (build_nop (type, expr));
}
return ocp_convert (type, expr, CONV_OLD_CONVERT,
@@ -963,13 +963,14 @@ convert_force (tree type, tree expr, int convtype)
enum tree_code code = TREE_CODE (type);
if (code == REFERENCE_TYPE)
- return fold (convert_to_reference (type, e, CONV_C_CAST, LOOKUP_COMPLAIN,
- NULL_TREE));
+ return (fold_if_not_in_template
+ (convert_to_reference (type, e, CONV_C_CAST, LOOKUP_COMPLAIN,
+ NULL_TREE)));
else if (TREE_CODE (TREE_TYPE (e)) == REFERENCE_TYPE)
e = convert_from_reference (e);
if (code == POINTER_TYPE)
- return fold (convert_to_pointer_force (type, e));
+ return fold_if_not_in_template (convert_to_pointer_force (type, e));
/* From typeck.c convert_for_assignment */
if (((TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE && TREE_CODE (e) == ADDR_EXPR