annotate gcc/ada/sem_smem.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S E M _ S M E M --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1998-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 with Atree; use Atree;
kono
parents:
diff changeset
27 with Einfo; use Einfo;
kono
parents:
diff changeset
28 with Errout; use Errout;
kono
parents:
diff changeset
29 with Namet; use Namet;
kono
parents:
diff changeset
30 with Sem_Aux; use Sem_Aux;
kono
parents:
diff changeset
31 with Sinfo; use Sinfo;
kono
parents:
diff changeset
32 with Snames; use Snames;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 package body Sem_Smem is
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 function Contains_Access_Type (T : Entity_Id) return Boolean;
kono
parents:
diff changeset
37 -- This function determines if type T is an access type, or contains
kono
parents:
diff changeset
38 -- a component (array, record, protected type cases) that contains
kono
parents:
diff changeset
39 -- an access type (recursively defined in the appropriate manner).
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 ----------------------
kono
parents:
diff changeset
42 -- Check_Shared_Var --
kono
parents:
diff changeset
43 ----------------------
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 procedure Check_Shared_Var
kono
parents:
diff changeset
46 (Id : Entity_Id;
kono
parents:
diff changeset
47 T : Entity_Id;
kono
parents:
diff changeset
48 N : Node_Id)
kono
parents:
diff changeset
49 is
kono
parents:
diff changeset
50 begin
kono
parents:
diff changeset
51 -- We cannot tolerate aliased variables, because they might be
kono
parents:
diff changeset
52 -- modified via an aliased pointer, and we could not detect that
kono
parents:
diff changeset
53 -- this was happening (to update the corresponding shared memory
kono
parents:
diff changeset
54 -- file), so we must disallow all use of Aliased
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 if Aliased_Present (N) then
kono
parents:
diff changeset
57 Error_Msg_N
kono
parents:
diff changeset
58 ("aliased variables " &
kono
parents:
diff changeset
59 "not supported in Shared_Passive partitions",
kono
parents:
diff changeset
60 N);
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 -- We can't support access types at all, since they are local
kono
parents:
diff changeset
63 -- pointers that cannot in any simple way be transmitted to other
kono
parents:
diff changeset
64 -- partitions.
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 elsif Is_Access_Type (T) then
kono
parents:
diff changeset
67 Error_Msg_N
kono
parents:
diff changeset
68 ("access type variables " &
kono
parents:
diff changeset
69 "not supported in Shared_Passive partitions",
kono
parents:
diff changeset
70 Id);
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 -- We cannot tolerate types that contain access types, same reasons
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 elsif Contains_Access_Type (T) then
kono
parents:
diff changeset
75 Error_Msg_N
kono
parents:
diff changeset
76 ("types containing access components " &
kono
parents:
diff changeset
77 "not supported in Shared_Passive partitions",
kono
parents:
diff changeset
78 Id);
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 -- Objects with default-initialized types will be rejected when
kono
parents:
diff changeset
81 -- the initialization code is generated. However we must flag tasks
kono
parents:
diff changeset
82 -- earlier on, to prevent expansion of stream attributes that is
kono
parents:
diff changeset
83 -- bound to fail.
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 elsif Has_Task (T) then
kono
parents:
diff changeset
86 Error_Msg_N
kono
parents:
diff changeset
87 ("Shared_Passive partitions cannot contain tasks", Id);
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 -- Currently we do not support unconstrained record types, since we
kono
parents:
diff changeset
90 -- use 'Write to write out values. This could probably be special
kono
parents:
diff changeset
91 -- cased and handled in the future if necessary.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 elsif Is_Record_Type (T)
kono
parents:
diff changeset
94 and then not Is_Constrained (T)
kono
parents:
diff changeset
95 and then (Nkind (N) /= N_Object_Declaration
kono
parents:
diff changeset
96 or else No (Expression (N)))
kono
parents:
diff changeset
97 then
kono
parents:
diff changeset
98 Error_Msg_N
kono
parents:
diff changeset
99 ("unconstrained variant records " &
kono
parents:
diff changeset
100 "not supported in Shared_Passive partitions",
kono
parents:
diff changeset
101 Id);
kono
parents:
diff changeset
102 end if;
kono
parents:
diff changeset
103 end Check_Shared_Var;
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 --------------------------
kono
parents:
diff changeset
106 -- Contains_Access_Type --
kono
parents:
diff changeset
107 --------------------------
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 function Contains_Access_Type (T : Entity_Id) return Boolean is
kono
parents:
diff changeset
110 C : Entity_Id;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 begin
kono
parents:
diff changeset
113 if Is_Access_Type (T) then
kono
parents:
diff changeset
114 return True;
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 elsif Is_Array_Type (T) then
kono
parents:
diff changeset
117 return Contains_Access_Type (Component_Type (T));
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 elsif Is_Record_Type (T) then
kono
parents:
diff changeset
120 if Has_Discriminants (T) then
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 -- Check for access discriminants.
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 C := First_Discriminant (T);
kono
parents:
diff changeset
125 while Present (C) loop
kono
parents:
diff changeset
126 if Is_Access_Type (Etype (C)) then
kono
parents:
diff changeset
127 return True;
kono
parents:
diff changeset
128 else
kono
parents:
diff changeset
129 C := Next_Discriminant (C);
kono
parents:
diff changeset
130 end if;
kono
parents:
diff changeset
131 end loop;
kono
parents:
diff changeset
132 end if;
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 C := First_Component (T);
kono
parents:
diff changeset
135 while Present (C) loop
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 -- For components, ignore internal components other than _Parent
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 if Comes_From_Source (T)
kono
parents:
diff changeset
140 and then
kono
parents:
diff changeset
141 (Chars (C) = Name_uParent
kono
parents:
diff changeset
142 or else
kono
parents:
diff changeset
143 not Is_Internal_Name (Chars (C)))
kono
parents:
diff changeset
144 and then Contains_Access_Type (Etype (C))
kono
parents:
diff changeset
145 then
kono
parents:
diff changeset
146 return True;
kono
parents:
diff changeset
147 else
kono
parents:
diff changeset
148 C := Next_Component (C);
kono
parents:
diff changeset
149 end if;
kono
parents:
diff changeset
150 end loop;
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 return False;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 elsif Is_Protected_Type (T) then
kono
parents:
diff changeset
155 return Contains_Access_Type (Corresponding_Record_Type (T));
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 else
kono
parents:
diff changeset
158 return False;
kono
parents:
diff changeset
159 end if;
kono
parents:
diff changeset
160 end Contains_Access_Type;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 end Sem_Smem;