diff mbox

[Ada] Special case for case expression alternative moved in caller

Message ID 20121029095538.GA14620@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 29, 2012, 9:55 a.m. UTC
Is_Signed_Integer_Arithmetic_Op is called to recognize an arithmetic operation
on signed integers, or on if expressions and case expressions whose dependent
expressions are arithmetic operation on signed integers. A special case was
included for N_Case_Expression_Alternative which should have been included in
the caller Apply_Arithmetic_Overflow_Minimized_Eliminated.  Now done.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-10-29  Yannick Moy  <moy@adacore.com>

	* checks.adb (Apply_Arithmetic_Overflow_Minimized_Eliminated):
	Add special case for case expression alternative.
	(Is_Signed_Integer_Arithmetic_Op): Remove special case for case
	expression alternative.
	* exp_ch4.adb Minor reformatting.
diff mbox

Patch

Index: checks.adb
===================================================================
--- checks.adb	(revision 192908)
+++ checks.adb	(working copy)
@@ -1108,8 +1108,12 @@ 
         or else Nkind (P) in N_Membership_Test
         or else Nkind (P) in N_Op_Compare
 
-        --  We may also be a range operand in a membership test
+        --  This is also true for an alternative in a case expression
 
+        or else Nkind (P) = N_Case_Expression_Alternative
+
+        --  This is also true for a range operand in a membership test
+
         or else (Nkind (P) = N_Range
                   and then Nkind (Parent (P)) in N_Membership_Test)
       then
@@ -6268,9 +6272,6 @@ 
          when N_If_Expression | N_Case_Expression =>
             return Is_Signed_Integer_Type (Etype (N));
 
-         when N_Case_Expression_Alternative =>
-            return Is_Signed_Integer_Type (Etype (Parent (N)));
-
          when others =>
             return False;
       end case;
Index: exp_ch4.adb
===================================================================
--- exp_ch4.adb	(revision 192908)
+++ exp_ch4.adb	(working copy)
@@ -3877,8 +3877,8 @@ 
          end if;
 
       --  Right operand is a subtype name and the subtype has a predicate. We
-      --  have to make sure predicate is checked, and for that we need to use
-      --  the standard N_In circuitry with appropriate types.
+      --  have to make sure the predicate is checked, and for that we need to
+      --  use the standard N_In circuitry with appropriate types.
 
       else
          pragma Assert (Present (Predicate_Function (Etype (Rop))));
@@ -3921,7 +3921,7 @@ 
             --       Bnn
             --   end
 
-            --  A bit gruesome, but here goes.
+            --  A bit gruesome, but there doesn't seem to be a simpler way
 
             declare
                Blk : constant Node_Id   := Make_Bignum_Block (Loc);
@@ -3937,10 +3937,8 @@ 
 
                Nin :=
                  Make_In (Loc,
-                   Left_Opnd =>
-                     Convert_To (Base_Type (Etype (Rop)),
-                       New_Occurrence_Of (Lnn, Loc)),
-                   Right_Opnd => New_Occurrence_Of (Etype (Rop), Loc));
+                   Left_Opnd  => Convert_To (TB, New_Occurrence_Of (Lnn, Loc)),
+                   Right_Opnd => New_Occurrence_Of (T, Loc));
                Set_No_Minimize_Eliminate (Nin);
 
                --  Now decorate the block