1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-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 -- This unit contains the routines used for checking for conformance with
30 -- the semantic restrictions required for the categorization pragmas:
34 -- Remote_Call_Interface
38 -- Note that we treat Preelaborate as a categorization pragma, even though
39 -- strictly, according to RM E.2(2,3), the term does not apply in this case.
41 with Types; use Types;
45 function In_Preelaborated_Unit return Boolean;
46 -- Determines if the current scope is within a preelaborated compilation
47 -- unit, that is one to which one of the pragmas Preelaborate, Pure,
48 -- Shared_Passive, Remote_Types, or inside a unit other than a package
49 -- body with pragma Remote_Call_Interface.
51 function In_Pure_Unit return Boolean;
52 pragma Inline (In_Pure_Unit);
53 -- Determines if the current scope is within pure compilation unit,
54 -- that is, one to which the pragmas Pure is applied.
56 function In_Subprogram_Task_Protected_Unit return Boolean;
57 -- Determines if the current scope is within a subprogram, task
58 -- or protected unit. Used to validate if the library unit is Pure
61 procedure Set_Categorization_From_Pragmas (N : Node_Id);
62 -- Since validation of categorization dependency is done during analyze
63 -- so categorization flags from following pragmas should be set before
64 -- validation begin. N is the N_Compilation_Unit node.
66 procedure Validate_Access_Type_Declaration (T : Entity_Id; N : Node_Id);
67 -- Validate all constraints against declaration of access types in
68 -- categorized library units. Usually this is a violation in Pure unit,
69 -- Shared_Passive unit. N is the declaration node.
71 procedure Validate_Ancestor_Part (N : Node_Id);
72 -- Checks that a type given as the ancestor in an extension aggregate
73 -- satisfies the restriction of 10.2.1(9).
75 procedure Validate_Categorization_Dependency (N : Node_Id; E : Entity_Id);
76 -- There are restrictions on lib unit that semantically depends on other
77 -- units (RM E.2(5), 10.2.1(11). This procedure checks the restrictions
78 -- on categorizations. N is the current unit node, and E is the current
79 -- library unit entity.
81 procedure Validate_Controlled_Object (E : Entity_Id);
82 -- Given an entity for a library level controlled object, check that it is
83 -- not in a preelaborated unit (prohibited by RM 10.2.1(9)).
85 procedure Validate_Null_Statement_Sequence (N : Node_Id);
86 -- Given N, a package body node, check that a handled statement sequence
87 -- in a preelaborable body contains no statements other than labels or
88 -- null statements, as required by RM 10.2.1(6).
90 procedure Validate_Object_Declaration (N : Node_Id);
91 -- Given N, an object declaration node, validates all the constraints in
92 -- a preelaborable library unit, including creation of task objects etc.
93 -- Note that this is called when the corresponding object is frozen since
94 -- the checks cannot be made before knowing if the object is imported.
96 procedure Validate_RCI_Declarations (P : Entity_Id);
97 -- Apply semantic checks given in E2.3(10-14).
99 procedure Validate_RCI_Subprogram_Declaration (N : Node_Id);
100 -- Check for RCI unit subprogram declarations with respect to
101 -- in-lined subprogram and subprogram with access parameter or
102 -- limited type parameter without Read and Write.
104 procedure Validate_Remote_Access_To_Class_Wide_Type (N : Node_Id);
105 -- Checks that Storage_Pool and Storage_Size attribute references are
106 -- not applied to remote access-to-class-wide types. And the expected
107 -- type for an allocator shall not be a remote access-to-class-wide
108 -- type. And a remote access-to-class-wide type shall not be an actual
109 -- parameter for a generic formal access type. RM E.2.3(22).
111 procedure Validate_Remote_Access_To_Subprogram_Type (N : Node_Id);
112 -- Checks that a remote access to subprogram type does not have a
113 -- parameter of an access type. This is not strictly forbidden at this
114 -- time, but this is useless, as such a RAS type will not be usable
115 -- per E.2.2(12) and E.2.3(14).
117 procedure Validate_RT_RAT_Component (N : Node_Id);
118 -- Given N, the package library unit declaration node, we should check
119 -- against RM:9.95 E.2.2(8): the full view of a type declared in the
120 -- visible part of a Remote Types unit has a part that is of a non-remote
121 -- access type which has no read/write.
123 procedure Validate_Remote_Type_Type_Conversion (N : Node_Id);
124 -- Check for remote-type type conversion constraints. First, a value of
125 -- a remote access-to-subprogram type can be converted only to another
126 -- type conformant remote access-to-subprogram type. Secondly, a value
127 -- of a remote access-to-class-wide type can be converted only to another
128 -- remote access-to-class-wide type (RM E.2.3(17,20)).
130 procedure Validate_SP_Access_Object_Type_Decl (T : Entity_Id);
131 -- Check validity of declaration if shared passive unit. It should not
132 -- contain the declaration of an access-to-object type whose designated
133 -- type is a class-wide type ,task type or protected type. E.2.1(7).
134 -- T is the entity of the declared type.
136 procedure Validate_Static_Object_Name (N : Node_Id);
137 -- In the elaboration code of a preelaborated library unit, check
138 -- that we do not have the evaluation of a primary that is a name of
139 -- an object, unless the name is a static expression (RM 10.2.1(8)).
140 -- Non-static constant and variable are the targets, generic parameters
141 -- are not included because the generic declaration and body are