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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ S M E M --
-- --
-- B o d y --
-- --
-- $Revision: 1.5 $
-- --
-- Copyright (C) 1998-2000, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Einfo; use Einfo;
with Errout; use Errout;
with Namet; use Namet;
with Sinfo; use Sinfo;
with Snames; use Snames;
package body Sem_Smem is
function Contains_Access_Type (T : Entity_Id) return Boolean;
-- This function determines if type T is an access type, or contains
-- a component (array, record, protected type cases) that contains
-- an access type (recursively defined in the appropriate manner).
----------------------
-- Check_Shared_Var --
----------------------
procedure Check_Shared_Var
(Id : Entity_Id;
T : Entity_Id;
N : Node_Id)
is
begin
-- We cannot tolerate aliased variables, because they might be
-- modified via an aliased pointer, and we could not detect that
-- this was happening (to update the corresponding shared memory
-- file), so we must disallow all use of Aliased
if Aliased_Present (N) then
Error_Msg_N
("aliased variables " &
"not supported in Shared_Passive partitions",
N);
-- We can't support access types at all, since they are local
-- pointers that cannot in any simple way be transmitted to other
-- partitions.
elsif Is_Access_Type (T) then
Error_Msg_N
("access type variables " &
"not supported in Shared_Passive partitions",
Id);
-- We cannot tolerate types that contain access types, same reasons
elsif Contains_Access_Type (T) then
Error_Msg_N
("types containing access components " &
"not supported in Shared_Passive partitions",
Id);
-- Currently we do not support unconstrained record types, since we
-- use 'Write to write out values. This could probably be special
-- cased and handled in the future if necessary.
elsif Is_Record_Type (T)
and then not Is_Constrained (T)
then
Error_Msg_N
("unconstrained variant records " &
"not supported in Shared_Passive partitions",
Id);
end if;
end Check_Shared_Var;
--------------------------
-- Contains_Access_Type --
--------------------------
function Contains_Access_Type (T : Entity_Id) return Boolean is
C : Entity_Id;
begin
if Is_Access_Type (T) then
return True;
elsif Is_Array_Type (T) then
return Contains_Access_Type (Component_Type (T));
elsif Is_Record_Type (T) then
if Has_Discriminants (T) then
C := First_Discriminant (T);
while Present (C) loop
if Comes_From_Source (C) then
return True;
else
C := Next_Discriminant (C);
end if;
end loop;
end if;
C := First_Component (T);
while Present (C) loop
-- For components, ignore internal components other than _Parent
if Comes_From_Source (T)
and then
(Chars (C) = Name_uParent
or else
not Is_Internal_Name (Chars (C)))
and then Contains_Access_Type (Etype (C))
then
return True;
else
C := Next_Component (C);
end if;
end loop;
return False;
elsif Is_Protected_Type (T) then
return Contains_Access_Type (Corresponding_Record_Type (T));
else
return False;
end if;
end Contains_Access_Type;
end Sem_Smem;
|