From patchwork Wed May 16 07:19:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 159540 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 5546AB6FC3 for ; Wed, 16 May 2012 17:20:07 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1337757608; h=Comment: DomainKey-Signature:Received:Received:Received:Received:From:To: Subject:Date:Message-Id:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=hWn3Q5H09LfoS9wEc92EghDbx1o=; b=v1kXZtkKg6McsBA bTmlsMDo2louGLZzfcm/cKJGy7WjhlKkkpZFIO2g/ai70Y4gh6FEJJyP5eoiehPN 4rZCw420ZlQkAU8Js3sb0EgWbzYSDzS5r3NtOX9ySmgnHZ2ewZCUlTDoL9YF0Yyb ub1MygHZvxl0FhrTL83SXzmS80oU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:From:To:Subject:Date:Message-Id:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Yn1/FlmI9/PVPe3cyyV8y9uxehS5KMxmnFXlkPaMoFU/y6uarBP/w4T3m4I6tK NrQLVtoFUsRTX+9c9zHcL92gygBHAwvQKu36vAz57kMqX0Tj9i80xLZ9kZHOO+ds QQsVK9ilv8aud0lQ6mY1Sy0Ho3udmjVRNRNUb/UsxCs5Y=; Received: (qmail 25373 invoked by alias); 16 May 2012 07:19:56 -0000 Received: (qmail 25347 invoked by uid 22791); 16 May 2012 07:19:54 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 16 May 2012 07:19:41 +0000 Received: from bonzini by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1SUYWJ-0007kG-Qe for gcc-patches@gcc.gnu.org; Wed, 16 May 2012 03:19:39 -0400 From: Paolo Bonzini To: gcc-patches@gcc.gnu.org Subject: [PATCH] relax constraint on integral<->offset conversions (PR53336) Date: Wed, 16 May 2012 09:19:37 +0200 Message-Id: <1337152777-8102-1-git-send-email-bonzini@gnu.org> 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 OFFSET_TYPE is treated as an integral type for the purpose of conversion in fold-const.c. However, the GIMPLE verifier disagrees, leading to verification errors when a cast from boolean to offset type is gimplified. Bootstrapped/regtested x86_64-pc-linux-gnu, ok for mainline? Paolo 2012-05-16 Paolo Bonzini * tree-cfg.c (verify_gimple_assign_unary): Allow conversion from non-integer integral types to offset type and vice versa. 2012-05-16 Paolo Bonzini * g++.dg/torture/pr53336.C: New testcase. Index: tree-cfg.c =================================================================== --- tree-cfg.c (revisione 186903) +++ tree-cfg.c (copia locale) @@ -3374,11 +3374,11 @@ verify_gimple_assign_unary (gimple stmt) || ptrofftype_p (sizetype)))) return false; - /* Allow conversion from integer to offset type and vice versa. */ + /* Allow conversion from integral to offset type and vice versa. */ if ((TREE_CODE (lhs_type) == OFFSET_TYPE - && TREE_CODE (rhs1_type) == INTEGER_TYPE) + && INTEGRAL_TYPE_P (rhs1_type)) || (TREE_CODE (lhs_type) == INTEGER_TYPE - && TREE_CODE (rhs1_type) == OFFSET_TYPE)) + && INTEGRAL_TYPE_P (rhs1_type))) return false; /* Otherwise assert we are converting between types of the Index: testsuite/g++.dg/torture/pr53336.C =================================================================== --- testsuite/g++.dg/torture/pr53336.C (revisione 0) +++ testsuite/g++.dg/torture/pr53336.C (revisione 0) @@ -0,0 +1,45 @@ +// { dg-do compile } + +bool foo(); + +struct C +{ + C() + { + if (foo()) + foo(); + } +}; + +struct S +{ + struct dummy + { + int i_; + }; + typedef int dummy::*bool_type; + + operator bool_type() const + { + return foo() ? &dummy::i_ : 0; + } +}; + +int x; + +struct adaptor +{ + C c; + + virtual void bar() + { + if (S()) + x = 0; + } +}; + +int main() +{ + adaptor a; +} +