diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-03-18 08:10:33 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-03-18 08:10:33 +0100 |
commit | 12d2dc5e67905a22e0bf6d8b4a49b1ce246284a8 (patch) | |
tree | 90cd1769b3c65fd0d483617a9235af7981d5d905 /gcc/tree.c | |
parent | 136357ac8d1da764c452aa4316ebf8ea7e027457 (diff) | |
download | gcc-12d2dc5e67905a22e0bf6d8b4a49b1ce246284a8.zip gcc-12d2dc5e67905a22e0bf6d8b4a49b1ce246284a8.tar.gz gcc-12d2dc5e67905a22e0bf6d8b4a49b1ce246284a8.tar.bz2 |
re PR c/56566 (bogus "is narrower than values of its type" warning)
PR c/56566
* tree.c (tree_int_cst_min_precision): For integer_zerop (value)
return 1 even for !unsignedp.
* c-c++-common/pr56566.c: New test.
From-SVN: r196767
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -6648,8 +6648,6 @@ tree_int_cst_sgn (const_tree t) unsigned int tree_int_cst_min_precision (tree value, bool unsignedp) { - int log; - /* If the value is negative, compute its negative minus 1. The latter adjustment is because the absolute value of the largest negative value is one larger than the largest positive value. This is equivalent to @@ -6659,14 +6657,14 @@ tree_int_cst_min_precision (tree value, bool unsignedp) value = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (value), value); /* Return the number of bits needed, taking into account the fact - that we need one more bit for a signed than unsigned type. */ + that we need one more bit for a signed than unsigned type. + If value is 0 or -1, the minimum precision is 1 no matter + whether unsignedp is true or false. */ if (integer_zerop (value)) - log = 0; + return 1; else - log = tree_floor_log2 (value); - - return log + 1 + !unsignedp; + return tree_floor_log2 (value) + 1 + !unsignedp; } /* Compare two constructor-element-type constants. Return 1 if the lists |