1-- PR ada/49732
2-- Testcase by Vorfeed Canal
3
4-- { dg-do compile }
5-- { dg-options "-gnato" }
6
7with Interfaces.C; use Interfaces.C;
8with Interfaces.C.Strings; use Interfaces.C.Strings;
9with Interfaces.C.Pointers;
10
11procedure Pointer_Controlled is
12
13   function Create (Name : String) return size_t is
14
15      type Name_String is new char_array (0 .. Name'Length);
16      type Name_String_Ptr is access Name_String;
17      pragma Controlled (Name_String_Ptr);
18
19      Name_Str : constant Name_String_Ptr := new Name_String;
20      Name_Len : size_t;
21
22   begin
23      To_C (Name, Name_Str.all, Name_Len);
24      return 1;
25   end;
26
27   Test : size_t;
28
29begin
30   Test := Create("ABC");
31end;
32