annotate gcc/ada/sem_cat.ads @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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 _ C A T --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, 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 -- This unit contains the routines used for checking for conformance with
kono
parents:
diff changeset
27 -- the semantic restrictions required for the categorization pragmas:
kono
parents:
diff changeset
28 --
kono
parents:
diff changeset
29 -- Preelaborate
kono
parents:
diff changeset
30 -- Pure,
kono
parents:
diff changeset
31 -- Remote_Call_Interface
kono
parents:
diff changeset
32 -- Remote_Types
kono
parents:
diff changeset
33 -- Shared_Passive
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- Note that we treat Preelaborate as a categorization pragma, even though
kono
parents:
diff changeset
36 -- strictly, according to RM E.2(2,3), the term does not apply in this case.
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 with Exp_Tss; use Exp_Tss;
kono
parents:
diff changeset
39 with Types; use Types;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 package Sem_Cat is
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 function Has_Stream_Attribute_Definition
kono
parents:
diff changeset
44 (Typ : Entity_Id;
kono
parents:
diff changeset
45 Nam : TSS_Name_Type;
kono
parents:
diff changeset
46 At_Any_Place : Boolean := False) return Boolean;
kono
parents:
diff changeset
47 -- True when there is a attribute definition clause specifying attribute
kono
parents:
diff changeset
48 -- Nam for Typ. In Ada 2005 mode, returns True only when the attribute
kono
parents:
diff changeset
49 -- definition clause is visible, unless At_Any_Place is True (in which case
kono
parents:
diff changeset
50 -- no visibility test is made, and True is returned as long as an attribute
kono
parents:
diff changeset
51 -- is visible at any place). Note that attribute definition clauses
kono
parents:
diff changeset
52 -- inherited from parent types are taken into account by this predicate
kono
parents:
diff changeset
53 -- (to test for presence of an attribute definition clause for one
kono
parents:
diff changeset
54 -- specific type, excluding inherited definitions, the flags
kono
parents:
diff changeset
55 -- Has_Specified_Stream_* can be used instead).
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 function In_Preelaborated_Unit return Boolean;
kono
parents:
diff changeset
58 -- Determines if the current scope is within a preelaborated compilation
kono
parents:
diff changeset
59 -- unit, that is one to which one of the pragmas Preelaborate, Pure,
kono
parents:
diff changeset
60 -- Shared_Passive, Remote_Types, or inside a unit other than a package
kono
parents:
diff changeset
61 -- body with pragma Remote_Call_Interface.
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 function In_Pure_Unit return Boolean;
kono
parents:
diff changeset
64 pragma Inline (In_Pure_Unit);
kono
parents:
diff changeset
65 -- Determines if the current scope is within pure compilation unit,
kono
parents:
diff changeset
66 -- that is, one to which the pragmas Pure is applied.
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 function In_Subprogram_Task_Protected_Unit return Boolean;
kono
parents:
diff changeset
69 -- Determines if the current scope is within a subprogram, task
kono
parents:
diff changeset
70 -- or protected unit. Used to validate if the library unit is Pure
kono
parents:
diff changeset
71 -- (RM 10.2.1(16)).
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 procedure Set_Categorization_From_Pragmas (N : Node_Id);
kono
parents:
diff changeset
74 -- Since validation of categorization dependency is done during Analyze,
kono
parents:
diff changeset
75 -- categorization flags from following pragmas should be set before
kono
parents:
diff changeset
76 -- validation begin. N is the N_Compilation_Unit node.
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 procedure Set_Categorization_From_Scope (E : Entity_Id; Scop : Entity_Id);
kono
parents:
diff changeset
79 -- Set categorization flags Pure, Remote_Call_Interface and Remote_Types
kono
parents:
diff changeset
80 -- on entity E according to those of Scop.
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 procedure Validate_Access_Type_Declaration (T : Entity_Id; N : Node_Id);
kono
parents:
diff changeset
83 -- Validate all constraints against declaration of access types in
kono
parents:
diff changeset
84 -- categorized library units. Usually this is a violation in Pure unit,
kono
parents:
diff changeset
85 -- Shared_Passive unit. N is the declaration node.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure Validate_Ancestor_Part (N : Node_Id);
kono
parents:
diff changeset
88 -- Checks that a type given as the ancestor in an extension aggregate
kono
parents:
diff changeset
89 -- satisfies the restriction of 10.2.1(9).
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 procedure Validate_Categorization_Dependency (N : Node_Id; E : Entity_Id);
kono
parents:
diff changeset
92 -- There are restrictions on lib unit that semantically depends on other
kono
parents:
diff changeset
93 -- units (RM E.2(5), 10.2.1(11). This procedure checks the restrictions
kono
parents:
diff changeset
94 -- on categorizations. N is the current unit node, and E is the current
kono
parents:
diff changeset
95 -- library unit entity.
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 procedure Validate_Controlled_Object (E : Entity_Id);
kono
parents:
diff changeset
98 -- Given an entity for a library level controlled object, check that it is
kono
parents:
diff changeset
99 -- not in a preelaborated unit (prohibited by RM 10.2.1(9)).
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 procedure Validate_Null_Statement_Sequence (N : Node_Id);
kono
parents:
diff changeset
102 -- Given N, a package body node, check that a handled statement sequence
kono
parents:
diff changeset
103 -- in a preelaborable body contains no statements other than labels or
kono
parents:
diff changeset
104 -- null statements, as required by RM 10.2.1(6).
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 procedure Validate_Object_Declaration (N : Node_Id);
kono
parents:
diff changeset
107 -- Given N, an object declaration node, validates all the constraints in
kono
parents:
diff changeset
108 -- a preelaborable library unit, including creation of task objects etc.
kono
parents:
diff changeset
109 -- Note that this is called when the corresponding object is frozen since
kono
parents:
diff changeset
110 -- the checks cannot be made before knowing if the object is imported.
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 procedure Validate_RCI_Declarations (P : Entity_Id);
kono
parents:
diff changeset
113 -- Apply semantic checks given in E2.3(10-14)
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 procedure Validate_RCI_Subprogram_Declaration (N : Node_Id);
kono
parents:
diff changeset
116 -- Check RCI subprogram declarations for illegal inlining and formals not
kono
parents:
diff changeset
117 -- supporting external streaming.
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 procedure Validate_Remote_Access_To_Class_Wide_Type (N : Node_Id);
kono
parents:
diff changeset
120 -- Checks that Storage_Pool and Storage_Size attribute references are
kono
parents:
diff changeset
121 -- not applied to remote access-to-class-wide types. Also checks that the
kono
parents:
diff changeset
122 -- expected type for an allocator cannot be a remote access-to-class-wide
kono
parents:
diff changeset
123 -- type. ALso checks that a remote access-to-class-wide type cannot be an
kono
parents:
diff changeset
124 -- actual parameter for a generic formal access type. RM E.2.3(22).
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 procedure Validate_RT_RAT_Component (N : Node_Id);
kono
parents:
diff changeset
127 -- Given N, the package library unit declaration node, we should check
kono
parents:
diff changeset
128 -- against RM:9.95 E.2.2(8): the full view of a type declared in the
kono
parents:
diff changeset
129 -- visible part of a Remote Types unit has a part that is of a non-remote
kono
parents:
diff changeset
130 -- access type which has no read/write.
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 procedure Validate_Remote_Type_Type_Conversion (N : Node_Id);
kono
parents:
diff changeset
133 -- Check for remote-type type conversion constraints. First, a value of
kono
parents:
diff changeset
134 -- a remote access-to-subprogram type can be converted only to another
kono
parents:
diff changeset
135 -- type conformant remote access-to-subprogram type. Secondly, a value
kono
parents:
diff changeset
136 -- of a remote access-to-class-wide type can be converted only to another
kono
parents:
diff changeset
137 -- remote access-to-class-wide type (RM E.2.3(17,20)).
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 procedure Validate_SP_Access_Object_Type_Decl (T : Entity_Id);
kono
parents:
diff changeset
140 -- Check validity of declaration if shared passive unit. It should not
kono
parents:
diff changeset
141 -- contain the declaration of an access-to-object type whose designated
kono
parents:
diff changeset
142 -- type is a class-wide type ,task type or protected type. E.2.1(7).
kono
parents:
diff changeset
143 -- T is the entity of the declared type.
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 procedure Validate_Static_Object_Name (N : Node_Id);
kono
parents:
diff changeset
146 -- In the elaboration code of a preelaborated library unit, check that we
kono
parents:
diff changeset
147 -- do not have the evaluation of a primary that is a name of an object,
kono
parents:
diff changeset
148 -- unless the name is a static expression (RM 10.2.1(8)). Non-static
kono
parents:
diff changeset
149 -- constant and variable are the targets, generic parameters are not
kono
parents:
diff changeset
150 -- are not included because the generic declaration and body are
kono
parents:
diff changeset
151 -- preelaborable.
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 procedure Validate_RACW_Primitives (T : Entity_Id);
kono
parents:
diff changeset
154 -- Enforce constraints on primitive operations of the designated type of
kono
parents:
diff changeset
155 -- an RACW. Note that since the complete set of primitive operations of the
kono
parents:
diff changeset
156 -- designated type needs to be known, we must defer these checks until the
kono
parents:
diff changeset
157 -- designated type is frozen.
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 end Sem_Cat;