testsuite: 32 bit AIX 2 byte wchar
[official-gcc.git] / gcc / ada / sem_cat.ads
blob66e2fef4c7d82a8b6ec0713363c37e1141dbde65
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E M _ C A T --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- This unit contains the routines used for checking for conformance with
27 -- the semantic restrictions required for the categorization pragmas:
29 -- Preelaborate
30 -- Pure
31 -- Remote_Call_Interface
32 -- Remote_Types
33 -- Shared_Passive
35 -- Note that we treat Preelaborate as a categorization pragma, even though
36 -- strictly, according to RM E.2(2,3), the term does not apply in this case.
38 with Exp_Tss; use Exp_Tss;
39 with Types; use Types;
41 package Sem_Cat is
43 function Has_Stream_Attribute_Definition
44 (Typ : Entity_Id;
45 Nam : TSS_Name_Type;
46 Real_Rep : out Node_Id;
47 At_Any_Place : Boolean := False) return Boolean;
48 -- True when there is a attribute definition clause specifying attribute
49 -- Nam for Typ. In Ada 2005 mode, returns True only when the attribute
50 -- definition clause is visible, unless At_Any_Place is True (in which case
51 -- no visibility test is made, and True is returned as long as an attribute
52 -- is visible at any place). Note that attribute definition clauses
53 -- inherited from parent types are taken into account by this predicate
54 -- (to test for presence of an attribute definition clause for one
55 -- specific type, excluding inherited definitions, the flags
56 -- Has_Specified_Stream_* can be used instead).
58 -- The stream operation may be specified by an attribute definition
59 -- clause in the source, or by an aspect that generates such an
60 -- attribute definition. For an aspect, the generated attribute
61 -- definition may be placed at the freeze point of the full view of
62 -- the type, but the aspect specification makes the operation visible
63 -- to a client wherever the partial view is visible. This real
64 -- representation is returned in the Real_Rep parameter.
66 function In_Preelaborated_Unit return Boolean;
67 -- Determines if the current scope is within a preelaborated compilation
68 -- unit, that is one to which one of the pragmas Preelaborate, Pure,
69 -- Shared_Passive, Remote_Types, or inside a unit other than a package
70 -- body with pragma Remote_Call_Interface.
72 function In_Pure_Unit return Boolean;
73 pragma Inline (In_Pure_Unit);
74 -- Determines if the current scope is within pure compilation unit,
75 -- that is, one to which the pragmas Pure is applied.
77 function In_Subprogram_Task_Protected_Unit return Boolean;
78 -- Determines if the current scope is within a subprogram, task
79 -- or protected unit. Used to validate if the library unit is Pure
80 -- (RM 10.2.1(16)).
82 procedure Set_Categorization_From_Pragmas (N : Node_Id);
83 -- Since validation of categorization dependency is done during Analyze,
84 -- categorization flags from following pragmas should be set before
85 -- validation begin. N is the N_Compilation_Unit node.
87 procedure Set_Categorization_From_Scope (E : Entity_Id; Scop : Entity_Id);
88 -- Set categorization flags Pure, Remote_Call_Interface and Remote_Types
89 -- on entity E according to those of Scop.
91 procedure Validate_Access_Type_Declaration (T : Entity_Id; N : Node_Id);
92 -- Validate all constraints against declaration of access types in
93 -- categorized library units. Usually this is a violation in Pure unit,
94 -- Shared_Passive unit. N is the declaration node.
96 procedure Validate_Ancestor_Part (N : Node_Id);
97 -- Checks that a type given as the ancestor in an extension aggregate
98 -- satisfies the restriction of 10.2.1(9).
100 procedure Validate_Categorization_Dependency (N : Node_Id; E : Entity_Id);
101 -- There are restrictions on lib unit that semantically depends on other
102 -- units (RM E.2(5), 10.2.1(11). This procedure checks the restrictions
103 -- on categorizations. N is the current unit node, and E is the current
104 -- library unit entity.
106 procedure Validate_Controlled_Object (E : Entity_Id);
107 -- Given an entity for a library level controlled object, check that it is
108 -- not in a preelaborated unit (prohibited by RM 10.2.1(9)).
110 procedure Validate_Null_Statement_Sequence (N : Node_Id);
111 -- Given N, a package body node, check that a handled statement sequence
112 -- in a preelaborable body contains no statements other than labels or
113 -- null statements, as required by RM 10.2.1(6).
115 procedure Validate_Object_Declaration (N : Node_Id);
116 -- Given N, an object declaration node, validates all the constraints in
117 -- a preelaborable library unit, including creation of task objects etc.
118 -- Note that this is called when the corresponding object is frozen since
119 -- the checks cannot be made before knowing if the object is imported.
121 procedure Validate_RCI_Declarations (P : Entity_Id);
122 -- Apply semantic checks given in E2.3(10-14)
124 procedure Validate_RCI_Subprogram_Declaration (N : Node_Id);
125 -- Check RCI subprogram declarations for illegal inlining and formals not
126 -- supporting external streaming.
128 procedure Validate_Remote_Access_To_Class_Wide_Type (N : Node_Id);
129 -- Checks that Storage_Pool and Storage_Size attribute references are
130 -- not applied to remote access-to-class-wide types. Also checks that the
131 -- expected type for an allocator cannot be a remote access-to-class-wide
132 -- type. Also checks that a remote access-to-class-wide type cannot be an
133 -- actual parameter for a generic formal access type. RM E.2.2(17).
135 procedure Validate_RT_RAT_Component (N : Node_Id);
136 -- Given N, the package library unit declaration node, we should check
137 -- against RM:9.95 E.2.2(8): the full view of a type declared in the
138 -- visible part of a Remote Types unit has a part that is of a non-remote
139 -- access type which has no read/write.
141 procedure Validate_Remote_Type_Type_Conversion (N : Node_Id);
142 -- Check for remote-type type conversion constraints. First, a value of
143 -- a remote access-to-subprogram type can be converted only to another
144 -- type conformant remote access-to-subprogram type. Secondly, a value
145 -- of a remote access-to-class-wide type can be converted only to another
146 -- remote access-to-class-wide type (RM E.2.3(17,20)).
148 procedure Validate_SP_Access_Object_Type_Decl (T : Entity_Id);
149 -- Check validity of declaration if shared passive unit. It should not
150 -- contain the declaration of an access-to-object type whose designated
151 -- type is a class-wide type ,task type or protected type. E.2.1(7).
152 -- T is the entity of the declared type.
154 procedure Validate_Static_Object_Name (N : Node_Id);
155 -- In the elaboration code of a preelaborated library unit, check that we
156 -- do not have the evaluation of a primary that is a name of an object,
157 -- unless the name is a static expression (RM 10.2.1(8)). Non-static
158 -- constant and variable are the targets, generic parameters are not
159 -- are not included because the generic declaration and body are
160 -- preelaborable.
162 procedure Validate_RACW_Primitives (T : Entity_Id);
163 -- Enforce constraints on primitive operations of the designated type of
164 -- an RACW. Note that since the complete set of primitive operations of the
165 -- designated type needs to be known, we must defer these checks until the
166 -- designated type is frozen.
168 end Sem_Cat;