fold-const.c (fold): Don't require strict type equality...
authorRoger Sayle <roger@eyesopen.com>
Tue, 30 Dec 2003 17:21:54 +0000 (17:21 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Tue, 30 Dec 2003 17:21:54 +0000 (17:21 +0000)
* fold-const.c (fold) <COND_EXPR>: Don't require strict type
equality, instead just prevent replacing a COND_EXPR of non-void
type by one of its operands of void type.

From-SVN: r75239

gcc/ChangeLog
gcc/fold-const.c

index a1010196710e2846a721042c8ebb6bd8a1c1c6d2..20ca93eba17b02c7789d686202a12beb588b3baf 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-30  Roger Sayle  <roger@eyesopen.com>
+
+       * fold-const.c (fold) <COND_EXPR>: Don't require strict type
+       equality, instead just prevent replacing a COND_EXPR of non-void
+       type by one of its operands of void type.
+
 2003-12-30  Andreas Schwab  <schwab@suse.de>
 
        * doc/c-tree.texi: Fix @item vs. @itemx.
index 556593243ac335609593fb8f0f95b95cd45e4d94..7a939c4966658545711035d13c1496bc819f3cde 100644 (file)
@@ -7869,7 +7869,8 @@ fold (tree expr)
          /* Only optimize constant conditions when the selected branch
             has the same type as the COND_EXPR.  This avoids optimizing
             away "c ? x : throw", where the throw has a void type.  */
-         if (TREE_TYPE (tem) == TREE_TYPE (t))
+         if (! VOID_TYPE_P (TREE_TYPE (tem))
+             || VOID_TYPE_P (TREE_TYPE (t)))
            return pedantic_non_lvalue (tem);
          return t;
        }