aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-10-11 13:53:07 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-10-11 13:53:07 -0400
commita4474a3854f4fec4bfccad91706f95a6737e6a79 (patch)
tree473b4642325a93846dad0753e76e9aebf4091fc9 /gcc/cp/call.c
parent816e239ae16481accfae7b85359dc6ebce1dd97b (diff)
downloadgcc-a4474a3854f4fec4bfccad91706f95a6737e6a79.zip
gcc-a4474a3854f4fec4bfccad91706f95a6737e6a79.tar.gz
gcc-a4474a3854f4fec4bfccad91706f95a6737e6a79.tar.bz2
re PR c++/49855 (internal compiler error: in fold_convert_const_int_from_real)
PR c++/49855 PR c++/49896 * cp-tree.def (IMPLICIT_CONV_EXPR): New. * call.c (perform_implicit_conversion_flags): Build it instead of NOP_EXPR. * cp-objcp-common.c (cp_common_init_ts): It's typed. * cxx-pretty-print.c (pp_cxx_cast_expression): Handle it. (pp_cxx_expression): Likewise. * error.c (dump_expr): Likewise. * semantics.c (potential_constant_expression_1): Likewise. * tree.c (cp_tree_equal): Likewise. (cp_walk_subtrees): Likewise. * pt.c (iterative_hash_template_arg): Likewise. (for_each_template_parm_r): Likewise. (type_dependent_expression_p): Likewise. (tsubst_copy, tsubst_copy_and_build): Handle IMPLICIT_CONV_EXPR and CONVERT_EXPR. * cp-tree.h (IMPLICIT_CONV_EXPR_DIRECT_INIT): New. From-SVN: r179813
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 4c03e76..7219afe 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8397,13 +8397,19 @@ perform_implicit_conversion_flags (tree type, tree expr, tsubst_flags_t complain
}
expr = error_mark_node;
}
- else if (processing_template_decl)
+ else if (processing_template_decl
+ /* As a kludge, we always perform conversions between scalar
+ types, as IMPLICIT_CONV_EXPR confuses c_finish_omp_for. */
+ && !(SCALAR_TYPE_P (type) && SCALAR_TYPE_P (TREE_TYPE (expr))))
{
/* In a template, we are only concerned about determining the
type of non-dependent expressions, so we do not have to
- perform the actual conversion. */
- if (TREE_TYPE (expr) != type)
- expr = build_nop (type, expr);
+ perform the actual conversion. But for initializers, we
+ need to be able to perform it at instantiation
+ (or fold_non_dependent_expr) time. */
+ expr = build1 (IMPLICIT_CONV_EXPR, type, expr);
+ if (!(flags & LOOKUP_ONLYCONVERTING))
+ IMPLICIT_CONV_EXPR_DIRECT_INIT (expr) = true;
}
else
expr = convert_like (conv, expr, complain);