From: eggert Date: Fri, 2 Jul 1993 01:26:01 +0000 (+0000) Subject: (constant_expression_warning, overflow_warning, X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=b04da9b54c6dfa7a6246a1fafdba3ca335a2a36f;p=pf3gnuchains%2Fgcc-fork.git (constant_expression_warning, overflow_warning, convert_and_check): Distinguish between TREE_OVERFLOW, which is just for warnings, and TREE_CONSTANT_OVERFLOW, which is for required pedantic diagnostics. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@4827 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/c-common.c b/gcc/c-common.c index 7e0691e0079..087332c98b9 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -349,15 +349,8 @@ constant_expression_warning (value) tree value; { if (TREE_CODE (value) == INTEGER_CST && TREE_CONSTANT_OVERFLOW (value)) - { - /* ??? This is a warning, not a pedwarn, in 2.4, - because it happens in contexts that are not - "constant expressions" in ANSI C. - Fix the problem differently in 2.5. */ - warning ("overflow in constant expression"); - /* Suppress duplicate warnings. */ - TREE_CONSTANT_OVERFLOW (value) = 0; - } + if (pedantic) + pedwarn ("overflow in constant expression"); } /* Print a warning if an expression had overflow in folding. @@ -371,14 +364,10 @@ void overflow_warning (value) tree value; { - if (TREE_CODE (value) == INTEGER_CST && TREE_CONSTANT_OVERFLOW (value)) + if (TREE_CODE (value) == INTEGER_CST && TREE_OVERFLOW (value)) { - /* ??? This is a warning, not a pedwarn, in 2.4, - because it happens in contexts that are not - "constant expressions" in ANSI C. - Fix the problem differently in 2.5. */ + TREE_OVERFLOW (value) = 0; warning ("integer overflow in expression"); - TREE_CONSTANT_OVERFLOW (value) = 0; } } @@ -415,20 +404,15 @@ convert_and_check (type, expr) tree t = convert (type, expr); if (TREE_CODE (t) == INTEGER_CST) { - if (TREE_UNSIGNED (TREE_TYPE (expr)) - && !TREE_UNSIGNED (type) - && TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE - && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (expr))) - /* No warning for converting 0x80000000 to int. */ - TREE_CONSTANT_OVERFLOW (t) = 0; - else if (TREE_CONSTANT_OVERFLOW (t)) + if (TREE_OVERFLOW (t)) { - /* ??? This is a warning, not a pedwarn, in 2.4, - because it happens in contexts that are not - "constant expressions" in ANSI C. - Fix the problem differently in 2.5. */ - warning ("overflow in implicit constant conversion"); - TREE_CONSTANT_OVERFLOW (t) = 0; + TREE_OVERFLOW (t) = 0; + + /* No warning for converting 0x80000000 to int. */ + if (!(TREE_UNSIGNED (type) < TREE_UNSIGNED (TREE_TYPE (expr)) + && TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE + && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (expr)))) + warning ("overflow in implicit constant conversion"); } else unsigned_conversion_warning (t, expr);