summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/tls1.adb
blob: d45105d719c9b4aab7d8e1c84f44e455b9d767be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--  { dg-do run }

with Text_IO; use Text_IO;
with TLS1_Pkg; use TLS1_Pkg;

procedure TLS1 is
  Result : Integer;

  task type T is
     entry Change (Inc : Integer);
     entry Sum (Result : out Integer);
  end T;

  task body T is
  begin
      accept Change (Inc : Integer) do
         for I in My_Array.data'range loop
           My_Array.Data (I).Point := Inc;
         end loop;
      end;

      accept Sum (Result : out Integer) do
         Result := 0;
         for I in My_Array.data'range loop
           Result := Result + My_Array.Data (I).Point;
         end loop;
      end;
   end T;

   Gang : array (1..10) of T;

begin
   for J in Gang'range loop
      Gang (J).Change (J);
   end loop;

   -- Verify the contents of each local thread storage.

   for J in Gang'range loop
      Gang (J).Sum (Result);
      pragma Assert (Result = J * 500);
   end loop;

 --  Verify that original data is unaffected.

   for J in My_Array.Data'range loop
      Result := Result + My_Array.Data (J).Point;
   end loop;

   pragma Assert (Result = 500);
end TLS1;