| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- S E M _ P R A G -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1992-2025, 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 |
------------------------------------------------------------------------------ |
| 25 |
|
| 26 |
-- Pragma handling is isolated in a separate package |
| 27 |
-- (logically this processing belongs in chapter 4) |
| 28 |
|
| 29 |
with Namet; use Namet; |
| 30 |
with Opt; use Opt; |
| 31 |
with Snames; use Snames; |
| 32 |
with Types; use Types; |
| 33 |
|
| 34 |
package Sem_Prag is |
| 35 |
|
| 36 |
-- The following table lists all pragmas that emulate an Ada 2012 aspect |
| 37 |
|
| 38 |
Aspect_Specifying_Pragma : constant array (Pragma_Id) of Boolean := |
| 39 |
(Pragma_Abstract_State => True, |
| 40 |
Pragma_All_Calls_Remote => True, |
| 41 |
Pragma_Always_Terminates => True, |
| 42 |
Pragma_Annotate => True, |
| 43 |
Pragma_Async_Readers => True, |
| 44 |
Pragma_Async_Writers => True, |
| 45 |
Pragma_Asynchronous => True, |
| 46 |
Pragma_Atomic => True, |
| 47 |
Pragma_Atomic_Components => True, |
| 48 |
Pragma_Attach_Handler => True, |
| 49 |
Pragma_Constant_After_Elaboration => True, |
| 50 |
Pragma_Contract_Cases => True, |
| 51 |
Pragma_Convention => True, |
| 52 |
Pragma_CPU => True, |
| 53 |
Pragma_CUDA_Device => True, |
| 54 |
Pragma_CUDA_Global => True, |
| 55 |
Pragma_Default_Initial_Condition => True, |
| 56 |
Pragma_Default_Storage_Pool => True, |
| 57 |
Pragma_Depends => True, |
| 58 |
Pragma_Discard_Names => True, |
| 59 |
Pragma_Dispatching_Domain => True, |
| 60 |
Pragma_Effective_Reads => True, |
| 61 |
Pragma_Effective_Writes => True, |
| 62 |
Pragma_Elaborate_Body => True, |
| 63 |
Pragma_Exceptional_Cases => True, |
| 64 |
Pragma_Export => True, |
| 65 |
Pragma_Extended_Access => True, |
| 66 |
Pragma_Extensions_Visible => True, |
| 67 |
Pragma_Favor_Top_Level => True, |
| 68 |
Pragma_First_Controlling_Parameter => True, |
| 69 |
Pragma_Ghost => True, |
| 70 |
Pragma_Global => True, |
| 71 |
Pragma_GNAT_Annotate => True, |
| 72 |
Pragma_Import => True, |
| 73 |
Pragma_Independent => True, |
| 74 |
Pragma_Independent_Components => True, |
| 75 |
Pragma_Initial_Condition => True, |
| 76 |
Pragma_Initializes => True, |
| 77 |
Pragma_Inline => True, |
| 78 |
Pragma_Inline_Always => True, |
| 79 |
Pragma_Interrupt_Handler => True, |
| 80 |
Pragma_Interrupt_Priority => True, |
| 81 |
Pragma_Invariant => True, |
| 82 |
Pragma_Linker_Section => True, |
| 83 |
Pragma_Lock_Free => True, |
| 84 |
Pragma_No_Elaboration_Code_All => True, |
| 85 |
Pragma_No_Return => True, |
| 86 |
Pragma_Obsolescent => True, |
| 87 |
Pragma_Pack => True, |
| 88 |
Pragma_Part_Of => True, |
| 89 |
Pragma_Persistent_BSS => True, |
| 90 |
Pragma_Post => True, |
| 91 |
Pragma_Post_Class => True, |
| 92 |
Pragma_Postcondition => True, |
| 93 |
Pragma_Pre => True, |
| 94 |
Pragma_Pre_Class => True, |
| 95 |
Pragma_Precondition => True, |
| 96 |
Pragma_Predicate => True, |
| 97 |
Pragma_Preelaborable_Initialization => True, |
| 98 |
Pragma_Preelaborate => True, |
| 99 |
Pragma_Priority => True, |
| 100 |
Pragma_Pure => True, |
| 101 |
Pragma_Pure_Function => True, |
| 102 |
Pragma_Refined_Depends => True, |
| 103 |
Pragma_Refined_Global => True, |
| 104 |
Pragma_Refined_Post => True, |
| 105 |
Pragma_Refined_State => True, |
| 106 |
Pragma_Relative_Deadline => True, |
| 107 |
Pragma_Remote_Access_Type => True, |
| 108 |
Pragma_Remote_Call_Interface => True, |
| 109 |
Pragma_Remote_Types => True, |
| 110 |
Pragma_Secondary_Stack_Size => True, |
| 111 |
Pragma_Shared => True, |
| 112 |
Pragma_Shared_Passive => True, |
| 113 |
Pragma_Simple_Storage_Pool_Type => True, |
| 114 |
Pragma_SPARK_Mode => True, |
| 115 |
Pragma_Storage_Size => True, |
| 116 |
Pragma_Subprogram_Variant => True, |
| 117 |
Pragma_Suppress => True, |
| 118 |
Pragma_Suppress_Debug_Info => True, |
| 119 |
Pragma_Suppress_Initialization => True, |
| 120 |
Pragma_Test_Case => True, |
| 121 |
Pragma_Thread_Local_Storage => True, |
| 122 |
Pragma_Type_Invariant => True, |
| 123 |
Pragma_Unchecked_Union => True, |
| 124 |
Pragma_Universal_Aliasing => True, |
| 125 |
Pragma_Unmodified => True, |
| 126 |
Pragma_Unreferenced => True, |
| 127 |
Pragma_Unreferenced_Objects => True, |
| 128 |
Pragma_Unsuppress => True, |
| 129 |
Pragma_Volatile => True, |
| 130 |
Pragma_Volatile_Components => True, |
| 131 |
Pragma_Volatile_Full_Access => True, |
| 132 |
Pragma_Warnings => True, |
| 133 |
others => False); |
| 134 |
|
| 135 |
-- The following table lists all pragmas that act as an assertion |
| 136 |
-- expression. |
| 137 |
|
| 138 |
Assertion_Expression_Pragma : constant array (Pragma_Id) of Boolean := |
| 139 |
(Pragma_Always_Terminates => True, |
| 140 |
Pragma_Assert => True, |
| 141 |
Pragma_Assert_And_Cut => True, |
| 142 |
Pragma_Assume => True, |
| 143 |
Pragma_Check => True, |
| 144 |
Pragma_Compile_Time_Error => True, |
| 145 |
Pragma_Contract_Cases => True, |
| 146 |
Pragma_Default_Initial_Condition => True, |
| 147 |
Pragma_Exceptional_Cases => True, |
| 148 |
Pragma_Initial_Condition => True, |
| 149 |
Pragma_Invariant => True, |
| 150 |
Pragma_Loop_Invariant => True, |
| 151 |
Pragma_Loop_Variant => True, |
| 152 |
Pragma_Post => True, |
| 153 |
Pragma_Post_Class => True, |
| 154 |
Pragma_Postcondition => True, |
| 155 |
Pragma_Pre => True, |
| 156 |
Pragma_Pre_Class => True, |
| 157 |
Pragma_Precondition => True, |
| 158 |
Pragma_Predicate => True, |
| 159 |
Pragma_Refined_Post => True, |
| 160 |
Pragma_Subprogram_Variant => True, |
| 161 |
Pragma_Test_Case => True, |
| 162 |
Pragma_Type_Invariant => True, |
| 163 |
Pragma_Type_Invariant_Class => True, |
| 164 |
others => False); |
| 165 |
|
| 166 |
-- Should to following constant arrays be renamed to better suit their |
| 167 |
-- use as a predicate (e.g. Is_Pragma_*) ??? |
| 168 |
|
| 169 |
-- The following table lists all the implementation-defined pragmas that |
| 170 |
-- should apply to the anonymous object produced by the analysis of a |
| 171 |
-- single protected or task type. The table should be synchronized with |
| 172 |
-- Aspect_On_Anonymous_Object_OK in unit Aspects. |
| 173 |
|
| 174 |
Pragma_On_Anonymous_Object_OK : constant array (Pragma_Id) of Boolean := |
| 175 |
(Pragma_Depends => True, |
| 176 |
Pragma_Global => True, |
| 177 |
Pragma_Part_Of => True, |
| 178 |
others => False); |
| 179 |
|
| 180 |
-- The following table lists all the implementation-defined pragmas that |
| 181 |
-- may apply to a body stub (no language defined pragmas apply). The table |
| 182 |
-- should be synchronized with Aspect_On_Body_Or_Stub_OK in unit Aspects. |
| 183 |
|
| 184 |
Pragma_On_Body_Or_Stub_OK : constant array (Pragma_Id) of Boolean := |
| 185 |
(Pragma_Refined_Depends => True, |
| 186 |
Pragma_Refined_Global => True, |
| 187 |
Pragma_Refined_Post => True, |
| 188 |
Pragma_SPARK_Mode => True, |
| 189 |
Pragma_Warnings => True, |
| 190 |
others => False); |
| 191 |
|
| 192 |
-- The following table lists all pragmas which are significant in SPARK and |
| 193 |
-- as a result get translated into verification conditions. The table is an |
| 194 |
-- amalgamation of the pragmas listed in SPARK RM 16.1 and internally added |
| 195 |
-- entries. |
| 196 |
|
| 197 |
Pragma_Significant_In_SPARK : constant array (Pragma_Id) of Boolean := |
| 198 |
(Pragma_All_Calls_Remote => False, |
| 199 |
Pragma_Asynchronous => False, |
| 200 |
Pragma_Default_Storage_Pool => False, |
| 201 |
Pragma_Discard_Names => False, |
| 202 |
Pragma_Dispatching_Domain => False, |
| 203 |
Pragma_Priority_Specific_Dispatching => False, |
| 204 |
Pragma_Remote_Call_Interface => False, |
| 205 |
Pragma_Remote_Types => False, |
| 206 |
Pragma_Shared_Passive => False, |
| 207 |
Pragma_Task_Dispatching_Policy => False, |
| 208 |
Pragma_Unmodified => False, |
| 209 |
Pragma_Unreferenced => False, |
| 210 |
Pragma_Warnings => False, |
| 211 |
others => True); |
| 212 |
|
| 213 |
-- The following table lists all pragmas which are relevant to the analysis |
| 214 |
-- of subprogram bodies. |
| 215 |
|
| 216 |
Pragma_Significant_To_Subprograms : constant array (Pragma_Id) of Boolean := |
| 217 |
(Pragma_Always_Terminates => True, |
| 218 |
Pragma_Contract_Cases => True, |
| 219 |
Pragma_Depends => True, |
| 220 |
Pragma_Exceptional_Cases => True, |
| 221 |
Pragma_Extensions_Visible => True, |
| 222 |
Pragma_Ghost => True, |
| 223 |
Pragma_Global => True, |
| 224 |
Pragma_Inline => True, |
| 225 |
Pragma_Inline_Always => True, |
| 226 |
Pragma_Post => True, |
| 227 |
Pragma_Post_Class => True, |
| 228 |
Pragma_Postcondition => True, |
| 229 |
Pragma_Pre => True, |
| 230 |
Pragma_Pre_Class => True, |
| 231 |
Pragma_Precondition => True, |
| 232 |
Pragma_Pure => True, |
| 233 |
Pragma_Pure_Function => True, |
| 234 |
Pragma_Refined_Depends => True, |
| 235 |
Pragma_Refined_Global => True, |
| 236 |
Pragma_Refined_Post => True, |
| 237 |
Pragma_Refined_State => True, |
| 238 |
Pragma_Side_Effects => True, |
| 239 |
Pragma_Subprogram_Variant => True, |
| 240 |
Pragma_Volatile => True, |
| 241 |
Pragma_Volatile_Function => True, |
| 242 |
others => False); |
| 243 |
|
| 244 |
-- The following table lists all pragmas which are relevant to the analysis |
| 245 |
-- of subprogram bodies and should be analyzed first, because the analysis |
| 246 |
-- of other pragmas relevant to subprogram bodies depend on them. |
| 247 |
|
| 248 |
Pragma_Significant_To_Subprograms_Analyzed_First : |
| 249 |
constant array (Pragma_Id) of Boolean := |
| 250 |
(Pragma_Extensions_Visible => True, |
| 251 |
others => False); |
| 252 |
|
| 253 |
----------------- |
| 254 |
-- Subprograms -- |
| 255 |
----------------- |
| 256 |
|
| 257 |
procedure Analyze_Pragma (N : Node_Id); |
| 258 |
-- Analyze procedure for pragma reference node N |
| 259 |
|
| 260 |
procedure Analyze_Pragmas_If_Present (Decl : Node_Id; Id : Pragma_Id); |
| 261 |
-- Inspect the list of pragmas after declaration Decl and look for a pragma |
| 262 |
-- that matches Id. If found, analyze the pragma. |
| 263 |
|
| 264 |
procedure Analyze_Always_Terminates_In_Decl_Part |
| 265 |
(N : Node_Id; |
| 266 |
Freeze_Id : Entity_Id := Empty); |
| 267 |
-- Perform full analysis of delayed pragma Always_Terminates. Freeze_Id is |
| 268 |
-- the entity of [generic] package body or [generic] subprogram body which |
| 269 |
-- caused "freezing" of the related contract where the pragma resides. |
| 270 |
|
| 271 |
procedure Analyze_Contract_Cases_In_Decl_Part |
| 272 |
(N : Node_Id; |
| 273 |
Freeze_Id : Entity_Id := Empty); |
| 274 |
-- Perform full analysis of delayed pragma Contract_Cases. Freeze_Id is the |
| 275 |
-- entity of [generic] package body or [generic] subprogram body which |
| 276 |
-- caused "freezing" of the related contract where the pragma resides. |
| 277 |
|
| 278 |
procedure Analyze_Depends_In_Decl_Part (N : Node_Id); |
| 279 |
-- Perform full analysis of delayed pragma Depends. This routine is also |
| 280 |
-- capable of performing basic analysis of pragma Refined_Depends. |
| 281 |
|
| 282 |
procedure Analyze_Exceptional_Cases_In_Decl_Part |
| 283 |
(N : Node_Id; |
| 284 |
Freeze_Id : Entity_Id := Empty); |
| 285 |
-- Perform full analysis of delayed pragma Exceptional_Cases. Freeze_Id is |
| 286 |
-- the entity of [generic] package body or [generic] subprogram body which |
| 287 |
-- caused "freezing" of the related contract where the pragma resides. |
| 288 |
|
| 289 |
procedure Analyze_Exit_Cases_In_Decl_Part |
| 290 |
(N : Node_Id; |
| 291 |
Freeze_Id : Entity_Id := Empty); |
| 292 |
-- Perform full analysis of delayed pragma Exit_Cases. Freeze_Id is the |
| 293 |
-- entity of [generic] package body or [generic] subprogram body which |
| 294 |
-- caused "freezing" of the related contract where the pragma resides. |
| 295 |
|
| 296 |
procedure Analyze_External_Property_In_Decl_Part |
| 297 |
(N : Node_Id; |
| 298 |
Expr_Val : out Boolean); |
| 299 |
-- Perform full analysis of delayed pragmas Async_Readers, Async_Writers, |
| 300 |
-- Effective_Reads, Effective_Writes and No_Caching. Flag Expr_Val contains |
| 301 |
-- the Boolean argument of the pragma or a default True if no argument |
| 302 |
-- is present. |
| 303 |
|
| 304 |
procedure Analyze_Global_In_Decl_Part (N : Node_Id); |
| 305 |
-- Perform full analysis of delayed pragma Global. This routine is also |
| 306 |
-- capable of performing basic analysis of pragma Refined_Global. |
| 307 |
|
| 308 |
procedure Analyze_Initial_Condition_In_Decl_Part (N : Node_Id); |
| 309 |
-- Perform full analysis of delayed pragma Initial_Condition |
| 310 |
|
| 311 |
procedure Analyze_Initializes_In_Decl_Part (N : Node_Id); |
| 312 |
-- Perform full analysis of delayed pragma Initializes |
| 313 |
|
| 314 |
procedure Analyze_Part_Of_In_Decl_Part |
| 315 |
(N : Node_Id; |
| 316 |
Freeze_Id : Entity_Id := Empty); |
| 317 |
-- Perform full analysis of delayed pragma Part_Of. Freeze_Id is the entity |
| 318 |
-- of [generic] package body or [generic] subprogram body which caused the |
| 319 |
-- "freezing" of the related contract where the pragma resides. |
| 320 |
|
| 321 |
procedure Analyze_Pre_Post_Condition_In_Decl_Part |
| 322 |
(N : Node_Id; |
| 323 |
Freeze_Id : Entity_Id := Empty); |
| 324 |
-- Perform full analysis of pragmas Precondition and Postcondition. |
| 325 |
-- Freeze_Id denotes the entity of [generic] package body or [generic] |
| 326 |
-- subprogram body which caused "freezing" of the related contract where |
| 327 |
-- the pragma resides. |
| 328 |
|
| 329 |
procedure Analyze_Refined_Depends_In_Decl_Part (N : Node_Id); |
| 330 |
-- Preform full analysis of delayed pragma Refined_Depends. This routine |
| 331 |
-- uses Analyze_Depends_In_Decl_Part as a starting point, then performs |
| 332 |
-- various consistency checks between Depends and Refined_Depends. |
| 333 |
|
| 334 |
procedure Analyze_Refined_Global_In_Decl_Part (N : Node_Id); |
| 335 |
-- Perform full analysis of delayed pragma Refined_Global. This routine |
| 336 |
-- uses Analyze_Global_In_Decl_Part as a starting point, then performs |
| 337 |
-- various consistency checks between Global and Refined_Global. |
| 338 |
|
| 339 |
procedure Analyze_Refined_State_In_Decl_Part |
| 340 |
(N : Node_Id; |
| 341 |
Freeze_Id : Entity_Id := Empty); |
| 342 |
-- Perform full analysis of delayed pragma Refined_State. Freeze_Id denotes |
| 343 |
-- the entity of [generic] package body or [generic] subprogram body which |
| 344 |
-- caused "freezing" of the related contract where the pragma resides. |
| 345 |
|
| 346 |
procedure Analyze_Subprogram_Variant_In_Decl_Part |
| 347 |
(N : Node_Id; |
| 348 |
Freeze_Id : Entity_Id := Empty); |
| 349 |
-- Perform full analysis of delayed pragma Subprogram_Variant. Freeze_Id is |
| 350 |
-- the entity of [generic] package body or [generic] subprogram body which |
| 351 |
-- caused "freezing" of the related contract where the pragma resides. |
| 352 |
|
| 353 |
procedure Analyze_Test_Case_In_Decl_Part (N : Node_Id); |
| 354 |
-- Perform preanalysis of pragma Test_Case |
| 355 |
|
| 356 |
function Build_Pragma_Check_Equivalent |
| 357 |
(Prag : Node_Id; |
| 358 |
Subp_Id : Entity_Id := Empty; |
| 359 |
Inher_Id : Entity_Id := Empty; |
| 360 |
Keep_Pragma_Id : Boolean := False) return Node_Id; |
| 361 |
-- Transform a pre- or [refined] postcondition denoted by Prag into an |
| 362 |
-- equivalent pragma Check. When the pre- or postcondition is inherited, |
| 363 |
-- the routine replaces the references of all formals of Inher_Id |
| 364 |
-- and primitive operations of its controlling type by references |
| 365 |
-- to the corresponding entities of Subp_Id and the descendant type. |
| 366 |
-- Keep_Pragma_Id is True when the newly created pragma should be |
| 367 |
-- in fact of the same kind as the source pragma Prag. This is used |
| 368 |
-- in GNATprove_Mode to generate the inherited pre- and postconditions. |
| 369 |
|
| 370 |
procedure Check_Applicable_Policy (N : Node_Id); |
| 371 |
-- N is either an N_Aspect or an N_Pragma node. There are two cases. If |
| 372 |
-- the name of the aspect or pragma is not one of those recognized as |
| 373 |
-- an assertion kind by an Assertion_Policy pragma, then the call has |
| 374 |
-- no effect. Note that in the case of a pragma derived from an aspect, |
| 375 |
-- the name we use for the purpose of this procedure is the aspect name, |
| 376 |
-- which may be different from the pragma name (e.g. Precondition for |
| 377 |
-- Pre aspect). In addition, 'Class aspects are recognized (and the |
| 378 |
-- corresponding special names used in the processing). |
| 379 |
-- |
| 380 |
-- If the name is a valid assertion kind name, then the Check_Policy pragma |
| 381 |
-- chain is checked for a matching entry (or for an Assertion entry which |
| 382 |
-- matches all possibilities). If a matching entry is found then the policy |
| 383 |
-- is checked. If it is On or Check, then the Is_Checked flag is set in |
| 384 |
-- the aspect or pragma node. If it is Off, Ignore, or Disable, then the |
| 385 |
-- Is_Ignored flag is set in the aspect or pragma node. Additionally for |
| 386 |
-- policy Disable, the Is_Disabled flag is set. |
| 387 |
-- |
| 388 |
-- If no matching Check_Policy pragma is found then the effect depends on |
| 389 |
-- whether -gnata was used, if so, then the call has no effect, otherwise |
| 390 |
-- Is_Ignored (but not Is_Disabled) is set True. |
| 391 |
|
| 392 |
procedure Check_External_Properties |
| 393 |
(Item : Node_Id; |
| 394 |
AR : Boolean; |
| 395 |
AW : Boolean; |
| 396 |
ER : Boolean; |
| 397 |
EW : Boolean); |
| 398 |
-- Flags AR, AW, ER and EW denote the static values of external properties |
| 399 |
-- Async_Readers, Async_Writers, Effective_Reads and Effective_Writes. Item |
| 400 |
-- is the related variable or state. Ensure legality of the combination and |
| 401 |
-- issue an error for an illegal combination. |
| 402 |
|
| 403 |
function Check_Kind (Nam : Name_Id) return Name_Id; |
| 404 |
-- This function is used in connection with pragmas Assert, Check, |
| 405 |
-- and assertion aspects and pragmas, to determine if Check pragmas |
| 406 |
-- (or corresponding assertion aspects or pragmas) are currently active |
| 407 |
-- as determined by the presence of -gnata on the command line (which |
| 408 |
-- sets the default), and the appearance of pragmas Check_Policy and |
| 409 |
-- Assertion_Policy as configuration pragmas either in a configuration |
| 410 |
-- pragma file, or at the start of the current unit, or locally given |
| 411 |
-- Check_Policy and Assertion_Policy pragmas that are currently active. |
| 412 |
-- |
| 413 |
-- The value returned is one of the names Check, Ignore, Disable (On |
| 414 |
-- returns Check, and Off returns Ignore). |
| 415 |
-- |
| 416 |
-- Note: for assertion kinds Pre'Class, Post'Class, Invariant'Class, |
| 417 |
-- and Type_Invariant'Class, the name passed is Name_uPre, Name_uPost, |
| 418 |
-- Name_uInvariant, or Name_uType_Invariant, which corresponds to _Pre, |
| 419 |
-- _Post, _Invariant, or _Type_Invariant, which are special names used |
| 420 |
-- in identifiers to represent these attribute references. |
| 421 |
|
| 422 |
procedure Check_Missing_Part_Of (Item_Id : Entity_Id); |
| 423 |
-- Determine whether the placement within the state space of an abstract |
| 424 |
-- state, variable or package instantiation denoted by Item_Id requires the |
| 425 |
-- use of indicator/option Part_Of. If this is the case, emit an error. |
| 426 |
|
| 427 |
procedure Collect_Inherited_Class_Wide_Conditions (Subp : Entity_Id); |
| 428 |
-- In GNATprove mode, when analyzing an overriding subprogram, check |
| 429 |
-- whether the overridden operations have class-wide pre/postconditions, |
| 430 |
-- and generate the corresponding pragmas. The pragmas are inserted after |
| 431 |
-- the subprogram declaration, together with those generated for other |
| 432 |
-- aspects of the subprogram. |
| 433 |
|
| 434 |
procedure Collect_Subprogram_Inputs_Outputs |
| 435 |
(Subp_Id : Entity_Id; |
| 436 |
Synthesize : Boolean := False; |
| 437 |
Subp_Inputs : in out Elist_Id; |
| 438 |
Subp_Outputs : in out Elist_Id; |
| 439 |
Global_Seen : out Boolean); |
| 440 |
-- Subsidiary to the analysis of pragmas Depends, Global, Refined_Depends |
| 441 |
-- and Refined_Global. Collect all inputs and outputs of subprogram Subp_Id |
| 442 |
-- in lists Subp_Inputs (inputs) and Subp_Outputs (outputs). The inputs and |
| 443 |
-- outputs are gathered from: |
| 444 |
-- 1) The formal parameters of the subprogram |
| 445 |
-- 2) The generic formal parameters of the generic subprogram |
| 446 |
-- 3) The current instance of a concurrent type |
| 447 |
-- 4) The items of pragma [Refined_]Global |
| 448 |
-- or |
| 449 |
-- 5) The items of pragma [Refined_]Depends if there is no pragma |
| 450 |
-- [Refined_]Global present and flag Synthesize is set to True. |
| 451 |
-- If the subprogram has no inputs and/or outputs, then the returned list |
| 452 |
-- is No_Elist. Flag Global_Seen is set when the related subprogram has |
| 453 |
-- pragma [Refined_]Global. |
| 454 |
|
| 455 |
function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean; |
| 456 |
-- N is a pragma appearing in a configuration pragma file. Most such |
| 457 |
-- pragmas are analyzed when the file is read, before parsing and analyzing |
| 458 |
-- the main unit. However, the analysis of certain pragmas results in |
| 459 |
-- adding information to the compiled main unit, and this cannot be done |
| 460 |
-- till the main unit is processed. Such pragmas return True from this |
| 461 |
-- function and in Frontend pragmas where Delay_Config_Pragma_Analyze is |
| 462 |
-- True have their analysis delayed until after the main program is parsed |
| 463 |
-- and analyzed. |
| 464 |
|
| 465 |
function Find_Related_Package_Or_Body |
| 466 |
(Prag : Node_Id; |
| 467 |
Do_Checks : Boolean := False) return Node_Id; |
| 468 |
-- Subsidiary to the analysis of pragmas |
| 469 |
-- Abstract_State |
| 470 |
-- Initial_Condition |
| 471 |
-- Initializes |
| 472 |
-- Refined_State |
| 473 |
-- Find the declaration of the related package [body] subject to pragma |
| 474 |
-- Prag. The return value is either N_Package_Declaration, N_Package_Body, |
| 475 |
-- or Empty if the placement of the pragma is illegal. If flag Do_Checks is |
| 476 |
-- set, the routine reports duplicate pragmas. |
| 477 |
|
| 478 |
function Find_Related_Declaration_Or_Body |
| 479 |
(Prag : Node_Id; |
| 480 |
Do_Checks : Boolean := False) return Node_Id; |
| 481 |
-- Subsidiary to the analysis of pragmas |
| 482 |
-- Always_Terminates |
| 483 |
-- Contract_Cases |
| 484 |
-- Depends |
| 485 |
-- Exceptional_Cases |
| 486 |
-- Extensions_Visible |
| 487 |
-- Global |
| 488 |
-- Initializes |
| 489 |
-- Max_Entry_Queue_Length |
| 490 |
-- Max_Queue_Length |
| 491 |
-- Post |
| 492 |
-- Post_Class |
| 493 |
-- Postcondition |
| 494 |
-- Pre |
| 495 |
-- Pre_Class |
| 496 |
-- Precondition |
| 497 |
-- Refined_Depends |
| 498 |
-- Refined_Global |
| 499 |
-- Refined_Post |
| 500 |
-- Refined_State |
| 501 |
-- Side_Effects |
| 502 |
-- Subprogram_Variant |
| 503 |
-- Test_Case |
| 504 |
-- Volatile_Function |
| 505 |
-- as well as attributes 'Old and 'Result. Find the declaration of the |
| 506 |
-- related entry, subprogram or task type [body] subject to pragma Prag. |
| 507 |
-- If flag Do_Checks is set, the routine reports duplicate pragmas and |
| 508 |
-- detects improper use of refinement pragmas in stand alone expression |
| 509 |
-- functions. |
| 510 |
|
| 511 |
function Get_Argument |
| 512 |
(Prag : Node_Id; |
| 513 |
Context_Id : Entity_Id := Empty) return Node_Id; |
| 514 |
-- Obtain the argument of pragma Prag depending on context and the nature |
| 515 |
-- of the pragma. The argument is extracted in the following manner: |
| 516 |
-- |
| 517 |
-- When the pragma is generated from an aspect, return the corresponding |
| 518 |
-- aspect when Context_Id denotes a generic unit. |
| 519 |
-- |
| 520 |
-- Otherwise return the first argument of Prag |
| 521 |
-- |
| 522 |
-- Context denotes the entity of the function, package or procedure where |
| 523 |
-- Prag resides. |
| 524 |
|
| 525 |
function Get_SPARK_Mode_From_Annotation |
| 526 |
(N : Node_Id) return SPARK_Mode_Type; |
| 527 |
-- Given an aspect or pragma SPARK_Mode node, return corresponding mode id |
| 528 |
|
| 529 |
procedure Initialize; |
| 530 |
-- Initializes data structures used for pragma processing. Must be called |
| 531 |
-- before analyzing each new main source program. |
| 532 |
|
| 533 |
function Is_Config_Static_String (Arg : Node_Id) return Boolean; |
| 534 |
-- This is called for a configuration pragma that requires either string |
| 535 |
-- literal or a concatenation of string literals. We cannot use normal |
| 536 |
-- static string processing because it is too early in the case of the |
| 537 |
-- pragma appearing in a configuration pragmas file. If Arg is of an |
| 538 |
-- appropriate form, then this call obtains the string (doing any necessary |
| 539 |
-- concatenations) and places it in Name_Buffer, setting Name_Len to its |
| 540 |
-- length, and then returns True. If it is not of the correct form, then an |
| 541 |
-- appropriate error message is posted, and False is returned. |
| 542 |
|
| 543 |
function Is_Elaboration_SPARK_Mode (N : Node_Id) return Boolean; |
| 544 |
-- Determine whether pragma SPARK_Mode appears in the statement part of a |
| 545 |
-- package body. |
| 546 |
|
| 547 |
function Is_Enabled_Pragma (Prag : Node_Id) return Boolean; |
| 548 |
-- Determine whether a Boolean-like SPARK pragma Prag is enabled. To be |
| 549 |
-- considered enabled, the pragma must either: |
| 550 |
-- * Appear without its Boolean expression |
| 551 |
-- * The Boolean expression evaluates to "True" |
| 552 |
-- |
| 553 |
-- Boolean-like SPARK pragmas differ from pure Boolean Ada pragmas in that |
| 554 |
-- their optional Boolean expression must be static and cannot benefit from |
| 555 |
-- forward references. The following are Boolean-like SPARK pragmas: |
| 556 |
-- Async_Readers |
| 557 |
-- Async_Writers |
| 558 |
-- Constant_After_Elaboration |
| 559 |
-- Effective_Reads |
| 560 |
-- Effective_Writes |
| 561 |
-- Extensions_Visible |
| 562 |
-- Volatile_Function |
| 563 |
|
| 564 |
function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean; |
| 565 |
-- The node N is a node for an entity and the issue is whether the |
| 566 |
-- occurrence is a reference for the purposes of giving warnings about |
| 567 |
-- unreferenced variables. This function returns True if the reference is |
| 568 |
-- not a reference from this point of view (e.g. the occurrence in a pragma |
| 569 |
-- Pack) and False if it is a real reference (e.g. the occurrence in a |
| 570 |
-- pragma Export); |
| 571 |
|
| 572 |
function Is_Pragma_String_Literal (Par : Node_Id) return Boolean; |
| 573 |
-- Given an N_Pragma_Argument_Association node, Par, which has the form of |
| 574 |
-- an operator symbol, determines whether or not it should be treated as an |
| 575 |
-- string literal. This is called by Sem_Ch6.Analyze_Operator_Symbol. If |
| 576 |
-- True is returned, the argument is converted to a string literal. If |
| 577 |
-- False is returned, then the argument is treated as an entity reference |
| 578 |
-- to the operator. |
| 579 |
|
| 580 |
function Is_Private_SPARK_Mode (N : Node_Id) return Boolean; |
| 581 |
-- Determine whether pragma SPARK_Mode appears in the private part of a |
| 582 |
-- package. |
| 583 |
|
| 584 |
function Is_Valid_Assertion_Kind (Nam : Name_Id) return Boolean; |
| 585 |
-- Returns True if Nam is one of the names recognized as a valid assertion |
| 586 |
-- kind by the Assertion_Policy pragma. Note that the 'Class cases are |
| 587 |
-- represented by the corresponding special names Name_uPre, Name_uPost, |
| 588 |
-- Name_uInvariant, and Name_uType_Invariant (_Pre, _Post, _Invariant, |
| 589 |
-- and _Type_Invariant). |
| 590 |
|
| 591 |
procedure Process_Compilation_Unit_Pragmas (N : Node_Id); |
| 592 |
-- Called at the start of processing compilation unit N to deal with any |
| 593 |
-- special issues regarding pragmas. In particular, we have to deal with |
| 594 |
-- Suppress_All at this stage, since it can appear after the unit instead |
| 595 |
-- of before (actually we allow it to appear anywhere). |
| 596 |
|
| 597 |
procedure Relocate_Pragmas_To_Anonymous_Object |
| 598 |
(Typ_Decl : Node_Id; |
| 599 |
Obj_Decl : Node_Id); |
| 600 |
-- Relocate all pragmas that appear in the visible declarations of task or |
| 601 |
-- protected type declaration Typ_Decl after the declaration of anonymous |
| 602 |
-- object Obj_Decl. Table Pragmas_On_Anonymous_Object_OK contains the list |
| 603 |
-- of candidate pragmas. |
| 604 |
|
| 605 |
procedure Relocate_Pragmas_To_Body |
| 606 |
(Subp_Body : Node_Id; |
| 607 |
Target_Body : Node_Id := Empty); |
| 608 |
-- Resocate all pragmas that follow and apply to subprogram body Subp_Body |
| 609 |
-- to its own declaration list. Candidate pragmas are classified in table |
| 610 |
-- Pragma_On_Body_Or_Stub_OK. If Target_Body is set, the pragma are moved |
| 611 |
-- to the declarations of Target_Body. This formal should be set when |
| 612 |
-- dealing with subprogram body stubs or expression functions. |
| 613 |
|
| 614 |
procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id); |
| 615 |
-- This routine is used to set an encoded interface name. The node S is |
| 616 |
-- an N_String_Literal node for the external name to be set, and E is an |
| 617 |
-- entity whose Interface_Name field is to be set. In the normal case where |
| 618 |
-- S contains a name that is a valid C identifier, then S is simply set as |
| 619 |
-- the value of the Interface_Name. Otherwise it is encoded as needed by |
| 620 |
-- particular operating systems. See the body for details of the encoding. |
| 621 |
|
| 622 |
procedure Set_Overflow_Mode (N : Node_Id); |
| 623 |
-- Sets Sem.Scope_Suppress according to the overflow modes specified in |
| 624 |
-- the pragma Overflow_Mode passed in argument. This should only be called |
| 625 |
-- after N has been successfully analyzed. |
| 626 |
|
| 627 |
function Test_Case_Arg |
| 628 |
(Prag : Node_Id; |
| 629 |
Arg_Nam : Name_Id; |
| 630 |
From_Aspect : Boolean := False) return Node_Id; |
| 631 |
-- Obtain argument "Name", "Mode", "Ensures" or "Requires" from Test_Case |
| 632 |
-- pragma Prag as denoted by Arg_Nam. When From_Aspect is set, an attempt |
| 633 |
-- is made to retrieve the argument from the corresponding aspect if there |
| 634 |
-- is one. The returned argument has several formats: |
| 635 |
-- |
| 636 |
-- N_Pragma_Argument_Association if retrieved directly from the pragma |
| 637 |
-- |
| 638 |
-- N_Component_Association if retrieved from the corresponding aspect and |
| 639 |
-- the argument appears in a named association form. |
| 640 |
-- |
| 641 |
-- An arbitrary expression if retrieved from the corresponding aspect and |
| 642 |
-- the argument appears in positional form. |
| 643 |
-- |
| 644 |
-- Empty if there is no such argument |
| 645 |
|
| 646 |
procedure Validate_Compile_Time_Warning_Errors; |
| 647 |
-- This routine is called after calling the back end to validate pragmas |
| 648 |
-- Compile_Time_Error and Compile_Time_Warning for size and alignment |
| 649 |
-- appropriateness. The reason it is called that late is to take advantage |
| 650 |
-- of any back-annotation of size and alignment performed by the back end. |
| 651 |
|
| 652 |
end Sem_Prag; |