1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree
; use Atree
;
27 with Casing
; use Casing
;
28 with Einfo
; use Einfo
;
29 with Errout
; use Errout
;
30 with Debug
; use Debug
;
31 with Fname
; use Fname
;
32 with Fname
.UF
; use Fname
.UF
;
35 with Sinfo
; use Sinfo
;
36 with Sinput
; use Sinput
;
37 with Stand
; use Stand
;
38 with Uname
; use Uname
;
40 package body Restrict
is
42 -------------------------------
43 -- SPARK Restriction Control --
44 -------------------------------
46 -- SPARK HIDE directives allow the effect of the SPARK_05 restriction to be
47 -- turned off for a specified region of code, and the following tables are
48 -- the data structures used to keep track of these regions.
50 -- The table contains pairs of source locations, the first being the start
51 -- location for hidden region, and the second being the end location.
53 -- Note that the start location is included in the hidden region, while
54 -- the end location is excluded from it. (It typically corresponds to the
55 -- next token during scanning.)
57 type SPARK_Hide_Entry
is record
62 package SPARK_Hides
is new Table
.Table
(
63 Table_Component_Type
=> SPARK_Hide_Entry
,
64 Table_Index_Type
=> Natural,
67 Table_Increment
=> 200,
68 Table_Name
=> "SPARK Hides");
70 --------------------------------
71 -- Package Local Declarations --
72 --------------------------------
74 Config_Cunit_Boolean_Restrictions
: Save_Cunit_Boolean_Restrictions
;
75 -- Save compilation unit restrictions set by config pragma files
77 Restricted_Profile_Result
: Boolean := False;
78 -- This switch memoizes the result of Restricted_Profile function calls for
79 -- improved efficiency. Valid only if Restricted_Profile_Cached is True.
80 -- Note: if this switch is ever set True, it is never turned off again.
82 Restricted_Profile_Cached
: Boolean := False;
83 -- This flag is set to True if the Restricted_Profile_Result contains the
84 -- correct cached result of Restricted_Profile calls.
86 No_Specification_Of_Aspects
: array (Aspect_Id
) of Source_Ptr
:=
87 (others => No_Location
);
88 -- Entries in this array are set to point to a previously occuring pragma
89 -- that activates a No_Specification_Of_Aspect check.
91 No_Specification_Of_Aspect_Warning
: array (Aspect_Id
) of Boolean :=
93 -- An entry in this array is set False in reponse to a previous call to
94 -- Set_No_Speficiation_Of_Aspect for pragmas in the main unit that
95 -- specify Warning as False. Once set False, an entry is never reset.
97 No_Specification_Of_Aspect_Set
: Boolean := False;
98 -- Set True if any entry of No_Specifcation_Of_Aspects has been set True.
99 -- Once set True, this is never turned off again.
101 No_Use_Of_Attribute
: array (Attribute_Id
) of Source_Ptr
:=
102 (others => No_Location
);
104 No_Use_Of_Attribute_Warning
: array (Attribute_Id
) of Boolean :=
107 No_Use_Of_Attribute_Set
: Boolean := False;
108 -- Indicates that No_Use_Of_Attribute was set at least once
110 No_Use_Of_Pragma
: array (Pragma_Id
) of Source_Ptr
:=
111 (others => No_Location
);
112 -- Source location of pragma No_Use_Of_Pragma for given pragma, a value
113 -- of System_Location indicates occurrence in system.ads.
115 No_Use_Of_Pragma_Warning
: array (Pragma_Id
) of Boolean :=
118 No_Use_Of_Pragma_Set
: Boolean := False;
119 -- Indicates that No_Use_Of_Pragma was set at least once
121 -----------------------
122 -- Local Subprograms --
123 -----------------------
125 procedure Restriction_Msg
(R
: Restriction_Id
; N
: Node_Id
);
126 -- Called if a violation of restriction R at node N is found. This routine
127 -- outputs the appropriate message or messages taking care of warning vs
128 -- real violation, serious vs non-serious, implicit vs explicit, the second
129 -- message giving the profile name if needed, and the location information.
131 function Same_Entity
(E1
, E2
: Node_Id
) return Boolean;
132 -- Returns True iff E1 and E2 represent the same entity. Used for handling
133 -- of No_Use_Of_Entity => fully_qualified_ENTITY restriction case.
135 function Same_Unit
(U1
, U2
: Node_Id
) return Boolean;
136 -- Returns True iff U1 and U2 represent the same library unit. Used for
137 -- handling of No_Dependence => Unit restriction case.
139 function Suppress_Restriction_Message
(N
: Node_Id
) return Boolean;
140 -- N is the node for a possible restriction violation message, but the
141 -- message is to be suppressed if this is an internal file and this file is
142 -- not the main unit. Returns True if message is to be suppressed.
148 function Abort_Allowed
return Boolean is
150 if Restrictions
.Set
(No_Abort_Statements
)
151 and then Restrictions
.Set
(Max_Asynchronous_Select_Nesting
)
152 and then Restrictions
.Value
(Max_Asynchronous_Select_Nesting
) = 0
160 ----------------------------------------
161 -- Add_To_Config_Boolean_Restrictions --
162 ----------------------------------------
164 procedure Add_To_Config_Boolean_Restrictions
(R
: Restriction_Id
) is
166 Config_Cunit_Boolean_Restrictions
(R
) := True;
167 end Add_To_Config_Boolean_Restrictions
;
168 -- Add specified restriction to stored configuration boolean restrictions.
169 -- This is used for handling the special case of No_Elaboration_Code.
171 -------------------------
172 -- Check_Compiler_Unit --
173 -------------------------
175 procedure Check_Compiler_Unit
(Feature
: String; N
: Node_Id
) is
177 if Compiler_Unit
then
178 Error_Msg_N
(Feature
& " not allowed in compiler unit!!??", N
);
180 end Check_Compiler_Unit
;
182 procedure Check_Compiler_Unit
(Feature
: String; Loc
: Source_Ptr
) is
184 if Compiler_Unit
then
185 Error_Msg
(Feature
& " not allowed in compiler unit!!??", Loc
);
187 end Check_Compiler_Unit
;
189 ------------------------------------
190 -- Check_Elaboration_Code_Allowed --
191 ------------------------------------
193 procedure Check_Elaboration_Code_Allowed
(N
: Node_Id
) is
195 Check_Restriction
(No_Elaboration_Code
, N
);
196 end Check_Elaboration_Code_Allowed
;
198 --------------------------------
199 -- Check_No_Implicit_Aliasing --
200 --------------------------------
202 procedure Check_No_Implicit_Aliasing
(Obj
: Node_Id
) is
206 -- If restriction not active, nothing to check
208 if not Restriction_Active
(No_Implicit_Aliasing
) then
212 -- If we have an entity name, check entity
214 if Is_Entity_Name
(Obj
) then
217 -- Restriction applies to entities that are objects
219 if Is_Object
(E
) then
220 if Is_Aliased
(E
) then
223 elsif Present
(Renamed_Object
(E
)) then
224 Check_No_Implicit_Aliasing
(Renamed_Object
(E
));
228 -- If we don't have an object, then it's OK
234 -- For selected component, check selector
236 elsif Nkind
(Obj
) = N_Selected_Component
then
237 Check_No_Implicit_Aliasing
(Selector_Name
(Obj
));
240 -- Indexed component is OK if aliased components
242 elsif Nkind
(Obj
) = N_Indexed_Component
then
243 if Has_Aliased_Components
(Etype
(Prefix
(Obj
)))
245 (Is_Access_Type
(Etype
(Prefix
(Obj
)))
246 and then Has_Aliased_Components
247 (Designated_Type
(Etype
(Prefix
(Obj
)))))
252 -- For type conversion, check converted expression
254 elsif Nkind_In
(Obj
, N_Unchecked_Type_Conversion
, N_Type_Conversion
) then
255 Check_No_Implicit_Aliasing
(Expression
(Obj
));
258 -- Explicit dereference is always OK
260 elsif Nkind
(Obj
) = N_Explicit_Dereference
then
264 -- If we fall through, then we have an aliased view that does not meet
265 -- the rules for being explicitly aliased, so issue restriction msg.
267 Check_Restriction
(No_Implicit_Aliasing
, Obj
);
268 end Check_No_Implicit_Aliasing
;
270 -----------------------------------------
271 -- Check_Implicit_Dynamic_Code_Allowed --
272 -----------------------------------------
274 procedure Check_Implicit_Dynamic_Code_Allowed
(N
: Node_Id
) is
276 Check_Restriction
(No_Implicit_Dynamic_Code
, N
);
277 end Check_Implicit_Dynamic_Code_Allowed
;
279 ----------------------------------
280 -- Check_No_Implicit_Heap_Alloc --
281 ----------------------------------
283 procedure Check_No_Implicit_Heap_Alloc
(N
: Node_Id
) is
285 Check_Restriction
(No_Implicit_Heap_Allocations
, N
);
286 end Check_No_Implicit_Heap_Alloc
;
288 -----------------------------------
289 -- Check_Obsolescent_2005_Entity --
290 -----------------------------------
292 procedure Check_Obsolescent_2005_Entity
(E
: Entity_Id
; N
: Node_Id
) is
293 function Chars_Is
(E
: Entity_Id
; S
: String) return Boolean;
294 -- Return True iff Chars (E) matches S (given in lower case)
300 function Chars_Is
(E
: Entity_Id
; S
: String) return Boolean is
301 Nam
: constant Name_Id
:= Chars
(E
);
303 if Length_Of_Name
(Nam
) /= S
'Length then
306 return Get_Name_String
(Nam
) = S
;
310 -- Start of processing for Check_Obsolescent_2005_Entity
313 if Restriction_Check_Required
(No_Obsolescent_Features
)
314 and then Ada_Version
>= Ada_2005
315 and then Chars_Is
(Scope
(E
), "handling")
316 and then Chars_Is
(Scope
(Scope
(E
)), "characters")
317 and then Chars_Is
(Scope
(Scope
(Scope
(E
))), "ada")
318 and then Scope
(Scope
(Scope
(Scope
(E
)))) = Standard_Standard
320 if Chars_Is
(E
, "is_character") or else
321 Chars_Is
(E
, "is_string") or else
322 Chars_Is
(E
, "to_character") or else
323 Chars_Is
(E
, "to_string") or else
324 Chars_Is
(E
, "to_wide_character") or else
325 Chars_Is
(E
, "to_wide_string")
327 Check_Restriction
(No_Obsolescent_Features
, N
);
330 end Check_Obsolescent_2005_Entity
;
332 ---------------------------
333 -- Check_Restricted_Unit --
334 ---------------------------
336 procedure Check_Restricted_Unit
(U
: Unit_Name_Type
; N
: Node_Id
) is
338 if Suppress_Restriction_Message
(N
) then
341 elsif Is_Spec_Name
(U
) then
343 Fnam
: constant File_Name_Type
:=
344 Get_File_Name
(U
, Subunit
=> False);
349 Get_Name_String
(Fnam
);
351 -- Nothing to do if name not at least 5 characters long ending
352 -- in .ads or .adb extension, which we strip.
355 or else (Name_Buffer
(Name_Len
- 3 .. Name_Len
) /= ".ads"
357 Name_Buffer
(Name_Len
- 3 .. Name_Len
) /= ".adb")
362 -- Strip extension and pad to eight characters
364 Name_Len
:= Name_Len
- 4;
365 Add_Str_To_Name_Buffer
((Name_Len
+ 1 .. 8 => ' '));
367 -- If predefined unit, check the list of restricted units
369 if Is_Predefined_File_Name
(Fnam
) then
370 for J
in Unit_Array
'Range loop
372 and then Name_Buffer
(1 .. 8) = Unit_Array
(J
).Filenm
374 Check_Restriction
(Unit_Array
(J
).Res_Id
, N
);
378 -- If not predefined unit, then one special check still
379 -- remains. GNAT.Current_Exception is not allowed if we have
380 -- restriction No_Exception_Propagation active.
383 if Name_Buffer
(1 .. 8) = "g-curexc" then
384 Check_Restriction
(No_Exception_Propagation
, N
);
389 end Check_Restricted_Unit
;
391 -----------------------
392 -- Check_Restriction --
393 -----------------------
395 procedure Check_Restriction
398 V
: Uint
:= Uint_Minus_1
)
400 Msg_Issued
: Boolean;
401 pragma Unreferenced
(Msg_Issued
);
403 Check_Restriction
(Msg_Issued
, R
, N
, V
);
404 end Check_Restriction
;
406 procedure Check_Restriction
407 (Msg_Issued
: out Boolean;
410 V
: Uint
:= Uint_Minus_1
)
413 -- V converted to integer form. If V is greater than Integer'Last,
414 -- it is reset to minus 1 (unknown value).
416 procedure Update_Restrictions
(Info
: in out Restrictions_Info
);
417 -- Update violation information in Info.Violated and Info.Count
419 -------------------------
420 -- Update_Restrictions --
421 -------------------------
423 procedure Update_Restrictions
(Info
: in out Restrictions_Info
) is
425 -- If not violated, set as violated now
427 if not Info
.Violated
(R
) then
428 Info
.Violated
(R
) := True;
430 if R
in All_Parameter_Restrictions
then
432 Info
.Unknown
(R
) := True;
436 Info
.Count
(R
) := VV
;
440 -- Otherwise if violated already and a parameter restriction,
441 -- update count by maximizing or summing depending on restriction.
443 elsif R
in All_Parameter_Restrictions
then
445 -- If new value is unknown, result is unknown
448 Info
.Unknown
(R
) := True;
450 -- If checked by maximization, nothing to do because the
451 -- check is per-object.
453 elsif R
in Checked_Max_Parameter_Restrictions
then
456 -- If checked by adding, do add, checking for overflow
458 elsif R
in Checked_Add_Parameter_Restrictions
then
460 pragma Unsuppress
(Overflow_Check
);
462 Info
.Count
(R
) := Info
.Count
(R
) + VV
;
464 when Constraint_Error
=>
465 Info
.Count
(R
) := Integer'Last;
466 Info
.Unknown
(R
) := True;
469 -- Should not be able to come here, known counts should only
470 -- occur for restrictions that are Checked_max or Checked_Sum.
476 end Update_Restrictions
;
478 -- Start of processing for Check_Restriction
483 -- In CodePeer and SPARK mode, we do not want to check for any
484 -- restriction, or set additional restrictions other than those already
485 -- set in gnat1drv.adb so that we have consistency between each
488 -- Just checking, SPARK does not allow restrictions to be set ???
490 if CodePeer_Mode
or GNATprove_Mode
then
494 -- In SPARK mode, issue an error for any use of class-wide, even if the
495 -- No_Dispatch restriction is not set.
497 if R
= No_Dispatch
then
498 Check_SPARK_05_Restriction
("class-wide is not allowed", N
);
501 if UI_Is_In_Int_Range
(V
) then
502 VV
:= Integer (UI_To_Int
(V
));
507 -- Count can only be specified in the checked val parameter case
509 pragma Assert
(VV
< 0 or else R
in Checked_Val_Parameter_Restrictions
);
511 -- Nothing to do if value of zero specified for parameter restriction
517 -- Update current restrictions
519 Update_Restrictions
(Restrictions
);
521 -- If in main extended unit, update main restrictions as well. Note
522 -- that as usual we check for Main_Unit explicitly to deal with the
523 -- case of configuration pragma files.
525 if Current_Sem_Unit
= Main_Unit
526 or else In_Extended_Main_Source_Unit
(N
)
528 Update_Restrictions
(Main_Restrictions
);
531 -- Nothing to do if restriction message suppressed
533 if Suppress_Restriction_Message
(N
) then
536 -- If restriction not set, nothing to do
538 elsif not Restrictions
.Set
(R
) then
541 -- Don't complain about No_Obsolescent_Features in an instance, since we
542 -- will complain on the template, which is much better. Are there other
543 -- cases like this ??? Do we need a more general mechanism ???
545 elsif R
= No_Obsolescent_Features
546 and then Instantiation_Location
(Sloc
(N
)) /= No_Location
550 -- Here if restriction set, check for violation (this is a Boolean
551 -- restriction, or a parameter restriction with a value of zero and an
552 -- unknown count, or a parameter restriction with a known value that
553 -- exceeds the restriction count).
555 elsif R
in All_Boolean_Restrictions
556 or else (Restrictions
.Unknown
(R
)
557 and then Restrictions
.Value
(R
) = 0)
558 or else Restrictions
.Count
(R
) > Restrictions
.Value
(R
)
561 Restriction_Msg
(R
, N
);
564 -- For Max_Entries and the like, do not carry forward the violation
565 -- count because it does not affect later declarations.
567 if R
in Checked_Max_Parameter_Restrictions
then
568 Restrictions
.Count
(R
) := 0;
569 Restrictions
.Violated
(R
) := False;
571 end Check_Restriction
;
573 -------------------------------------
574 -- Check_Restriction_No_Dependence --
575 -------------------------------------
577 procedure Check_Restriction_No_Dependence
(U
: Node_Id
; Err
: Node_Id
) is
581 -- Ignore call if node U is not in the main source unit. This avoids
582 -- cascaded errors, e.g. when Ada.Containers units with other units.
583 -- However, allow Standard_Location here, since this catches some cases
584 -- of constructs that get converted to run-time calls.
586 if not In_Extended_Main_Source_Unit
(U
)
587 and then Sloc
(U
) /= Standard_Location
592 -- Loop through entries in No_Dependence table to check each one in turn
594 for J
in No_Dependences
.First
.. No_Dependences
.Last
loop
595 DU
:= No_Dependences
.Table
(J
).Unit
;
597 if Same_Unit
(U
, DU
) then
598 Error_Msg_Sloc
:= Sloc
(DU
);
599 Error_Msg_Node_1
:= DU
;
601 if No_Dependences
.Table
(J
).Warn
then
603 ("?*?violation of restriction `No_Dependence '='> &`#",
607 ("|violation of restriction `No_Dependence '='> &`#",
614 end Check_Restriction_No_Dependence
;
616 --------------------------------------------------
617 -- Check_Restriction_No_Specification_Of_Aspect --
618 --------------------------------------------------
620 procedure Check_Restriction_No_Specification_Of_Aspect
(N
: Node_Id
) is
625 -- Ignore call if no instances of this restriction set
627 if not No_Specification_Of_Aspect_Set
then
631 -- Ignore call if node N is not in the main source unit, since we only
632 -- give messages for the main unit. This avoids giving messages for
633 -- aspects that are specified in withed units.
635 if not In_Extended_Main_Source_Unit
(N
) then
639 Id
:= Identifier
(N
);
640 A_Id
:= Get_Aspect_Id
(Chars
(Id
));
641 pragma Assert
(A_Id
/= No_Aspect
);
643 Error_Msg_Sloc
:= No_Specification_Of_Aspects
(A_Id
);
645 if Error_Msg_Sloc
/= No_Location
then
646 Error_Msg_Node_1
:= Id
;
647 Error_Msg_Warn
:= No_Specification_Of_Aspect_Warning
(A_Id
);
649 ("<*<violation of restriction `No_Specification_Of_Aspect '='> &`#",
652 end Check_Restriction_No_Specification_Of_Aspect
;
654 -------------------------------------------
655 -- Check_Restriction_No_Use_Of_Attribute --
656 --------------------------------------------
658 procedure Check_Restriction_No_Use_Of_Attribute
(N
: Node_Id
) is
659 Id
: constant Name_Id
:= Chars
(N
);
660 A_Id
: constant Attribute_Id
:= Get_Attribute_Id
(Id
);
663 -- Ignore call if node N is not in the main source unit, since we only
664 -- give messages for the main unit. This avoids giving messages for
665 -- aspects that are specified in withed units.
667 if not In_Extended_Main_Source_Unit
(N
) then
671 -- If nothing set, nothing to check
673 if not No_Use_Of_Attribute_Set
then
677 Error_Msg_Sloc
:= No_Use_Of_Attribute
(A_Id
);
679 if Error_Msg_Sloc
/= No_Location
then
680 Error_Msg_Node_1
:= N
;
681 Error_Msg_Warn
:= No_Use_Of_Attribute_Warning
(A_Id
);
683 ("<*<violation of restriction `No_Use_Of_Attribute '='> &`#", N
);
685 end Check_Restriction_No_Use_Of_Attribute
;
687 ----------------------------------------
688 -- Check_Restriction_No_Use_Of_Entity --
689 ----------------------------------------
691 procedure Check_Restriction_No_Use_Of_Entity
(N
: Node_Id
) is
693 -- Error defence (not clearly necessary, but better safe)
695 if No
(Entity
(N
)) then
699 -- If simple name of entity not flagged with Boolean2 flag, then there
700 -- cannot be a matching entry in the table, so skip the search.
702 if Get_Name_Table_Boolean2
(Chars
(Entity
(N
))) = False then
706 -- Restriction is only recognized within a configuration
707 -- pragma file, or within a unit of the main extended
708 -- program. Note: the test for Main_Unit is needed to
709 -- properly include the case of configuration pragma files.
711 if Current_Sem_Unit
/= Main_Unit
712 and then not In_Extended_Main_Source_Unit
(N
)
717 -- Here we must search the table
719 for J
in No_Use_Of_Entity
.First
.. No_Use_Of_Entity
.Last
loop
721 NE_Ent
: NE_Entry
renames No_Use_Of_Entity
.Table
(J
);
727 Expr
:= NE_Ent
.Entity
;
729 -- Here if at outer level of entity name in reference
731 if Scope
(Ent
) = Standard_Standard
then
732 if Nkind_In
(Expr
, N_Identifier
, N_Operator_Symbol
)
733 and then Chars
(Ent
) = Chars
(Expr
)
735 Error_Msg_Node_1
:= N
;
736 Error_Msg_Warn
:= NE_Ent
.Warn
;
737 Error_Msg_Sloc
:= Sloc
(NE_Ent
.Entity
);
739 ("<*<reference to & violates restriction "
740 & "No_Use_Of_Entity #", N
);
747 -- Here if at outer level of entity name in table
749 elsif Nkind_In
(Expr
, N_Identifier
, N_Operator_Symbol
) then
752 -- Here if neither at the outer level
755 pragma Assert
(Nkind
(Expr
) = N_Selected_Component
);
757 if Chars
(Selector_Name
(Expr
)) /= Chars
(Ent
) then
766 exit when not Is_Internal_Name
(Chars
(Ent
));
769 Expr
:= Prefix
(Expr
);
771 -- Entry did not match
777 end Check_Restriction_No_Use_Of_Entity
;
779 ----------------------------------------
780 -- Check_Restriction_No_Use_Of_Pragma --
781 ----------------------------------------
783 procedure Check_Restriction_No_Use_Of_Pragma
(N
: Node_Id
) is
784 Id
: constant Node_Id
:= Pragma_Identifier
(N
);
785 P_Id
: constant Pragma_Id
:= Get_Pragma_Id
(Chars
(Id
));
788 -- Ignore call if node N is not in the main source unit, since we only
789 -- give messages for the main unit. This avoids giving messages for
790 -- aspects that are specified in withed units.
792 if not In_Extended_Main_Source_Unit
(N
) then
796 -- If nothing set, nothing to check
798 if not No_Use_Of_Pragma_Set
then
802 Error_Msg_Sloc
:= No_Use_Of_Pragma
(P_Id
);
804 if Error_Msg_Sloc
/= No_Location
then
805 Error_Msg_Node_1
:= Id
;
806 Error_Msg_Warn
:= No_Use_Of_Pragma_Warning
(P_Id
);
808 ("<*<violation of restriction `No_Use_Of_Pragma '='> &`#", Id
);
810 end Check_Restriction_No_Use_Of_Pragma
;
812 --------------------------------------
813 -- Check_Wide_Character_Restriction --
814 --------------------------------------
816 procedure Check_Wide_Character_Restriction
(E
: Entity_Id
; N
: Node_Id
) is
818 if Restriction_Check_Required
(No_Wide_Characters
)
819 and then Comes_From_Source
(N
)
822 T
: constant Entity_Id
:= Root_Type
(E
);
824 if T
= Standard_Wide_Character
or else
825 T
= Standard_Wide_String
or else
826 T
= Standard_Wide_Wide_Character
or else
827 T
= Standard_Wide_Wide_String
829 Check_Restriction
(No_Wide_Characters
, N
);
833 end Check_Wide_Character_Restriction
;
835 ----------------------------------------
836 -- Cunit_Boolean_Restrictions_Restore --
837 ----------------------------------------
839 procedure Cunit_Boolean_Restrictions_Restore
840 (R
: Save_Cunit_Boolean_Restrictions
)
843 for J
in Cunit_Boolean_Restrictions
loop
844 Restrictions
.Set
(J
) := R
(J
);
847 -- If No_Elaboration_Code set in configuration restrictions, and we
848 -- in the main extended source, then set it here now. This is part of
849 -- the special processing for No_Elaboration_Code.
851 if In_Extended_Main_Source_Unit
(Cunit_Entity
(Current_Sem_Unit
))
852 and then Config_Cunit_Boolean_Restrictions
(No_Elaboration_Code
)
854 Restrictions
.Set
(No_Elaboration_Code
) := True;
856 end Cunit_Boolean_Restrictions_Restore
;
858 -------------------------------------
859 -- Cunit_Boolean_Restrictions_Save --
860 -------------------------------------
862 function Cunit_Boolean_Restrictions_Save
863 return Save_Cunit_Boolean_Restrictions
865 R
: Save_Cunit_Boolean_Restrictions
;
868 for J
in Cunit_Boolean_Restrictions
loop
869 R
(J
) := Restrictions
.Set
(J
);
873 end Cunit_Boolean_Restrictions_Save
;
875 ------------------------
876 -- Get_Restriction_Id --
877 ------------------------
879 function Get_Restriction_Id
880 (N
: Name_Id
) return Restriction_Id
884 Set_Casing
(All_Upper_Case
);
886 for J
in All_Restrictions
loop
888 S
: constant String := Restriction_Id
'Image (J
);
890 if S
= Name_Buffer
(1 .. Name_Len
) then
896 return Not_A_Restriction_Id
;
897 end Get_Restriction_Id
;
899 --------------------------------
900 -- Is_In_Hidden_Part_In_SPARK --
901 --------------------------------
903 function Is_In_Hidden_Part_In_SPARK
(Loc
: Source_Ptr
) return Boolean is
905 -- Loop through table of hidden ranges
907 for J
in SPARK_Hides
.First
.. SPARK_Hides
.Last
loop
908 if SPARK_Hides
.Table
(J
).Start
<= Loc
909 and then Loc
< SPARK_Hides
.Table
(J
).Stop
916 end Is_In_Hidden_Part_In_SPARK
;
918 -------------------------------
919 -- No_Exception_Handlers_Set --
920 -------------------------------
922 function No_Exception_Handlers_Set
return Boolean is
924 return (No_Run_Time_Mode
or else Configurable_Run_Time_Mode
)
925 and then (Restrictions
.Set
(No_Exception_Handlers
)
927 Restrictions
.Set
(No_Exception_Propagation
));
928 end No_Exception_Handlers_Set
;
930 -------------------------------------
931 -- No_Exception_Propagation_Active --
932 -------------------------------------
934 function No_Exception_Propagation_Active
return Boolean is
936 return (No_Run_Time_Mode
937 or else Configurable_Run_Time_Mode
938 or else Debug_Flag_Dot_G
)
939 and then Restriction_Active
(No_Exception_Propagation
);
940 end No_Exception_Propagation_Active
;
942 --------------------------------
943 -- OK_No_Dependence_Unit_Name --
944 --------------------------------
946 function OK_No_Dependence_Unit_Name
(N
: Node_Id
) return Boolean is
948 if Nkind
(N
) = N_Selected_Component
then
950 OK_No_Dependence_Unit_Name
(Prefix
(N
))
952 OK_No_Dependence_Unit_Name
(Selector_Name
(N
));
954 elsif Nkind
(N
) = N_Identifier
then
958 Error_Msg_N
("wrong form for unit name for No_Dependence", N
);
961 end OK_No_Dependence_Unit_Name
;
963 ------------------------------
964 -- OK_No_Use_Of_Entity_Name --
965 ------------------------------
967 function OK_No_Use_Of_Entity_Name
(N
: Node_Id
) return Boolean is
969 if Nkind
(N
) = N_Selected_Component
then
971 OK_No_Use_Of_Entity_Name
(Prefix
(N
))
973 OK_No_Use_Of_Entity_Name
(Selector_Name
(N
));
975 elsif Nkind_In
(N
, N_Identifier
, N_Operator_Symbol
) then
979 Error_Msg_N
("wrong form for entity name for No_Use_Of_Entity", N
);
982 end OK_No_Use_Of_Entity_Name
;
984 ----------------------------------
985 -- Process_Restriction_Synonyms --
986 ----------------------------------
988 -- Note: body of this function must be coordinated with list of renaming
989 -- declarations in System.Rident.
991 function Process_Restriction_Synonyms
(N
: Node_Id
) return Name_Id
993 Old_Name
: constant Name_Id
:= Chars
(N
);
998 when Name_Boolean_Entry_Barriers
=>
999 New_Name
:= Name_Simple_Barriers
;
1001 when Name_Max_Entry_Queue_Depth
=>
1002 New_Name
:= Name_Max_Entry_Queue_Length
;
1004 when Name_No_Dynamic_Interrupts
=>
1005 New_Name
:= Name_No_Dynamic_Attachment
;
1007 when Name_No_Requeue
=>
1008 New_Name
:= Name_No_Requeue_Statements
;
1010 when Name_No_Task_Attributes
=>
1011 New_Name
:= Name_No_Task_Attributes_Package
;
1013 -- SPARK is special in that we unconditionally warn
1016 Error_Msg_Name_1
:= Name_SPARK
;
1017 Error_Msg_N
("restriction identifier % is obsolescent??", N
);
1018 Error_Msg_Name_1
:= Name_SPARK_05
;
1019 Error_Msg_N
("|use restriction identifier % instead??", N
);
1020 return Name_SPARK_05
;
1026 -- Output warning if we are warning on obsolescent features for all
1027 -- cases other than SPARK.
1029 if Warn_On_Obsolescent_Feature
then
1030 Error_Msg_Name_1
:= Old_Name
;
1031 Error_Msg_N
("restriction identifier % is obsolescent?j?", N
);
1032 Error_Msg_Name_1
:= New_Name
;
1033 Error_Msg_N
("|use restriction identifier % instead?j?", N
);
1037 end Process_Restriction_Synonyms
;
1039 --------------------------------------
1040 -- Reset_Cunit_Boolean_Restrictions --
1041 --------------------------------------
1043 procedure Reset_Cunit_Boolean_Restrictions
is
1045 for J
in Cunit_Boolean_Restrictions
loop
1046 Restrictions
.Set
(J
) := False;
1048 end Reset_Cunit_Boolean_Restrictions
;
1050 -----------------------------------------------
1051 -- Restore_Config_Cunit_Boolean_Restrictions --
1052 -----------------------------------------------
1054 procedure Restore_Config_Cunit_Boolean_Restrictions
is
1056 Cunit_Boolean_Restrictions_Restore
(Config_Cunit_Boolean_Restrictions
);
1057 end Restore_Config_Cunit_Boolean_Restrictions
;
1059 ------------------------
1060 -- Restricted_Profile --
1061 ------------------------
1063 function Restricted_Profile
return Boolean is
1065 if Restricted_Profile_Cached
then
1066 return Restricted_Profile_Result
;
1069 Restricted_Profile_Result
:= True;
1070 Restricted_Profile_Cached
:= True;
1073 R
: Restriction_Flags
renames Profile_Info
(Restricted
).Set
;
1074 V
: Restriction_Values
renames Profile_Info
(Restricted
).Value
;
1076 for J
in R
'Range loop
1078 and then (Restrictions
.Set
(J
) = False
1079 or else Restriction_Warnings
(J
)
1081 (J
in All_Parameter_Restrictions
1082 and then Restrictions
.Value
(J
) > V
(J
)))
1084 Restricted_Profile_Result
:= False;
1089 return Restricted_Profile_Result
;
1092 end Restricted_Profile
;
1094 ------------------------
1095 -- Restriction_Active --
1096 ------------------------
1098 function Restriction_Active
(R
: All_Restrictions
) return Boolean is
1100 return Restrictions
.Set
(R
) and then not Restriction_Warnings
(R
);
1101 end Restriction_Active
;
1103 --------------------------------
1104 -- Restriction_Check_Required --
1105 --------------------------------
1107 function Restriction_Check_Required
(R
: All_Restrictions
) return Boolean is
1109 return Restrictions
.Set
(R
);
1110 end Restriction_Check_Required
;
1112 ---------------------
1113 -- Restriction_Msg --
1114 ---------------------
1116 procedure Restriction_Msg
(R
: Restriction_Id
; N
: Node_Id
) is
1117 Msg
: String (1 .. 100);
1120 procedure Add_Char
(C
: Character);
1121 -- Append given character to Msg, bumping Len
1123 procedure Add_Str
(S
: String);
1124 -- Append given string to Msg, bumping Len appropriately
1126 procedure Id_Case
(S
: String; Quotes
: Boolean := True);
1127 -- Given a string S, case it according to current identifier casing,
1128 -- except for SPARK_05 (an acronym) which is set all upper case, and
1129 -- store in Error_Msg_String. Then append `~` to the message buffer
1130 -- to output the string unchanged surrounded in quotes. The quotes
1131 -- are suppressed if Quotes = False.
1137 procedure Add_Char
(C
: Character) is
1147 procedure Add_Str
(S
: String) is
1149 Msg
(Len
+ 1 .. Len
+ S
'Length) := S
;
1150 Len
:= Len
+ S
'Length;
1157 procedure Id_Case
(S
: String; Quotes
: Boolean := True) is
1159 Name_Buffer
(1 .. S
'Last) := S
;
1160 Name_Len
:= S
'Length;
1162 if R
= SPARK_05
then
1165 Set_Casing
(Identifier_Casing
(Get_Source_File_Index
(Sloc
(N
))));
1168 Error_Msg_Strlen
:= Name_Len
;
1169 Error_Msg_String
(1 .. Name_Len
) := Name_Buffer
(1 .. Name_Len
);
1178 -- Start of processing for Restriction_Msg
1181 -- Set warning message if warning
1183 if Restriction_Warnings
(R
) then
1186 -- If real violation (not warning), then mark it as non-serious unless
1187 -- it is a violation of No_Finalization in which case we leave it as a
1188 -- serious message, since otherwise we get crashes during attempts to
1189 -- expand stuff that is not properly formed due to assumptions made
1190 -- about no finalization being present.
1192 elsif R
/= No_Finalization
then
1196 Error_Msg_Sloc
:= Restrictions_Loc
(R
);
1198 -- Set main message, adding implicit if no source location
1200 if Error_Msg_Sloc
> No_Location
1201 or else Error_Msg_Sloc
= System_Location
1203 Add_Str
("violation of restriction ");
1205 Add_Str
("violation of implicit restriction ");
1206 Error_Msg_Sloc
:= No_Location
;
1209 -- Case of parameterized restriction
1211 if R
in All_Parameter_Restrictions
then
1213 Id_Case
(Restriction_Id
'Image (R
), Quotes
=> False);
1215 Error_Msg_Uint_1
:= UI_From_Int
(Int
(Restrictions
.Value
(R
)));
1217 -- Case of boolean restriction
1220 Id_Case
(Restriction_Id
'Image (R
));
1223 -- Case of no secondary profile continuation message
1225 if Restriction_Profile_Name
(R
) = No_Profile
then
1226 if Error_Msg_Sloc
/= No_Location
then
1231 Error_Msg_N
(Msg
(1 .. Len
), N
);
1233 -- Case of secondary profile continuation message present
1237 Error_Msg_N
(Msg
(1 .. Len
), N
);
1242 -- Set as warning if warning case
1244 if Restriction_Warnings
(R
) then
1250 Add_Str
("from profile ");
1251 Id_Case
(Profile_Name
'Image (Restriction_Profile_Name
(R
)));
1253 -- Add location if we have one
1255 if Error_Msg_Sloc
/= No_Location
then
1259 -- Output unconditional message and we are done
1262 Error_Msg_N
(Msg
(1 .. Len
), N
);
1264 end Restriction_Msg
;
1270 function Same_Entity
(E1
, E2
: Node_Id
) return Boolean is
1272 if Nkind_In
(E1
, N_Identifier
, N_Operator_Symbol
)
1274 Nkind_In
(E2
, N_Identifier
, N_Operator_Symbol
)
1276 return Chars
(E1
) = Chars
(E2
);
1278 elsif Nkind_In
(E1
, N_Selected_Component
, N_Expanded_Name
)
1280 Nkind_In
(E2
, N_Selected_Component
, N_Expanded_Name
)
1282 return Same_Unit
(Prefix
(E1
), Prefix
(E2
))
1284 Same_Unit
(Selector_Name
(E1
), Selector_Name
(E2
));
1294 function Same_Unit
(U1
, U2
: Node_Id
) return Boolean is
1296 if Nkind
(U1
) = N_Identifier
and then Nkind
(U2
) = N_Identifier
then
1297 return Chars
(U1
) = Chars
(U2
);
1299 elsif Nkind_In
(U1
, N_Selected_Component
, N_Expanded_Name
)
1301 Nkind_In
(U2
, N_Selected_Component
, N_Expanded_Name
)
1303 return Same_Unit
(Prefix
(U1
), Prefix
(U2
))
1305 Same_Unit
(Selector_Name
(U1
), Selector_Name
(U2
));
1311 --------------------------------------------
1312 -- Save_Config_Cunit_Boolean_Restrictions --
1313 --------------------------------------------
1315 procedure Save_Config_Cunit_Boolean_Restrictions
is
1317 Config_Cunit_Boolean_Restrictions
:= Cunit_Boolean_Restrictions_Save
;
1318 end Save_Config_Cunit_Boolean_Restrictions
;
1320 ------------------------------
1321 -- Set_Hidden_Part_In_SPARK --
1322 ------------------------------
1324 procedure Set_Hidden_Part_In_SPARK
(Loc1
, Loc2
: Source_Ptr
) is
1326 SPARK_Hides
.Increment_Last
;
1327 SPARK_Hides
.Table
(SPARK_Hides
.Last
).Start
:= Loc1
;
1328 SPARK_Hides
.Table
(SPARK_Hides
.Last
).Stop
:= Loc2
;
1329 end Set_Hidden_Part_In_SPARK
;
1331 ------------------------------
1332 -- Set_Profile_Restrictions --
1333 ------------------------------
1335 procedure Set_Profile_Restrictions
1340 R
: Restriction_Flags
renames Profile_Info
(P
).Set
;
1341 V
: Restriction_Values
renames Profile_Info
(P
).Value
;
1344 for J
in R
'Range loop
1347 Already_Restricted
: constant Boolean := Restriction_Active
(J
);
1350 -- Set the restriction
1352 if J
in All_Boolean_Restrictions
then
1353 Set_Restriction
(J
, N
);
1355 Set_Restriction
(J
, N
, V
(J
));
1358 -- Record that this came from a Profile[_Warnings] restriction
1360 Restriction_Profile_Name
(J
) := P
;
1362 -- Set warning flag, except that we do not set the warning
1363 -- flag if the restriction was already active and this is
1364 -- the warning case. That avoids a warning overriding a real
1365 -- restriction, which should never happen.
1367 if not (Warn
and Already_Restricted
) then
1368 Restriction_Warnings
(J
) := Warn
;
1373 end Set_Profile_Restrictions
;
1375 ---------------------
1376 -- Set_Restriction --
1377 ---------------------
1379 -- Case of Boolean restriction
1381 procedure Set_Restriction
1382 (R
: All_Boolean_Restrictions
;
1386 Restrictions
.Set
(R
) := True;
1388 if Restricted_Profile_Cached
and Restricted_Profile_Result
then
1391 Restricted_Profile_Cached
:= False;
1394 -- Set location, but preserve location of system restriction for nice
1395 -- error msg with run time name.
1397 if Restrictions_Loc
(R
) /= System_Location
then
1398 Restrictions_Loc
(R
) := Sloc
(N
);
1401 -- Note restriction came from restriction pragma, not profile
1403 Restriction_Profile_Name
(R
) := No_Profile
;
1405 -- Record the restriction if we are in the main unit, or in the extended
1406 -- main unit. The reason that we test separately for Main_Unit is that
1407 -- gnat.adc is processed with Current_Sem_Unit = Main_Unit, but nodes in
1408 -- gnat.adc do not appear to be in the extended main source unit (they
1409 -- probably should do ???)
1411 if Current_Sem_Unit
= Main_Unit
1412 or else In_Extended_Main_Source_Unit
(N
)
1414 if not Restriction_Warnings
(R
) then
1415 Main_Restrictions
.Set
(R
) := True;
1418 end Set_Restriction
;
1420 -- Case of parameter restriction
1422 procedure Set_Restriction
1423 (R
: All_Parameter_Restrictions
;
1428 if Restricted_Profile_Cached
and Restricted_Profile_Result
then
1431 Restricted_Profile_Cached
:= False;
1434 if Restrictions
.Set
(R
) then
1435 if V
< Restrictions
.Value
(R
) then
1436 Restrictions
.Value
(R
) := V
;
1437 Restrictions_Loc
(R
) := Sloc
(N
);
1441 Restrictions
.Set
(R
) := True;
1442 Restrictions
.Value
(R
) := V
;
1443 Restrictions_Loc
(R
) := Sloc
(N
);
1446 -- Record the restriction if we are in the main unit, or in the extended
1447 -- main unit. The reason that we test separately for Main_Unit is that
1448 -- gnat.adc is processed with Current_Sem_Unit = Main_Unit, but nodes in
1449 -- gnat.adc do not appear to be the extended main source unit (they
1450 -- probably should do ???)
1452 if Current_Sem_Unit
= Main_Unit
1453 or else In_Extended_Main_Source_Unit
(N
)
1455 if Main_Restrictions
.Set
(R
) then
1456 if V
< Main_Restrictions
.Value
(R
) then
1457 Main_Restrictions
.Value
(R
) := V
;
1460 elsif not Restriction_Warnings
(R
) then
1461 Main_Restrictions
.Set
(R
) := True;
1462 Main_Restrictions
.Value
(R
) := V
;
1466 -- Note restriction came from restriction pragma, not profile
1468 Restriction_Profile_Name
(R
) := No_Profile
;
1469 end Set_Restriction
;
1471 -----------------------------------
1472 -- Set_Restriction_No_Dependence --
1473 -----------------------------------
1475 procedure Set_Restriction_No_Dependence
1478 Profile
: Profile_Name
:= No_Profile
)
1481 -- Loop to check for duplicate entry
1483 for J
in No_Dependences
.First
.. No_Dependences
.Last
loop
1485 -- Case of entry already in table
1487 if Same_Unit
(Unit
, No_Dependences
.Table
(J
).Unit
) then
1489 -- Error has precedence over warning
1492 No_Dependences
.Table
(J
).Warn
:= False;
1499 -- Entry is not currently in table
1501 No_Dependences
.Append
((Unit
, Warn
, Profile
));
1502 end Set_Restriction_No_Dependence
;
1504 --------------------------------------
1505 -- Set_Restriction_No_Use_Of_Entity --
1506 --------------------------------------
1508 procedure Set_Restriction_No_Use_Of_Entity
1511 Profile
: Profile_Name
:= No_Profile
)
1516 -- Loop to check for duplicate entry
1518 for J
in No_Use_Of_Entity
.First
.. No_Use_Of_Entity
.Last
loop
1520 -- Case of entry already in table
1522 if Same_Entity
(Entity
, No_Use_Of_Entity
.Table
(J
).Entity
) then
1524 -- Error has precedence over warning
1527 No_Use_Of_Entity
.Table
(J
).Warn
:= False;
1534 -- Entry is not currently in table
1536 No_Use_Of_Entity
.Append
((Entity
, Warn
, Profile
));
1538 -- Now we need to find the direct name and set Boolean2 flag
1540 if Nkind_In
(Entity
, N_Identifier
, N_Operator_Symbol
) then
1544 pragma Assert
(Nkind
(Entity
) = N_Selected_Component
);
1545 Nam
:= Selector_Name
(Entity
);
1546 pragma Assert
(Nkind_In
(Nam
, N_Identifier
, N_Operator_Symbol
));
1549 Set_Name_Table_Boolean2
(Chars
(Nam
), True);
1550 end Set_Restriction_No_Use_Of_Entity
;
1552 ------------------------------------------------
1553 -- Set_Restriction_No_Specification_Of_Aspect --
1554 ------------------------------------------------
1556 procedure Set_Restriction_No_Specification_Of_Aspect
1560 A_Id
: constant Aspect_Id_Exclude_No_Aspect
:= Get_Aspect_Id
(Chars
(N
));
1563 No_Specification_Of_Aspects
(A_Id
) := Sloc
(N
);
1565 if Warning
= False then
1566 No_Specification_Of_Aspect_Warning
(A_Id
) := False;
1569 No_Specification_Of_Aspect_Set
:= True;
1570 end Set_Restriction_No_Specification_Of_Aspect
;
1572 procedure Set_Restriction_No_Specification_Of_Aspect
(A_Id
: Aspect_Id
) is
1574 No_Specification_Of_Aspect_Set
:= True;
1575 No_Specification_Of_Aspects
(A_Id
) := System_Location
;
1576 No_Specification_Of_Aspect_Warning
(A_Id
) := False;
1577 end Set_Restriction_No_Specification_Of_Aspect
;
1579 -----------------------------------------
1580 -- Set_Restriction_No_Use_Of_Attribute --
1581 -----------------------------------------
1583 procedure Set_Restriction_No_Use_Of_Attribute
1587 A_Id
: constant Attribute_Id
:= Get_Attribute_Id
(Chars
(N
));
1590 No_Use_Of_Attribute_Set
:= True;
1591 No_Use_Of_Attribute
(A_Id
) := Sloc
(N
);
1593 if Warning
= False then
1594 No_Use_Of_Attribute_Warning
(A_Id
) := False;
1596 end Set_Restriction_No_Use_Of_Attribute
;
1598 procedure Set_Restriction_No_Use_Of_Attribute
(A_Id
: Attribute_Id
) is
1600 No_Use_Of_Attribute_Set
:= True;
1601 No_Use_Of_Attribute
(A_Id
) := System_Location
;
1602 No_Use_Of_Attribute_Warning
(A_Id
) := False;
1603 end Set_Restriction_No_Use_Of_Attribute
;
1605 --------------------------------------
1606 -- Set_Restriction_No_Use_Of_Pragma --
1607 --------------------------------------
1609 procedure Set_Restriction_No_Use_Of_Pragma
1613 A_Id
: constant Pragma_Id
:= Get_Pragma_Id
(Chars
(N
));
1616 No_Use_Of_Pragma_Set
:= True;
1617 No_Use_Of_Pragma
(A_Id
) := Sloc
(N
);
1619 if Warning
= False then
1620 No_Use_Of_Pragma_Warning
(A_Id
) := False;
1622 end Set_Restriction_No_Use_Of_Pragma
;
1624 procedure Set_Restriction_No_Use_Of_Pragma
(A_Id
: Pragma_Id
) is
1626 No_Use_Of_Pragma_Set
:= True;
1627 No_Use_Of_Pragma
(A_Id
) := System_Location
;
1628 No_Use_Of_Pragma_Warning
(A_Id
) := False;
1629 end Set_Restriction_No_Use_Of_Pragma
;
1631 --------------------------------
1632 -- Check_SPARK_05_Restriction --
1633 --------------------------------
1635 procedure Check_SPARK_05_Restriction
1638 Force
: Boolean := False)
1640 Msg_Issued
: Boolean;
1641 Save_Error_Msg_Sloc
: Source_Ptr
;
1642 Onode
: constant Node_Id
:= Original_Node
(N
);
1645 -- Output message if Force set
1649 -- Or if this node comes from source
1651 or else Comes_From_Source
(N
)
1653 -- Or if this is a range node which rewrites a range attribute and
1654 -- the range attribute comes from source.
1656 or else (Nkind
(N
) = N_Range
1657 and then Nkind
(Onode
) = N_Attribute_Reference
1658 and then Attribute_Name
(Onode
) = Name_Range
1659 and then Comes_From_Source
(Onode
))
1661 -- Or this is an expression that does not come from source, which is
1662 -- a rewriting of an expression that does come from source.
1664 or else (Nkind
(N
) in N_Subexpr
and then Comes_From_Source
(Onode
))
1666 if Restriction_Check_Required
(SPARK_05
)
1667 and then Is_In_Hidden_Part_In_SPARK
(Sloc
(N
))
1672 -- Since the call to Restriction_Msg from Check_Restriction may set
1673 -- Error_Msg_Sloc to the location of the pragma restriction, save and
1674 -- restore the previous value of the global variable around the call.
1676 Save_Error_Msg_Sloc
:= Error_Msg_Sloc
;
1677 Check_Restriction
(Msg_Issued
, SPARK_05
, First_Node
(N
));
1678 Error_Msg_Sloc
:= Save_Error_Msg_Sloc
;
1681 Error_Msg_F
("\\| " & Msg
, N
);
1684 end Check_SPARK_05_Restriction
;
1686 procedure Check_SPARK_05_Restriction
(Msg1
, Msg2
: String; N
: Node_Id
) is
1687 Msg_Issued
: Boolean;
1688 Save_Error_Msg_Sloc
: Source_Ptr
;
1691 pragma Assert
(Msg2
'Length /= 0 and then Msg2
(Msg2
'First) = '\');
1693 if Comes_From_Source
(Original_Node
(N
)) then
1694 if Restriction_Check_Required
(SPARK_05
)
1695 and then Is_In_Hidden_Part_In_SPARK
(Sloc
(N
))
1700 -- Since the call to Restriction_Msg from Check_Restriction may set
1701 -- Error_Msg_Sloc to the location of the pragma restriction, save and
1702 -- restore the previous value of the global variable around the call.
1704 Save_Error_Msg_Sloc
:= Error_Msg_Sloc
;
1705 Check_Restriction
(Msg_Issued
, SPARK_05
, First_Node
(N
));
1706 Error_Msg_Sloc
:= Save_Error_Msg_Sloc
;
1709 Error_Msg_F
("\\| " & Msg1
, N
);
1710 Error_Msg_F
(Msg2
, N
);
1713 end Check_SPARK_05_Restriction
;
1715 ----------------------------------
1716 -- Suppress_Restriction_Message --
1717 ----------------------------------
1719 function Suppress_Restriction_Message
(N
: Node_Id
) return Boolean is
1721 -- We only output messages for the extended main source unit
1723 if In_Extended_Main_Source_Unit
(N
) then
1726 -- If loaded by rtsfind, then suppress message
1728 elsif Sloc
(N
) <= No_Location
then
1731 -- Otherwise suppress message if internal file
1734 return Is_Internal_File_Name
(Unit_File_Name
(Get_Source_Unit
(N
)));
1736 end Suppress_Restriction_Message
;
1738 ---------------------
1739 -- Tasking_Allowed --
1740 ---------------------
1742 function Tasking_Allowed
return Boolean is
1744 return not Restrictions
.Set
(No_Tasking
)
1745 and then (not Restrictions
.Set
(Max_Tasks
)
1746 or else Restrictions
.Value
(Max_Tasks
) > 0)
1747 and then not No_Run_Time_Mode
;
1748 end Tasking_Allowed
;