PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gnat.dg / opt47.adb
blobcfe44eb1e657e08803a05c0a02b36fcf8dc83da1
1 -- { dg-do run { target i?86-*-* x86_64-*-* alpha*-*-* ia64-*-* } }
2 -- { dg-options "-O2" }
4 with Ada.Characters.Handling; use Ada.Characters.Handling;
5 with Interfaces; use Interfaces;
6 with Ada.Unchecked_Conversion;
8 procedure Opt47 is
10 subtype String4 is String (1 .. 4);
11 function To_String4 is new Ada.Unchecked_Conversion (Unsigned_32, String4);
12 type Arr is array (Integer range <>) of Unsigned_32;
13 Leaf : Arr (1 .. 4) := (1349478766, 1948272498, 1702436946, 1702061409);
14 Value : Unsigned_32;
15 Result : String (1 .. 32);
16 Last : Integer := 0;
18 begin
19 for I in 1 .. 4 loop
20 Value := Leaf (I);
21 for J in reverse String4'Range loop
22 if Is_Graphic (To_String4 (Value)(J)) then
23 Last := Last + 1;
24 Result (Last) := To_String4 (Value)(J);
25 end if;
26 end loop;
27 end loop;
28 if Result (1) /= 'P' then
29 raise Program_Error;
30 end if;
31 end;