diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2016-10-25 17:11:49 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2016-10-25 17:11:49 +0000 |
commit | 90e261e494a5f1fda83b815f513c5621fa5f8c83 (patch) | |
tree | 287ecd3c49a6b519376afa6b2ba709f33d37870a /gcc/tree.c | |
parent | cef026ecafe169871284fded6494efe33e763950 (diff) | |
download | gcc-90e261e494a5f1fda83b815f513c5621fa5f8c83.zip gcc-90e261e494a5f1fda83b815f513c5621fa5f8c83.tar.gz gcc-90e261e494a5f1fda83b815f513c5621fa5f8c83.tar.bz2 |
tree.h (wi::fits_to_tree_p): Accept only 0 and 1 for boolean types.
* tree.h (wi::fits_to_tree_p): Accept only 0 and 1 for boolean types.
* tree.c (int_fits_type_p): Likewise. Adjust head comment.
From-SVN: r241529
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -9065,8 +9065,8 @@ get_narrower (tree op, int *unsignedp_ptr) return win; } -/* Returns true if integer constant C has a value that is permissible - for type TYPE (an INTEGER_TYPE). */ +/* Return true if integer constant C has a value that is permissible + for TYPE, an integral type. */ bool int_fits_type_p (const_tree c, const_tree type) @@ -9075,6 +9075,11 @@ int_fits_type_p (const_tree c, const_tree type) bool ok_for_low_bound, ok_for_high_bound; signop sgn_c = TYPE_SIGN (TREE_TYPE (c)); + /* Short-circuit boolean types since various transformations assume that + they can only take values 0 and 1. */ + if (TREE_CODE (type) == BOOLEAN_TYPE) + return integer_zerop (c) || integer_onep (c); + retry: type_low_bound = TYPE_MIN_VALUE (type); type_high_bound = TYPE_MAX_VALUE (type); |