From b22327455de6128939ee7487ceec8f73d2e6d8be Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Tue, 17 May 2005 18:01:17 +0000 Subject: [PATCH] * c-typeck.c (common_type): Also handle BOOLEAN_TYPEs. From-SVN: r99843 --- gcc/ChangeLog | 4 ++++ gcc/c-typeck.c | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3217a8d0b90..e7657bc8128 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2005-05-17 Roger Sayle + + * c-typeck.c (common_type): Also handle BOOLEAN_TYPEs. + 2005-05-17 Steven Bosscher Stuart Hastings Jan Hubicka diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index b96328d89b9..04fa7454023 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); } -- 2.30.2