aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-10-25 17:11:49 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-10-25 17:11:49 +0000
commit90e261e494a5f1fda83b815f513c5621fa5f8c83 (patch)
tree287ecd3c49a6b519376afa6b2ba709f33d37870a /gcc/tree.c
parentcef026ecafe169871284fded6494efe33e763950 (diff)
downloadgcc-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.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 30d4373..56cc653 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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);