Preserving locations for variable-uses and constants (PR c++/43486)
[official-gcc.git] / gcc / testsuite / gnat.dg / opt50_pkg.adb
blob0f92f7dcf532afa3e98fa8e49a20f4e24ca2cfd4
1 with Ada.Characters.Handling;
2 with Ada.Containers;
3 with Ada.Containers.Indefinite_Hashed_Maps;
4 with Ada.Strings.Hash;
6 package body Opt50_Pkg is
8 type Enum_Name is array (Enum) of access constant String;
10 Enum_Name_Table : constant Enum_Name := (
11 One => new String'("one"),
12 Two => new String'("two"),
13 Three => new String'("three"));
15 package String_To_Enum_Map is new Ada.Containers.Indefinite_Hashed_Maps
16 (Key_Type => String, Element_Type => Enum,
17 Hash => Ada.Strings.Hash, Equivalent_Keys => "=");
19 function Fill_Hashed_Map return String_To_Enum_Map.Map is
20 Res : String_To_Enum_Map.Map;
21 use String_To_Enum_Map;
22 begin
23 for I in Enum_Name_Table'Range loop
24 declare
25 Kind : constant String := Enum_Name_Table (I).all;
26 begin
27 Res.Insert(Key => Kind, New_Item => I);
28 end;
29 end loop;
30 return Res;
31 end;
33 String_To_Enum : constant String_To_Enum_Map.Map := Fill_Hashed_Map;
35 procedure Get (Kind : String; Result : out Enum; Success : out Boolean) is
36 X : constant String := Ada.Characters.Handling.To_Lower (Kind);
37 use String_To_Enum_Map;
38 Curs : constant Cursor := String_To_Enum.Find (X);
39 begin
40 Success := Curs /= No_Element;
41 if Success then
42 Result := Element(Curs);
43 end if;
44 end;
46 procedure Set (A : Enum_Boolean_Array) is null;
48 end Opt50_Pkg;