c460009.a

来自「用于进行gcc测试」· A 代码 · 共 468 行 · 第 1/2 页

A
468
字号
         when Constraint_Error =>            Report.Failed ("Constraint_Error exception raised in Proc5");         when others           =>            Report.Failed ("Others exception raised in Proc5");      end;               begin      -- Lengths mismatch in the type conversion, Constraint_Error raised.      Proc5 (Formal(Arr_Obj5));      Report.Failed ("Constraint_Error not raised in the call Proc5");   exception      when Constraint_Error => null;      -- exception expected.      when others           =>         Report.Failed ("Arr_Obj5 - others exception raised");   end;   ---------------------------------------------------------------------------   declare      type Formal is array         (Report.Ident_Int(1) .. 3, 3 .. Report.Ident_Int(1)) of Character;      type Actual is array         (Report.Ident_Int(5) .. 3, 3 .. Report.Ident_Int(5)) of Character;      Arr_Obj6 : Actual := (5 .. 3 => (3 .. 5 => ' '));      procedure Proc6 (P : in out Formal) is      begin         Report.Failed ("No exception raised in Proc6");      exception                when Constraint_Error =>            Report.Failed ("Constraint_Error exception raised in Proc6");         when others           =>            Report.Failed ("Others exception raised in Proc6");      end;               begin      -- Lengths mismatch in the type conversion, Constraint_Error raised.      Proc6 (Formal(Arr_Obj6));      Report.Failed ("Constraint_Error not raised in the call Proc6");   exception      when Constraint_Error => null;      -- exception expected.      when others           =>         Report.Failed ("Arr_Obj6 - others exception raised");   end;   ---------------------------------------------------------------------------   declare      type Formal is array (Int range <>, Int range <>) of Character;      type Actual is array (Positive range 5 .. 2,                            Positive range 1 .. 3) of Character;      Arr_Obj7 : Actual := (5 .. 2 => (1 .. 3 => ' '));      procedure Proc7 (P : in out Formal) is      begin         if P'Last /= 2 and P'Last(2) /= 3 then            Report.Failed ("Wrong bounds passed for Arr_Obj7");         end if;         -- Lengths mismatch, Constraint_Error raised.         P := (1 .. 3 => (3 .. 0 => ' '));         Report.Comment ("Dead assignment prevention in Proc7 => " &                          Integer'Image (P'Last));         Report.Failed ("No exception raised in Proc7");      exception                when Constraint_Error => null;      -- exception expected.         when others           =>            Report.Failed ("Others exception raised in Proc7");      end;               begin      -- Same lengths, no Constraint_Error raised.      Proc7 (Formal(Arr_Obj7));      if Arr_Obj7'Last /= 2 and Arr_Obj7'Last(2) /= 3 then         Report.Failed ("Bounds changed for Arr_Obj7");      end if;   exception      when Constraint_Error =>         Report.Failed ("Constraint_Error exception raised after call Proc7");      when others           =>         Report.Failed ("Arr_Obj7 - others exception raised");   end;   ---------------------------------------------------------------------------   declare      type Arr_Char8 is array (Int range <>, Int range <>) of Character;      subtype Formal is Arr_Char8         (Report.Ident_Int(2) .. 0, 1 .. Report.Ident_Int(3));        Arr_Obj8 : Arr_Char8 (Report.Ident_Int(2) .. Report.Ident_Int(1),                            Report.Ident_Int(1) .. Report.Ident_Int(2));      procedure Proc8 (P : out Formal) is      begin         Report.Failed ("No exception raised in Proc8");      exception                when Constraint_Error =>            Report.Failed ("Constraint_Error exception raised in Proc8");         when others           =>            Report.Failed ("Others exception raised in Proc8");      end;               begin      -- Lengths mismatch in the type conversion, Constraint_Error raised.      Proc8 (Formal(Arr_Obj8));      Report.Failed ("Constraint_Error not raised in the call Proc8");   exception      when Constraint_Error => null;      -- exception expected.      when others           =>         Report.Failed ("Arr_Obj8 - others exception raised");   end;   ---------------------------------------------------------------------------   declare      type Formal is array         (Report.Ident_Int(1) .. 3, 3 .. Report.Ident_Int(1)) of Character;      type Actual is array         (Report.Ident_Int(5) .. 3, 3 .. Report.Ident_Int(5)) of Character;      Arr_Obj9 : Actual;      procedure Proc9 (P : out Formal) is      begin         Report.Failed ("No exception raised in Proc9");      exception                when Constraint_Error =>            Report.Failed ("Constraint_Error exception raised in Proc9");         when others           =>            Report.Failed ("Others exception raised in Proc9");      end;               begin      -- Lengths mismatch in the type conversion, Constraint_Error raised.      Proc9 (Formal(Arr_Obj9));      Report.Failed ("Constraint_Error not raised in the call Proc9");   exception      when Constraint_Error => null;      -- exception expected.      when others           =>         Report.Failed ("Arr_Obj9 - others exception raised");   end;   ---------------------------------------------------------------------------   declare      type Formal is array (Int range <>, Int range <>) of Character;      type Actual is array (Positive range 5 .. 2,                            Positive range 1 .. 3) of Character;      Arr_Obj10 : Actual;      procedure Proc10 (P : out Formal) is      begin         if P'Last /= 2 and P'Last(2) /= 3 then            Report.Failed ("Wrong bounds passed for Arr_Obj10");         end if;         -- Lengths mismatch, Constraint_Error raised.         P := (1 .. 3 => (3 .. 1 => ' '));         Report.Comment ("Dead assignment prevention in Proc10 => " &                          Integer'Image (P'Last));         Report.Failed ("No exception raised in Proc10");      exception                when Constraint_Error => null;      -- exception expected.         when others           =>            Report.Failed ("Others exception raised in Proc10");      end;               begin      -- Same lengths, no Constraint_Error raised.      Proc10 (Formal(Arr_Obj10));      if Arr_Obj10'Last /= 2 and Arr_Obj10'Last(2) /= 3 then         Report.Failed ("Bounds changed for Arr_Obj10");      end if;   exception      when Constraint_Error =>         Report.Failed ("Constraint_Error exception raised after call Proc10");      when others           =>         Report.Failed ("Arr_Obj10 - others exception raised");   end;   ---------------------------------------------------------------------------   Report.Result;end C460009;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?