From patchwork Fri May 13 11:31:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 95462 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0886BB6EED for ; Fri, 13 May 2011 21:32:00 +1000 (EST) Received: (qmail 29834 invoked by alias); 13 May 2011 11:31:59 -0000 Received: (qmail 29824 invoked by uid 22791); 13 May 2011 11:31:57 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 May 2011 11:31:42 +0000 Received: by qwh5 with SMTP id 5so1410316qwh.20 for ; Fri, 13 May 2011 04:31:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.65.218 with SMTP id k26mr1018649qci.270.1305286301309; Fri, 13 May 2011 04:31:41 -0700 (PDT) Received: by 10.229.33.209 with HTTP; Fri, 13 May 2011 04:31:41 -0700 (PDT) Date: Fri, 13 May 2011 13:31:41 +0200 Message-ID: Subject: [patch gimplifier]: Make sure TRUTH_NOT_EXPR has boolean_type_node type and argument From: Kai Tietz To: GCC Patches Cc: Richard Guenther X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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);