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-2002 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 2,  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 COPYING.  If not, write --
19-- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20-- MA 02111-1307, USA.                                                      --
21--                                                                          --
22-- GNAT was originally developed  by the GNAT team at  New York University. --
23-- Extensive contributions were provided by Ada Core Technologies Inc.      --
24--                                                                          --
25------------------------------------------------------------------------------
26
27--  This unit contains the routines used for checking for conformance with
28--  the semantic restrictions required for the categorization pragmas:
29--
30--    Preelaborate
31--    Pure,
32--    Remote_Call_Interface
33--    Remote_Types
34--    Shared_Passive
35--
36--  Note that we treat Preelaborate as a categorization pragma, even though
37--  strictly, according to RM E.2(2,3), the term does not apply in this case.
38
39with Types; use Types;
40
41package Sem_Cat is
42
43   function In_Preelaborated_Unit return Boolean;
44   --  Determines if the current scope is within a preelaborated compilation
45   --  unit, that is one to which one of the pragmas Preelaborate, Pure,
46   --  Shared_Passive, Remote_Types, or inside a unit other than a package
47   --  body with pragma Remote_Call_Interface.
48
49   function In_Pure_Unit return Boolean;
50   pragma Inline (In_Pure_Unit);
51   --  Determines if the current scope is within pure compilation unit,
52   --  that is, one to which the pragmas Pure is applied.
53
54   function In_Subprogram_Task_Protected_Unit return Boolean;
55   --  Determines if the current scope is within a subprogram, task
56   --  or protected unit. Used to validate if the library unit is Pure
57   --  (RM 10.2.1(16)).
58
59   procedure Set_Categorization_From_Pragmas (N : Node_Id);
60   --  Since validation of categorization dependency is done during Analyze,
61   --  categorization flags from following pragmas should be set before
62   --  validation begin. N is the N_Compilation_Unit node.
63
64   procedure Set_Categorization_From_Scope (E : Entity_Id; Scop : Entity_Id);
65   --  Set categorization flags Pure, Remote_Call_Interface and Remote_Types
66   --  on entity E according to those of Scop.
67
68   procedure Validate_Access_Type_Declaration (T : Entity_Id; N : Node_Id);
69   --  Validate all constraints against declaration of access types in
70   --  categorized library units. Usually this is a violation in Pure unit,
71   --  Shared_Passive unit. N is the declaration node.
72
73   procedure Validate_Ancestor_Part (N : Node_Id);
74   --  Checks that a type given as the ancestor in an extension aggregate
75   --  satisfies the restriction of 10.2.1(9).
76
77   procedure Validate_Categorization_Dependency (N : Node_Id; E : Entity_Id);
78   --  There are restrictions on lib unit that semantically depends on other
79   --  units (RM E.2(5), 10.2.1(11). This procedure checks the restrictions
80   --  on categorizations. N is the current unit node, and E is the current
81   --  library unit entity.
82
83   procedure Validate_Controlled_Object (E : Entity_Id);
84   --  Given an entity for a library level controlled object, check that it is
85   --  not in a preelaborated unit (prohibited by RM 10.2.1(9)).
86
87   procedure Validate_Null_Statement_Sequence (N : Node_Id);
88   --  Given N, a package body node, check that a handled statement sequence
89   --  in a preelaborable body contains no statements other than labels or
90   --  null statements, as required by RM 10.2.1(6).
91
92   procedure Validate_Object_Declaration (N : Node_Id);
93   --  Given N, an object declaration node, validates all the constraints in
94   --  a preelaborable library unit, including creation of task objects etc.
95   --  Note that this is called when the corresponding object is frozen since
96   --  the checks cannot be made before knowing if the object is imported.
97
98   procedure Validate_RCI_Declarations (P : Entity_Id);
99   --  Apply semantic checks given in  E2.3(10-14).
100
101   procedure Validate_RCI_Subprogram_Declaration (N : Node_Id);
102   --  Check for RCI unit subprogram declarations with respect to
103   --  in-lined subprogram and subprogram with access parameter or
104   --  limited type parameter without Read and Write.
105
106   procedure Validate_Remote_Access_To_Class_Wide_Type (N : Node_Id);
107   --  Checks that Storage_Pool and Storage_Size attribute references are
108   --  not applied to remote access-to-class-wide types. And the expected
109   --  type for an allocator shall not be a remote access-to-class-wide
110   --  type. And a remote access-to-class-wide type shall not be an actual
111   --  parameter for a generic formal access type. RM E.2.3(22).
112
113   procedure Validate_RT_RAT_Component (N : Node_Id);
114   --  Given N, the package library unit declaration node, we should check
115   --  against RM:9.95 E.2.2(8): the full view of a type declared in the
116   --  visible part of a Remote Types unit has a part that is of a non-remote
117   --  access type which has no read/write.
118
119   procedure Validate_Remote_Type_Type_Conversion (N : Node_Id);
120   --  Check for remote-type type conversion constraints. First, a value of
121   --  a remote access-to-subprogram type can be converted only to another
122   --  type conformant remote access-to-subprogram type. Secondly, a value
123   --  of a remote access-to-class-wide type can be converted only to another
124   --  remote access-to-class-wide type (RM E.2.3(17,20)).
125
126   procedure Validate_SP_Access_Object_Type_Decl (T : Entity_Id);
127   --  Check validity of declaration if shared passive unit. It should not
128   --  contain the declaration of an access-to-object type whose designated
129   --  type is a class-wide type ,task type or protected type. E.2.1(7).
130   --  T is the entity of the declared type.
131
132   procedure Validate_Static_Object_Name (N : Node_Id);
133   --  In the elaboration code of a preelaborated library unit, check
134   --  that we do not have the evaluation of a primary that is a name of
135   --  an object, unless the name is a static expression (RM 10.2.1(8)).
136   --  Non-static constant and variable are the targets, generic parameters
137   --  are not included because the generic declaration and body are
138   --  preelaborable.
139
140end Sem_Cat;
141