diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-03-04 23:29:41 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-03-04 23:29:41 +0000 |
commit | f73fe417bc5556b2ab098e22cb6436b9b26c0577 (patch) | |
tree | b5345e046ddd0c7cfef6c82973f5e694a3fbb99e /gcc/c-common.c | |
parent | af13a7a6ec9a50c39948ee5631a47c29c84fc6d1 (diff) | |
download | gcc-f73fe417bc5556b2ab098e22cb6436b9b26c0577.zip gcc-f73fe417bc5556b2ab098e22cb6436b9b26c0577.tar.gz gcc-f73fe417bc5556b2ab098e22cb6436b9b26c0577.tar.bz2 |
re PR other/30465 (Duplicated overflow warning)
2007-03-04 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR other/30465
* c-common.c (convert_and_check): Don't give warnings for
conversion if 'expr' already overflowed.
testsuite/
* gcc.dg/multiple-overflow-warn-3.c: New.
* g++.dg/warn/multiple-overflow-warn-3.C: New.
From-SVN: r122534
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 6ea3800..523ef46 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1250,10 +1250,9 @@ convert_and_check (tree type, tree expr) result = convert (type, expr); - if (skip_evaluation) + if (skip_evaluation || TREE_OVERFLOW_P (expr)) return result; - if (TREE_CODE (expr) == INTEGER_CST && (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == ENUMERAL_TYPE) @@ -1274,21 +1273,19 @@ convert_and_check (tree type, tree expr) else if (warn_conversion) conversion_warning (type, expr); } - else - { - if (!int_fits_type_p (expr, c_common_unsigned_type (type))) - warning (OPT_Woverflow, - "overflow in implicit constant conversion"); - /* No warning for converting 0x80000000 to int. */ - else if (pedantic - && (TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE - || TYPE_PRECISION (TREE_TYPE (expr)) - != TYPE_PRECISION (type))) - warning (OPT_Woverflow, - "overflow in implicit constant conversion"); - else if (warn_conversion) - conversion_warning (type, expr); - } + else if (!int_fits_type_p (expr, c_common_unsigned_type (type))) + warning (OPT_Woverflow, + "overflow in implicit constant conversion"); + /* No warning for converting 0x80000000 to int. */ + else if (pedantic + && (TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE + || TYPE_PRECISION (TREE_TYPE (expr)) + != TYPE_PRECISION (type))) + warning (OPT_Woverflow, + "overflow in implicit constant conversion"); + + else if (warn_conversion) + conversion_warning (type, expr); } else if (TREE_CODE (result) == INTEGER_CST && TREE_OVERFLOW (result)) warning (OPT_Woverflow, |