diff mbox

[Ada] Fix ICE on loop with modular iteration variable

Message ID 1474470.x324bNpRni@polaris
State New
Headers show

Commit Message

Eric Botcazou Oct. 22, 2012, 8:16 a.m. UTC
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.
diff mbox

Patch

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;