From 5389e4ae852628dd9624537c67588c0f2675dd01 Mon Sep 17 00:00:00 2001 From: Robert Dewar Date: Tue, 26 May 2015 08:12:15 +0000 Subject: [PATCH] exp_ch4.adb (Expand_N_Op_Expon): Deal with problem of wrong order in calling Duplicate_Subexpr. 2015-05-26 Robert Dewar * exp_ch4.adb (Expand_N_Op_Expon): Deal with problem of wrong order in calling Duplicate_Subexpr. * einfo.ads: Fix documentation of Object/Value size for scalar types. From-SVN: r223665 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/einfo.ads | 8 +++++--- gcc/ada/exp_ch4.adb | 19 ++++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index da387055e67..c0d03c39478 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2015-05-26 Robert Dewar + + * exp_ch4.adb (Expand_N_Op_Expon): Deal with problem of wrong + order in calling Duplicate_Subexpr. + * einfo.ads: Fix documentation of Object/Value size for scalar types. + 2015-05-26 Ed Schonberg * exp_aggr.adb (Build_Array_Aggr_Code, Gen_Assign): diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 5a309f914db..b5d776991ef 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -218,11 +218,13 @@ package Einfo is -- subtype x4 is x2'base range 0 .. 10; 8 4 --- subtype x5 is x2 range 0 .. dynamic; 16 (7) +-- dynamic : x2'Base range -64 .. +63; --- subtype x6 is x2'base range 0 .. dynamic; 8 (7) +-- subtype x5 is x2 range 0 .. dynamic; 16 3* --- Note: the entries marked (7) are not actually specified by the Ada 95 RM, +-- subtype x6 is x2'base range 0 .. dynamic; 8 7* + +-- Note: the entries marked * are not actually specified by the Ada 95 RM, -- but it seems in the spirit of the RM rules to allocate the minimum number -- of bits known to be large enough to hold the given range of values. diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 7bd3c6be157..4dcc9be7bb9 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -7779,6 +7779,9 @@ package body Exp_Ch4 is TestS : Boolean; -- Set True if we must test the shift count + Test_Gt : Node_Id; + -- Node for test against TestS + begin -- Compute maximum shift based on the underlying size. For a -- modular type this is one less than the size. @@ -7841,15 +7844,21 @@ package body Exp_Ch4 is -- zero if this shift count is exceeded. if TestS then + + -- Note: build node for the comparison first, before we + -- reuse the Right_Opnd, so that we have proper parents + -- in place for the Duplicate_Subexpr call. + + Test_Gt := + Make_Op_Gt (Loc, + Left_Opnd => Duplicate_Subexpr (Right_Opnd (N)), + Right_Opnd => Make_Integer_Literal (Loc, MaxS)); + Rewrite (N, Make_If_Expression (Loc, Expressions => New_List ( - Make_Op_Gt (Loc, - Left_Opnd => Duplicate_Subexpr (Right_Opnd (N)), - Right_Opnd => Make_Integer_Literal (Loc, MaxS)), - + Test_Gt, Make_Integer_Literal (Loc, Uint_0), - Make_Op_Shift_Left (Loc, Left_Opnd => Make_Integer_Literal (Loc, Uint_1), Right_Opnd => Right_Opnd (N))))); -- 2.30.2