public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch gimplifier]: Make sure TRUTH_NOT_EXPR has boolean_type_node type and argument
@ 2011-05-13 13:57 Kai Tietz
  2011-05-13 13:57 ` Richard Guenther
  2011-05-13 17:53 ` Andrew Pinski
  0 siblings, 2 replies; 23+ messages in thread
From: Kai Tietz @ 2011-05-13 13:57 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Guenther

Hello,

this patch adds a check to

ChangeLog

2011-05-13  Kai Tietz

          * 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.

Bootstrapped for x86_64-pc-linux-gnu (multilib). Ok for apply?

Index: tree-cfg.c
===================================================================
--- tree-cfg.c  (revision 173725)
+++ tree-cfg.c  (working copy)
@@ -3342,6 +3342,14 @@
       return false;

     case TRUTH_NOT_EXPR:
+      if (!useless_type_conversion_p (boolean_type_node,  rhs1_type)
+          || !useless_type_conversion_p (boolean_type_node,  lhs_type))
+        {
+           error ("invalid types in truth not");
+           debug_generic_expr (lhs_type);
+           debug_generic_expr (rhs1_type);
+           return true;
+        }
     case NEGATE_EXPR:
     case ABS_EXPR:
     case BIT_NOT_EXPR:

Index: gimplify.c
===================================================================
--- gimplify.c  (revision 173726)
+++ gimplify.c  (working copy)
@@ -6754,14 +6754,18 @@
          }

        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);
          recalculate_side_effects (*expr_p);

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2011-05-18  6:52 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-13 13:57 [patch gimplifier]: Make sure TRUTH_NOT_EXPR has boolean_type_node type and argument Kai Tietz
2011-05-13 13:57 ` Richard Guenther
2011-05-13 13:59   ` Kai Tietz
2011-05-13 17:46     ` H.J. Lu
2011-05-13 17:53 ` Andrew Pinski
2011-05-13 18:30   ` Kai Tietz
2011-05-13 21:56     ` Kai Tietz
2011-05-13 22:22       ` Andrew Pinski
2011-05-14  7:15   ` Eric Botcazou
2011-05-14 15:50     ` Kai Tietz
2011-05-14 19:46       ` Eric Botcazou
2011-05-14 23:46         ` Kai Tietz
2011-05-15 22:14           ` Eric Botcazou
2011-05-16  0:49             ` Kai Tietz
2011-05-16  0:52               ` Kai Tietz
2011-05-16  2:16               ` Eric Botcazou
2011-05-16  5:01                 ` Eric Botcazou
2011-05-16 13:15         ` Richard Guenther
2011-05-16 13:35           ` Michael Matz
2011-05-16 13:45             ` Richard Guenther
2011-05-16 15:32               ` Michael Matz
2011-05-16 15:37                 ` Richard Guenther
2011-05-18  9:37                   ` Kai Tietz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).