From 10d5caece7859aff9317b1c93732a222bd50f05b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 2 Jul 1993 01:26:01 +0000 Subject: [PATCH] (c_sizeof, build_c_cast): Set TREE_OVERFLOW in addition to TREE_CONSTANT_OVERFLOW. (c_sizeof, build_c_cast): Set TREE_OVERFLOW in addition to TREE_CONSTANT_OVERFLOW. (store_init_value): STRIP_TYPE_NOPS is required before constant_expression_warning. From-SVN: r4825 --- gcc/c-typeck.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index a10fb0abcc3..00de4cbddbb 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -761,8 +761,8 @@ c_sizeof (type) t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), size_int (TYPE_PRECISION (char_type_node))); /* size_binop does not put the constant in range, so do it now. */ - if (TREE_CODE (t) == INTEGER_CST) - TREE_CONSTANT_OVERFLOW (t) |= force_fit_type (t, 0); + if (TREE_CODE (t) == INTEGER_CST && force_fit_type (t, 0)) + TREE_CONSTANT_OVERFLOW (t) = TREE_OVERFLOW (t) = 1; return t; } @@ -3870,7 +3870,7 @@ build_c_cast (type, expr) } else { - tree otype; + tree otype, ovalue; /* If casting to void, avoid the error that would come from default_conversion in the case of a non-lvalue array. */ @@ -3925,11 +3925,15 @@ build_c_cast (type, expr) && !TREE_CONSTANT (value)) warning ("cast to pointer from integer of different size"); + ovalue = value; value = convert (type, value); /* Ignore any integer overflow caused by the cast. */ if (TREE_CODE (value) == INTEGER_CST) - TREE_CONSTANT_OVERFLOW (value) = 0; + { + TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue); + TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue); + } } if (value == expr && pedantic) @@ -4535,10 +4539,11 @@ store_init_value (decl, init) } #endif + DECL_INITIAL (decl) = value; + /* ANSI wants warnings about out-of-range constant initializers. */ + STRIP_TYPE_NOPS (value); constant_expression_warning (value); - - DECL_INITIAL (decl) = value; } /* Methods for storing and printing names for error messages. */ -- 2.30.2