gimplify.c (gimplify_expr): Make sure operand is boolified.
authorKai Tietz <ktietz@redhat.com>
Fri, 13 May 2011 13:37:16 +0000 (15:37 +0200)
committerKai Tietz <ktietz@gcc.gnu.org>
Fri, 13 May 2011 13:37:16 +0000 (15:37 +0200)
2011-05-13  Kai Tietz  <ktietz@redhat.com>

        * gimplify.c (gimplify_expr): Make sure operand is boolified.
        * tree-cfg.c (verify_gimple_assign_unary): Check for boolean
        compatible type for TRUTH_NOT_EXPR.

From-SVN: r173732

gcc/ChangeLog
gcc/gimplify.c
gcc/tree-cfg.c

index 62015642ef5cda46964e6cae123ab00e0bb299c8..52e6f10d5863c40f456d6f726054dbb05fe247db 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-13  Kai Tietz  <ktietz@redhat.com>
+
+       * gimplify.c (gimplify_expr): Make sure operand is boolified.
+       * tree-cfg.c (verify_gimple_assign_unary): Check for boolean
+       compatible type for TRUTH_NOT_EXPR.
+
 2011-05-13  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/i386/i386.c (ix86_save_reg): Change return type to
index 33a76a266a8ca536b97f0f60eeca2e43e0a4c348..d776692d71517f3d064db2002bc513d69c9cf3c0 100644 (file)
@@ -6754,13 +6754,17 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
          }
 
        case TRUTH_NOT_EXPR:
-         if (TREE_TYPE (*expr_p) != boolean_type_node)
-           {
-             tree type = TREE_TYPE (*expr_p);
-             *expr_p = fold_convert (type, gimple_boolify (*expr_p));
-             ret = GS_OK;
-             break;
-           }
+         {
+           tree org_type = TREE_TYPE (*expr_p);
+
+           *expr_p = gimple_boolify (*expr_p);
+           if (org_type != boolean_type_node)
+             {
+               *expr_p = fold_convert (org_type, *expr_p);
+               ret = GS_OK;
+               break;
+             }
+         }
 
          ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
                               is_gimple_val, fb_rvalue);
index aa73f5ea3a5c9c681b4d44c1191776d18534eb09..c5fa41637ccbbc18ba3da91fa0693abc66a8e527 100644 (file)
@@ -3342,6 +3342,15 @@ verify_gimple_assign_unary (gimple stmt)
       return false;
 
     case TRUTH_NOT_EXPR:
+      if (!useless_type_conversion_p (boolean_type_node,  rhs1_type))
+        {
+           error ("invalid types in truth not");
+           debug_generic_expr (lhs_type);
+           debug_generic_expr (rhs1_type);
+           return true;
+        }
+      break;
+
     case NEGATE_EXPR:
     case ABS_EXPR:
     case BIT_NOT_EXPR: