OSDN Git Service

* c-typeck.c (common_type): Also handle BOOLEAN_TYPEs.
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 May 2005 18:01:17 +0000 (18:01 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 May 2005 18:01:17 +0000 (18:01 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99843 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-typeck.c

index 3217a8d..e7657bc 100644 (file)
@@ -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>
index b96328d..04fa745 100644 (file)
@@ -618,7 +618,9 @@ c_common_type (tree t1, tree t2)
 }
 \f
 /* 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);
 }
 \f