diff options
author | Roger Sayle <roger@eyesopen.com> | 2005-05-17 18:01:17 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2005-05-17 18:01:17 +0000 |
commit | b22327455de6128939ee7487ceec8f73d2e6d8be (patch) | |
tree | 507956c1225dd0729f0aa8a013e8544d39e00772 | |
parent | a0f94629e9ae74173a1c0a79d0d13ee65ea3f96a (diff) | |
download | gcc-b22327455de6128939ee7487ceec8f73d2e6d8be.zip gcc-b22327455de6128939ee7487ceec8f73d2e6d8be.tar.gz gcc-b22327455de6128939ee7487ceec8f73d2e6d8be.tar.bz2 |
* c-typeck.c (common_type): Also handle BOOLEAN_TYPEs.
From-SVN: r99843
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-typeck.c | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3217a8d..e7657bc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2005-05-17 Roger Sayle <roger@eyesopen.com> + + * c-typeck.c (common_type): Also handle BOOLEAN_TYPEs. + 2005-05-17 Steven Bosscher <stevenb@suse.de> Stuart Hastings <stuart@apple.com> Jan Hubicka <jh@suse.cz> diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index b96328d..04fa745 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -618,7 +618,9 @@ c_common_type (tree t1, tree t2) } /* Wrapper around c_common_type that is used by c-common.c. ENUMERAL_TYPEs - are allowed here and are converted to their compatible integer types. */ + are allowed here and are converted to their compatible integer types. + BOOLEAN_TYPEs are allowed here and return either boolean_type_node or + preferably a non-Boolean type as the common type. */ tree common_type (tree t1, tree t2) { @@ -626,6 +628,18 @@ common_type (tree t1, tree t2) t1 = c_common_type_for_size (TYPE_PRECISION (t1), 1); if (TREE_CODE (t2) == ENUMERAL_TYPE) t2 = c_common_type_for_size (TYPE_PRECISION (t2), 1); + + /* If both types are BOOLEAN_TYPE, then return boolean_type_node. */ + if (TREE_CODE (t1) == BOOLEAN_TYPE + && TREE_CODE (t2) == BOOLEAN_TYPE) + return boolean_type_node; + + /* If either type is BOOLEAN_TYPE, then return the other. */ + if (TREE_CODE (t1) == BOOLEAN_TYPE) + return t2; + if (TREE_CODE (t2) == BOOLEAN_TYPE) + return t1; + return c_common_type (t1, t2); } |