1-- Copyright 2012-2020 Free Software Foundation, Inc. 2-- 3-- This program is free software; you can redistribute it and/or modify 4-- it under the terms of the GNU General Public License as published by 5-- the Free Software Foundation; either version 3 of the License, or 6-- (at your option) any later version. 7-- 8-- This program is distributed in the hope that it will be useful, 9-- but WITHOUT ANY WARRANTY; without even the implied warranty of 10-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11-- GNU General Public License for more details. 12-- 13-- You should have received a copy of the GNU General Public License 14-- along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16with Pck; use Pck; 17 18procedure Foo is 19 20 type Table is array (Positive range <>) of Integer; 21 type Table_Access is access Table; 22 23 type Object (N : Integer) is record 24 Ptr : Table_Access; 25 Data : Table (1 .. N); 26 end record; 27 28 My_Object : Object := (N => 3, Ptr => null, Data => (3, 5, 8)); 29 30 -- Same as above, but with a pointer to an unconstrained packed array. 31 32 type Byte is range 0 .. 255; 33 34 type P_Table is array (Positive range <>) of Byte; 35 pragma Pack (P_Table); 36 type P_Table_Access is access P_Table; 37 38 type P_Object (N : Integer) is record 39 Ptr : P_Table_Access; 40 Data : P_Table (1 .. N); 41 end record; 42 43 My_P_Object : P_Object := (N => 3, Ptr => null, Data => (3, 5, 8)); 44 45begin 46 My_Object.Ptr := new Table'(13, 21, 34); -- STOP1 47 My_P_Object.Ptr := new P_Table'(13, 21, 34); 48 Do_Nothing (My_Object'Address); -- STOP2 49 Do_Nothing (My_P_Object'Address); 50end Foo; 51 52