1pragma Ada_2005; 2procedure T_allocators is 3 procedure Anonymous is separate; 4 5 type Acc1 is access Integer; 6 type Acc1c1 is access Positive; 7 type Acc1c2 is access Integer range 1..10; 8 type Acc2 is access String; 9 10 type Int is range 1..10; 11 type Acc3 is access Int; 12 type Acc3c is access T_Allocators.Int'Base; 13 14 subtype Str10 is Wide_String (1 .. 10); 15 type Acc4 is access Wide_String; 16 type Acc4c is access Str10; 17 18 type Arr is array (1 .. 10) of Integer; 19 type Acc_Arr is access Arr; 20 type Der is new Arr; 21 type Acc_Der is access Der; 22 23 package Pack is 24 type Priv is private; 25 type Acc_Priv is access Priv; 26 private 27 type Priv is new Arr; 28 end Pack; 29 use Pack; 30 31 type Rec is null record; 32 type Acc_Rec is access Rec; 33 34 task type T1; 35 task body T1 is 36 begin 37 null; 38 end T1; 39 type Acc_T1 is access T1; 40 41 task type T2; 42 task body T2 is 43 begin 44 null; 45 end T2; 46 type Acc_T2 is access T2; 47 48 protected type P1 is 49 procedure Proc; 50 end P1; 51 protected body P1 is 52 procedure Proc is 53 begin 54 null; 55 end Proc; 56 end P1; 57 type Acc_P1 is access P1; 58 59 protected type P2 is 60 procedure Proc; 61 end P2; 62 protected body P2 is 63 procedure Proc is 64 begin 65 null; 66 end Proc; 67 end P2; 68 type Acc_P2 is access P2; 69 70 type Tag1 is tagged null record; 71 subtype Tag_Class is Tag1'Class; 72 type Acc_Tag1 is access Tag1; 73 type Acc_Tag_Class is access Tag_Class; 74 75 generic 76 package Gen is 77 type Gen_T is digits 5; 78 end Gen; 79 package Inst is new Gen; 80 type Acc_Gen_T is access Inst.Gen_T; 81 82 V1 : Acc1; 83 V1_2: Acc1c2; 84 V2 : Acc2; 85 V3 : Acc_T1; 86 V4 : Acc_T2; 87 V5 : Acc_P1; 88 V6 : Acc_P2; 89 V7 : Acc_Tag1; 90 V8 : Acc_Tag_Class; 91 V9 : Acc_Gen_T; 92 V10 : Acc1c1; 93 V11 : Acc3; 94 V12 : Acc3c; 95 V13 : Acc4; 96 V14 : Acc4c; 97 V15 : Acc_Arr; 98 V16 : Acc_Der; 99 V17 : Acc_Priv; 100 V18 : Acc_Rec; 101 V19 : access Wide_Wide_String; 102begin 103 V1 := new Integer; -- ALL 104 V1 := new Integer'(1); -- ALL 105 V1 := new Standard.Integer'Base'(1); -- Inconsistent 106 V1_2 := new Integer; -- Inconsistent 107 V1_2 := new Integer'(4); -- Inconsistent 108 V2 := new String (1..3); -- Allocator for String 109 V2 := new String'("Hello world!"); -- Allocator for String 110 V3 := new T1; -- Specific_Task 111 V4 := new T2; -- All_Tasks 112 V5 := new P1; -- Specific_Prot 113 V6 := new P2; -- All_Prot 114 V7 := new Tag1; -- Tagged 115 V7 := new Tag1'(null record); -- Tagged 116 V8 := new Tag1; -- Tagged 117 V8 := new Tag1'(V7.all); -- Tagged 118 V8 := new Tag1'Class'(Tag1'Class(V7.all)); -- Class1 119 V8 := new Tag_Class'(Tag_Class (V7.all)); -- Class1 120 V9 := new Inst.Gen_T; -- From_Gen 121 122 V1 := new Integer'(3); -- ALL 123 V1 := new Positive'(3); -- Inconsistent 124 V10 := new Integer'(3); -- Inconsistent 125 V10 := new Positive'(3); -- ALL 126 127 V11 := new Int'(1); -- ALL 128 V11 := new Int'Base'(1); -- Inconsistent 129 V12 := new Int'(1); -- All 130 V12 := new Int'Base'(1); -- All 131 132 V13 := new Str10; -- All_Arrays 133 V13 := new Wide_String (1 .. 10); -- All_Arrays 134 V13 := new Wide_String (1 .. 20); -- All_Arrays 135 136 V14 := new Str10; -- All_Arrays 137 V14 := new Wide_String (1 .. 10); -- Inconsistent 138 V14 := new Wide_String (1 .. 20); -- Inconsistent 139 140 V15 := new Arr; -- All_Arrays 141 V16 := new Der; -- All_Arrays 142 V17 := new Priv; -- All_Arrays 143 V18 := new Rec; -- All_Records 144 145 V19 := new Wide_Wide_String'("ABCD"); -- OK, not Wide_Wide_String 146 V19 := new Wide_Wide_String (1..100); -- OK, not Wide_Wide_String 147end T_allocators; 148