view gcc/testsuite/gnat.dg/pack19.adb @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

-- { dg-do run }

procedure Pack19 is

   subtype Always_False is Boolean range False .. False;

   type Rec1 is record
      B1 : Boolean;
      B2 : Boolean;
      B3 : Boolean;
      B4 : Boolean;
      B5 : Boolean;
      B6 : Boolean;
      B7 : Always_False;
      B8 : Boolean;
   end record;
   pragma Pack (Rec1);

   subtype Always_True is Boolean range True .. True;

   type Rec2 is record
      B1 : Boolean;
      B2 : Boolean;
      B3 : Boolean;
      B4 : Boolean;
      B5 : Boolean;
      B6 : Boolean;
      B7 : Always_True;
      B8 : Boolean;
   end record;
   pragma Pack (Rec2);

   R1 : Rec1 := (True, True, True, True, True, True, False, False);
   R2 : Rec2 := (False, False, False, False, False, False, True, True);

begin
   R1.B8 := True;
   if R1.B7 /= False then
      raise Program_Error;
   end if;

   R1.B7 := False;
   if R1.B7 /= False then
      raise Program_Error;
   end if;

   R2.B8 := False;
   if R2.B7 /= True then
      raise Program_Error;
   end if;

   R2.B7 := True;
   if R2.B7 /= True then
      raise Program_Error;
   end if;
end;