summaryrefslogtreecommitdiff
path: root/gcc/cp/tree.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-28 02:56:11 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-28 02:56:11 +0000
commit5d7ed6c775004db0b03ae47d20effa3b4bf6e5ed (patch)
tree36630ae2e63d9c79e59704bfce96a6e0b3b33f2c /gcc/cp/tree.c
parent76119aa3ccb987a98a77d4dc18e21cfd631c60c3 (diff)
downloadgcc-5d7ed6c775004db0b03ae47d20effa3b4bf6e5ed.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88217 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r--gcc/cp/tree.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index fc3516d8e8a..16bb39bc740 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2331,6 +2331,19 @@ stabilize_init (tree init, tree *initp)
return true;
}
+/* Like "fold", but should be used whenever we might be processing the
+ body of a template. */
+
+tree
+fold_if_not_in_template (tree expr)
+{
+ /* In the body of a template, there is never any need to call
+ "fold". We will call fold later when actually instantiating the
+ template. Integral constant expressions in templates will be
+ evaluted via fold_non_dependent_expr, as necessary. */
+ return (processing_template_decl ? expr : fold (expr));
+}
+
#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
/* Complain that some language-specific thing hanging off a tree