Debian Codegraph @

gcc/testsuite/gnat.dg/casesi.adb

raw
1 with Ada.Assertions;
2 package body Casesi is
3
4 function Process (X : Natural) return String is
5 begin
6 case X is
7 when 0 => raise Ada.Assertions.Assertion_Error;
8 when 1 => raise Ada.Assertions.Assertion_Error;
9 when 2 => return (1 .. 4 => 'T');
10 when 3 => return (2 .. 8 => 'T');
11 when 4 => return "hello";
12 when others => return (1 .. 0 => <>);
13 end case;
14 end;
15
16 procedure Try (X : Natural) is
17 begin
18 declare
19 Code : String := Process (X);
20 begin
21 if X < 2 then
22 raise Program_Error;
23 end if;
24 end;
25 exception
26 when Ada.Assertions.Assertion_Error => null;
27 end;
28 end;