This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Internal cleanups in handling of subtype bounds

This change causes subtype bounds to be captured in special constant
variables xxxL and xxxH, avoiding troublesome cases where the call to
Force_Evaluation generated serialized temporaries that got referenced
publicly. It also means that First/Last can be expanded out in more

No functional test required, since no functional effect, but the
following test:

     1. procedure FLastX (Q, S : in out Integer) is
     2.    subtype R is Integer range 5 .. 10;
     3.    subtype T is Integer range Q .. S;
     4.    M : Integer;
     5. begin
     6.    Q := Q + S;
     7.    S := S + Q;
     8.    M := R'First;
     9.    M := R'Last;
    10.    M := T'First;
    11.    M := T'Last;
    12. end;

generates the following expanded code, showing the changes:

    procedure flastx (q : in out integer; s : in out integer) is
       subtype flastx__r is integer range 5 .. 10;
       tL : constant integer := q;
       tH : constant integer := s;
       subtype flastx__t is integer range tL .. tH;
       m : integer;
       q := q + s;
       s := s + q;
       m := 5;
       m := 10;
       m := tL;
       m := tH;
    end flastx;

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

2014-07-30  Robert Dewar  <>

	* exp_attr.adb (Expand_Attribute, case First): Rewrite simple
	entity reference.
	(Expand_Attribute, case Last): Ditto.
	* exp_ch3.adb (Constrain_Index): New calling sequence for
	(Expand_N_Object_Declaration): Avoid setting Is_Known_Valid in one
	problematical case.
	* sem_ch3.adb (Constrain_Index): New calling sequence for
	(Set_Scalar_Range_For_Subtype): ditto.
	(Process_Range_Expr_In_Decl): Create constants to hold bounds for
	* (Process_Range_Expr_In_Decl): Add Subtyp parameter.
	* sem_eval.adb (Compile_Time_Compare): Make sure we use base
	types if we are not assuming no invalid values.

Attachment: difs
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]