PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gnat.dg / delta_aggr.adb
blob57e0a69693a4428db3cfbc34d7fe851353917641
1 -- { dg-do compile }
2 -- { dg-options "-gnat2020" }
4 procedure Delta_Aggr is
5 type T1 is tagged record
6 F1, F2, F3 : Integer := 0;
7 end record;
9 function Make (X : Integer) return T1 is
10 begin
11 return (10, 20, 30);
12 end Make;
14 package Pkg is
15 type T2 is new T1 with private;
16 X, Y : constant T2;
17 function Make (X : Integer) return T2;
18 private
19 type T2 is new T1 with
20 record
21 F4 : Integer := 0;
22 end record;
23 X : constant T2 := (0, 0, 0, 0);
24 Y : constant T2 := (1, 2, 0, 0);
25 end Pkg;
27 package body Pkg is
28 function Make (X : Integer) return T2 is
29 begin
30 return (X, X ** 2, X ** 3, X ** 4);
31 end Make;
32 end Pkg;
34 use Pkg;
36 Z : T2 := (Y with delta F1 => 111);
38 -- a legal delta aggregate whose type is a private extension
39 pragma Assert (Y = (X with delta F1 => 1, F2 => 2));
40 pragma assert (Y.F2 = X.F1);
42 begin
43 Z := (X with delta F1 => 1);
45 -- The base of the delta aggregate can be overloaded, in which case
46 -- the candidate interpretations for the aggregate are those of the
47 -- base, to be resolved from context.
49 Z := (Make (2) with delta F1 => 1);
50 null;
51 end Delta_Aggr;