This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Fix ICE on loop with modular iteration variable
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 Oct 2012 10:16 +0200
- Subject: [Ada] Fix ICE on loop with modular iteration variable
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 <ebotcazou@adacore.com>
* 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 <ebotcazou@adacore.com>
* gnat.dg/modular4.adb: New test.
* gnat.dg/modular4_pkg.ads: New helper.
--
Eric Botcazou
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;
-- { dg-do compile }
-- { dg-options "-O" }
with Modular4_Pkg; use Modular4_Pkg;
procedure Modular4 is
begin
for I in Zero .. F mod 8 loop
raise Program_Error;
end loop;
end;
package Modular4_Pkg is
type Word is mod 2**48;
Zero : constant Word := 0;
function F return Word;
end Modular4_Pkg;