From patchwork Mon Oct 22 08:16:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 193107 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 1EE1D2C00A8 for ; Mon, 22 Oct 2012 19:23:52 +1100 (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=1351499033; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=k0KP9XJSlbRf/4BF/72XWxFj3j4=; b=r4b/iDuPNU3OGSy 8tayGy84lLORorAogfPmSv86Bk2pKDuU6xLS3MqbQ4oKnZaRoA7XQOdtr5gsqYdh 1zO+zE2mwWH55h2C/rW9KtJJXt5Fsp8cRSbsNZWvRU0zxCnwqmvW78H3hZiFvHNk P+PfvnPkGC6P2XKec3JzK54El7yU= 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:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=byA6TIQ0qq/OiBRLPlR5QCiWt1mTEdfQ15oJ09qe5lBriNz1RFpPOmcUB/LABc fkJ9I1lKD9kRAqnJrlRfvei0JMoT10D/uOg7y5Pqd20VSXe2BGOMrv6tyikWhXyA mVgjXid4kdMIllyC7UHxrgg7taSH6dt5lhAHgUgL2G9PA=; Received: (qmail 8792 invoked by alias); 22 Oct 2012 08:23:49 -0000 Received: (qmail 8784 invoked by uid 22791); 22 Oct 2012 08:23:48 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Oct 2012 08:23:42 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 83E64290B01 for ; Mon, 22 Oct 2012 10:23:41 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vbo5xCCaa45t for ; Mon, 22 Oct 2012 10:23:41 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 4FF02290B00 for ; Mon, 22 Oct 2012 10:23:41 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on loop with modular iteration variable Date: Mon, 22 Oct 2012 10:16 +0200 Message-ID: <1474470.x324bNpRni@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.16-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 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 This is a regression at -O present on mainline and 4.7 branch. The compiler inadvertently uses a non-base type for the base type of a modular iteration variable on 32-bit architectures. Tested on x86_64-suse-linux, applied on the mainline and 4.7 branch. 2012-10-22 Eric Botcazou * gcc-interface/trans.c (Loop_Statement_to_gnu): Use gnat_type_for_size directly to obtain an unsigned version of the base type. 2012-10-22 Eric Botcazou * gnat.dg/modular4.adb: New test. * gnat.dg/modular4_pkg.ads: New helper. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 192648) +++ gcc-interface/trans.c (working copy) @@ -2431,7 +2431,8 @@ Loop_Statement_to_gnu (Node_Id gnat_node { if (TYPE_PRECISION (gnu_base_type) > TYPE_PRECISION (size_type_node)) - gnu_base_type = gnat_unsigned_type (gnu_base_type); + gnu_base_type + = gnat_type_for_size (TYPE_PRECISION (gnu_base_type), 1); else gnu_base_type = size_type_node;