1 1.11 christos -- Copyright 2009-2024 Free Software Foundation, Inc. 2 1.1 christos -- 3 1.1 christos -- This program is free software; you can redistribute it and/or modify 4 1.1 christos -- it under the terms of the GNU General Public License as published by 5 1.1 christos -- the Free Software Foundation; either version 3 of the License, or 6 1.1 christos -- (at your option) any later version. 7 1.1 christos -- 8 1.1 christos -- This program is distributed in the hope that it will be useful, 9 1.1 christos -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos -- GNU General Public License for more details. 12 1.1 christos -- 13 1.1 christos -- You should have received a copy of the GNU General Public License 14 1.1 christos -- along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos -- This program declares a bunch of unconstrained objects and 17 1.1 christos -- discrinimated records; the goal is to check that GDB does not crash 18 1.1 christos -- when printing them even if they are not initialized. 19 1.1 christos 20 1.1 christos with Parse_Controlled; 21 1.1 christos 22 1.1 christos procedure Parse is -- START 23 1.1 christos 24 1.1 christos A : aliased Integer := 1; 25 1.1 christos 26 1.1 christos type Access_Type is access all Integer; 27 1.1 christos 28 1.1 christos type String_Access is access String; 29 1.1 christos 30 1.1 christos type My_Record is record 31 1.1 christos Field1 : Access_Type; 32 1.1 christos Field2 : String (1 .. 2); 33 1.1 christos end record; 34 1.1 christos 35 1.1 christos type Discriminants_Record (A : Integer; B : Boolean) is record 36 1.1 christos C : Float; 37 1.1 christos end record; 38 1.1 christos Z : Discriminants_Record := (A => 1, B => False, C => 2.0); 39 1.1 christos 40 1.1 christos type Variable_Record (A : Boolean := True) is record 41 1.1 christos case A is 42 1.1 christos when True => 43 1.1 christos B : Integer; 44 1.1 christos when False => 45 1.1 christos C : Float; 46 1.1 christos D : Integer; 47 1.1 christos end case; 48 1.1 christos end record; 49 1.1 christos Y : Variable_Record := (A => True, B => 1); 50 1.1 christos Y2 : Variable_Record := (A => False, C => 1.0, D => 2); 51 1.1 christos Nv : Parse_Controlled.Null_Variant; 52 1.1 christos 53 1.1 christos type Union_Type (A : Boolean := False) is record 54 1.1 christos case A is 55 1.1 christos when True => B : Integer; 56 1.1 christos when False => C : Float; 57 1.1 christos end case; 58 1.1 christos end record; 59 1.1 christos pragma Unchecked_Union (Union_Type); 60 1.1 christos Ut : Union_Type := (A => True, B => 3); 61 1.1 christos 62 1.1 christos type Tagged_Type is tagged record 63 1.1 christos A : Integer; 64 1.1 christos B : Character; 65 1.1 christos end record; 66 1.1 christos Tt : Tagged_Type := (A => 2, B => 'C'); 67 1.1 christos 68 1.1 christos type Child_Tagged_Type is new Tagged_Type with record 69 1.1 christos C : Float; 70 1.1 christos end record; 71 1.1 christos Ctt : Child_Tagged_Type := (Tt with C => 4.5); 72 1.1 christos 73 1.1 christos type Child_Tagged_Type2 is new Tagged_Type with null record; 74 1.1 christos Ctt2 : Child_Tagged_Type2 := (Tt with null record); 75 1.1 christos 76 1.1 christos type My_Record_Array is array (Natural range <>) of My_Record; 77 1.1 christos W : My_Record_Array := ((Field1 => A'Access, Field2 => "ab"), 78 1.1 christos (Field1 => A'Access, Field2 => "rt")); 79 1.1 christos 80 1.1 christos type Discriminant_Record (Num1, Num2, 81 1.1 christos Num3, Num4 : Natural) is record 82 1.1 christos Field1 : My_Record_Array (1 .. Num2); 83 1.1 christos Field2 : My_Record_Array (Num1 .. 10); 84 1.1 christos Field3 : My_Record_Array (Num1 .. Num2); 85 1.1 christos Field4 : My_Record_Array (Num3 .. Num2); 86 1.1 christos Field5 : My_Record_Array (Num4 .. Num2); 87 1.1 christos end record; 88 1.1 christos Dire : Discriminant_Record (1, 7, 3, 0); 89 1.1 christos 90 1.1 christos type Null_Variant_Part (Discr : Integer) is record 91 1.1 christos case Discr is 92 1.1 christos when 1 => Var_1 : Integer; 93 1.1 christos when 2 => Var_2 : Boolean; 94 1.1 christos when others => null; 95 1.1 christos end case; 96 1.1 christos end record; 97 1.1 christos Nvp : Null_Variant_Part (3); 98 1.1 christos 99 1.1 christos type T_Type is array (Positive range <>) of Integer; 100 1.1 christos type T_Ptr_Type is access T_Type; 101 1.1 christos 102 1.1 christos T_Ptr : T_Ptr_Type := new T_Type' (13, 17); 103 1.1 christos T_Ptr2 : T_Ptr_Type := new T_Type' (2 => 13, 3 => 17); 104 1.1 christos 105 1.1 christos function Foos return String is 106 1.1 christos begin 107 1.1 christos return "string"; 108 1.1 christos end Foos; 109 1.1 christos 110 1.1 christos My_Str : String := Foos; 111 1.1 christos 112 1.1 christos type Value_Var_Type is ( V_Null, V_Boolean, V_Integer ); 113 1.1 christos type Value_Type( Var : Value_Var_Type := V_Null ) is 114 1.1 christos record 115 1.1 christos case Var is 116 1.1 christos when V_Null => 117 1.1 christos null; 118 1.1 christos when V_Boolean => 119 1.1 christos Boolean_Value : Boolean; 120 1.1 christos when V_Integer => 121 1.1 christos Integer_Value : Integer; 122 1.1 christos end case; 123 1.1 christos end record; 124 1.1 christos NBI_N : Value_Type := (Var => V_Null); 125 1.1 christos NBI_I : Value_Type := (Var => V_Integer, Integer_Value => 18); 126 1.1 christos NBI_B : Value_Type := (Var => V_Boolean, Boolean_Value => True); 127 1.1 christos 128 1.1 christos begin 129 1.1 christos null; 130 1.1 christos end Parse; 131