| 1 |
-- { dg-do compile } |
| 2 |
|
| 3 |
with Ada.Text_IO; |
| 4 |
|
| 5 |
procedure Inline_Always1 is |
| 6 |
|
| 7 |
function S(N : Integer ) return String is |
| 8 |
begin |
| 9 |
return "hello world"; |
| 10 |
end S; |
| 11 |
|
| 12 |
type String_Access is access all String; |
| 13 |
type R is record |
| 14 |
SA : String_Access; |
| 15 |
end record; |
| 16 |
|
| 17 |
Data : aliased String := "hello world"; |
| 18 |
My_SA : constant String_Access := Data'Access; |
| 19 |
function Make_R( S : String ) return R is |
| 20 |
My_R : R; |
| 21 |
begin |
| 22 |
My_R.SA := My_SA; |
| 23 |
return My_R; |
| 24 |
end Make_R; |
| 25 |
|
| 26 |
function Get_String( My_R : R ) return String |
| 27 |
is |
| 28 |
begin |
| 29 |
return S : String(My_R.SA.all'Range) do |
| 30 |
S := My_R.SA.all; |
| 31 |
end return; |
| 32 |
end Get_String; |
| 33 |
pragma Inline_Always( Get_String); |
| 34 |
|
| 35 |
My_R : constant R := Make_R( "hello world"); |
| 36 |
begin |
| 37 |
for I in 1..10000 loop |
| 38 |
declare |
| 39 |
Res : constant String := S( 4 ); |
| 40 |
begin |
| 41 |
Ada.Text_IO.Put_Line(Res); |
| 42 |
end; |
| 43 |
declare |
| 44 |
Res : constant String := S( 4 ); |
| 45 |
begin |
| 46 |
Ada.Text_IO.Put_Line(Res); |
| 47 |
end; |
| 48 |
|
| 49 |
declare |
| 50 |
S : constant String := Get_String( My_R ); |
| 51 |
begin |
| 52 |
Ada.Text_IO.Put_Line(S); |
| 53 |
Ada.Text_IO.Put_Line(My_R.SA.all); |
| 54 |
end; |
| 55 |
end loop; |
| 56 |
|
| 57 |
end Inline_Always1; |