orng[0] = -orng[1] - 1;
}
- /* Convert the array index range determined above to a byte
- offset. */
+ /* Convert the array index range determined above to a byte offset. */
tree lowbnd = array_ref_low_bound (aref);
- if (!integer_zerop (lowbnd) && tree_fits_uhwi_p (lowbnd))
- {
- /* Adjust the index by the low bound of the array domain
- (normally zero but 1 in Fortran). */
- unsigned HOST_WIDE_INT lb = tree_to_uhwi (lowbnd);
+ if (TREE_CODE (lowbnd) == INTEGER_CST && !integer_zerop (lowbnd))
+ {
+ /* Adjust the index by the low bound of the array domain (0 in C/C++,
+ 1 in Fortran and anything in Ada) by applying the same processing
+ as in get_offset_range. */
+ const wide_int wlb = wi::to_wide (lowbnd);
+ signop sgn = SIGNED;
+ if (TYPE_UNSIGNED (TREE_TYPE (lowbnd))
+ && wlb.get_precision () < TYPE_PRECISION (sizetype))
+ sgn = UNSIGNED;
+ const offset_int lb = offset_int::from (wlb, sgn);
orng[0] -= lb;
orng[1] -= lb;
}
--- /dev/null
+-- { dg-do run }
+-- { dg-options "-O2 -flto" { target lto } }
+
+with Ada.Streams; use Ada.Streams;
+with Lto26_Pkg1; use Lto26_Pkg1;
+
+procedure Lto26 is
+ R : Rec;
+begin
+ for I in 1 .. 10 loop
+ Set (R, (7, 0, 84, Stream_Element (I), 0, 0, 0), 1);
+ end loop;
+end;
--- /dev/null
+with Lto26_Pkg2; use Lto26_Pkg2;
+
+package body Lto26_Pkg1 is
+
+ procedure Set (R : Rec; A : Stream_Element_Array; C :Unsigned_8) is
+ procedure My_Build is new Build;
+ begin
+ My_Build (A, C);
+ end;
+
+end Lto26_Pkg1;
--- /dev/null
+with Ada.Finalization;
+with Ada.Streams; use Ada.Streams;
+with Interfaces; use Interfaces;
+
+package Lto26_Pkg1 is
+
+ type Rec is new Ada.Finalization.Limited_Controlled with null record;
+
+ procedure Set (R : Rec; A : Stream_Element_Array; C :Unsigned_8);
+
+end Lto26_Pkg1;
--- /dev/null
+package body Lto26_Pkg2 is
+
+ procedure Build (A : Stream_Element_Array; C : Unsigned_8) is
+ Start : Stream_Element_Offset := A'First;
+ Next : Stream_Element_Offset;
+ Length : Unsigned_8;
+ begin
+ for I in 1 .. C loop
+ Length := Unsigned_8 (A (A'First));
+ Next := Start + Stream_Element_Offset (Length);
+ Start := Next;
+ end loop;
+ end;
+
+end Lto26_Pkg2;
--- /dev/null
+with Ada.Streams; use Ada.Streams;
+with Interfaces; use Interfaces;
+
+package Lto26_Pkg2 is
+
+ generic
+ procedure Build (A : Stream_Element_Array; C : Unsigned_8);
+
+end Lto26_Pkg2;