aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cp-gimplify.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-02-08 10:31:47 -0500
committerJason Merrill <jason@gcc.gnu.org>2016-02-08 10:31:47 -0500
commit415594bb5c49d69f5350401d07abac62bce8656a (patch)
treefffcfe2c7dae6ee698e378ab02e9cdf2d86a254e /gcc/cp/cp-gimplify.c
parentae9dd7f3f8219057b459356c8234bf4aa73f7e1e (diff)
downloadgcc-415594bb5c49d69f5350401d07abac62bce8656a.zip
gcc-415594bb5c49d69f5350401d07abac62bce8656a.tar.gz
gcc-415594bb5c49d69f5350401d07abac62bce8656a.tar.bz2
re PR c++/69631 (Bogus overflow in constant expression error)
PR c++/69631 gcc/ * convert.c (convert_to_integer_1): Check dofold on truncation distribution. (convert_to_pointer_maybe_fold, convert_to_real_maybe_fold) (convert_to_integer_maybe_fold, convert_to_complex_maybe_fold): Rename from *_nofold. * convert.h (convert_to_pointer_nofold, convert_to_integer_nofold) (convert_to_real_nofold, convert_to_complex_nofold): New inlines. gcc/cp/ * cp-tree.h (CONV_FOLD, CONV_BACKEND_CONVERT): New. * cvt.c (convert): Pass CONV_BACKEND_CONVERT. (ocp_convert): Use *_maybe_fold. (cp_convert_to_pointer): Add dofold parameter. * cp-gimplify.c (cp_fold) [CONVERT_EXPR]: Call convert. From-SVN: r233216
Diffstat (limited to 'gcc/cp/cp-gimplify.c')
-rw-r--r--gcc/cp/cp-gimplify.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index bb81534..d83e9de 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1953,7 +1953,13 @@ cp_fold (tree x)
loc = EXPR_LOCATION (x);
op0 = cp_fold_maybe_rvalue (TREE_OPERAND (x, 0), rval_ops);
- if (op0 != TREE_OPERAND (x, 0))
+ if (code == CONVERT_EXPR
+ && SCALAR_TYPE_P (TREE_TYPE (x))
+ && op0 != void_node)
+ /* During parsing we used convert_to_*_nofold; re-convert now using the
+ folding variants, since fold() doesn't do those transformations. */
+ x = fold (convert (TREE_TYPE (x), op0));
+ else if (op0 != TREE_OPERAND (x, 0))
{
if (op0 == error_mark_node)
x = error_mark_node;