Merge from trunk @ 138209
[official-gcc.git] / gcc / testsuite / gnat.dg / allocator_maxalign1.adb
blob062c39bbf8763a7f73e47bf9341ba9745729f6cc
1 -- { dg-do run }
3 with System.Storage_Elements; use System.Storage_Elements;
4 with Ada.Unchecked_Deallocation;
6 procedure Allocator_Maxalign1 is
8 Max_Alignment : constant := Standard'Maximum_Alignment;
10 type Block is record
11 X : Integer;
12 end record;
13 for Block'Alignment use Standard'Maximum_Alignment;
15 type Block_Access is access all Block;
16 procedure Free is new Ada.Unchecked_Deallocation (Block, Block_Access);
18 N_Blocks : constant := 500;
19 Blocks : array (1 .. N_Blocks) of Block_Access;
20 begin
21 if Block'Alignment /= Max_Alignment then
22 raise Program_Error;
23 end if;
25 for K in 1 .. 4 loop
27 for I in Blocks'Range loop
28 Blocks (I) := new Block;
29 if Blocks (I).all'Address mod Block'Alignment /= 0 then
30 raise Program_Error;
31 end if;
32 Blocks(I).all.X := I;
33 end loop;
35 for I in Blocks'Range loop
36 Free (Blocks (I));
37 end loop;
39 end loop;
41 end;