1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1998-2000, Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 with Atree; use Atree;
30 with Einfo; use Einfo;
31 with Errout; use Errout;
32 with Namet; use Namet;
33 with Sinfo; use Sinfo;
34 with Snames; use Snames;
36 package body Sem_Smem is
38 function Contains_Access_Type (T : Entity_Id) return Boolean;
39 -- This function determines if type T is an access type, or contains
40 -- a component (array, record, protected type cases) that contains
41 -- an access type (recursively defined in the appropriate manner).
43 ----------------------
44 -- Check_Shared_Var --
45 ----------------------
47 procedure Check_Shared_Var
53 -- We cannot tolerate aliased variables, because they might be
54 -- modified via an aliased pointer, and we could not detect that
55 -- this was happening (to update the corresponding shared memory
56 -- file), so we must disallow all use of Aliased
58 if Aliased_Present (N) then
60 ("aliased variables " &
61 "not supported in Shared_Passive partitions",
64 -- We can't support access types at all, since they are local
65 -- pointers that cannot in any simple way be transmitted to other
68 elsif Is_Access_Type (T) then
70 ("access type variables " &
71 "not supported in Shared_Passive partitions",
74 -- We cannot tolerate types that contain access types, same reasons
76 elsif Contains_Access_Type (T) then
78 ("types containing access components " &
79 "not supported in Shared_Passive partitions",
82 -- Currently we do not support unconstrained record types, since we
83 -- use 'Write to write out values. This could probably be special
84 -- cased and handled in the future if necessary.
86 elsif Is_Record_Type (T)
87 and then not Is_Constrained (T)
90 ("unconstrained variant records " &
91 "not supported in Shared_Passive partitions",
96 --------------------------
97 -- Contains_Access_Type --
98 --------------------------
100 function Contains_Access_Type (T : Entity_Id) return Boolean is
104 if Is_Access_Type (T) then
107 elsif Is_Array_Type (T) then
108 return Contains_Access_Type (Component_Type (T));
110 elsif Is_Record_Type (T) then
111 if Has_Discriminants (T) then
112 C := First_Discriminant (T);
113 while Present (C) loop
114 if Comes_From_Source (C) then
117 C := Next_Discriminant (C);
122 C := First_Component (T);
123 while Present (C) loop
125 -- For components, ignore internal components other than _Parent
127 if Comes_From_Source (T)
129 (Chars (C) = Name_uParent
131 not Is_Internal_Name (Chars (C)))
132 and then Contains_Access_Type (Etype (C))
136 C := Next_Component (C);
142 elsif Is_Protected_Type (T) then
143 return Contains_Access_Type (Corresponding_Record_Type (T));
148 end Contains_Access_Type;