1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2023, 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 Csets
; use Csets
;
34 function SJLJ_Exceptions
return Boolean is
36 return Exception_Mechanism
= Back_End_SJLJ
;
43 function ZCX_Exceptions
return Boolean is
45 return Exception_Mechanism
= Back_End_ZCX
;
48 ------------------------------
49 -- Register_Config_Switches --
50 ------------------------------
52 procedure Register_Config_Switches
is
54 Ada_Version_Config
:= Ada_Version
;
55 Ada_Version_Pragma_Config
:= Ada_Version_Pragma
;
56 Ada_Version_Explicit_Config
:= Ada_Version_Explicit
;
57 Assertions_Enabled_Config
:= Assertions_Enabled
;
58 Assume_No_Invalid_Values_Config
:= Assume_No_Invalid_Values
;
59 Check_Float_Overflow_Config
:= Check_Float_Overflow
;
60 Check_Policy_List_Config
:= Check_Policy_List
;
61 Default_Pool_Config
:= Default_Pool
;
62 Default_SSO_Config
:= Default_SSO
;
63 Dynamic_Elaboration_Checks_Config
:= Dynamic_Elaboration_Checks
;
64 Exception_Locations_Suppressed_Config
:= Exception_Locations_Suppressed
;
65 External_Name_Exp_Casing_Config
:= External_Name_Exp_Casing
;
66 External_Name_Imp_Casing_Config
:= External_Name_Imp_Casing
;
67 Fast_Math_Config
:= Fast_Math
;
68 Initialize_Scalars_Config
:= Initialize_Scalars
;
69 No_Component_Reordering_Config
:= No_Component_Reordering
;
70 Optimize_Alignment_Config
:= Optimize_Alignment
;
71 Persistent_BSS_Mode_Config
:= Persistent_BSS_Mode
;
72 Prefix_Exception_Messages_Config
:= Prefix_Exception_Messages
;
73 SPARK_Mode_Config
:= SPARK_Mode
;
74 SPARK_Mode_Pragma_Config
:= SPARK_Mode_Pragma
;
75 Uneval_Old_Config
:= Uneval_Old
;
76 Use_VADS_Size_Config
:= Use_VADS_Size
;
77 Warnings_As_Errors_Count_Config
:= Warnings_As_Errors_Count
;
79 -- Reset the indication that Optimize_Alignment was set locally, since
80 -- if we had a pragma in the config file, it would set this flag True,
81 -- but that's not a local setting.
83 Optimize_Alignment_Local
:= False;
84 end Register_Config_Switches
;
86 -----------------------------
87 -- Restore_Config_Switches --
88 -----------------------------
90 procedure Restore_Config_Switches
(Save
: Config_Switches_Type
) is
92 Ada_Version
:= Save
.Ada_Version
;
93 Ada_Version_Pragma
:= Save
.Ada_Version_Pragma
;
94 Ada_Version_Explicit
:= Save
.Ada_Version_Explicit
;
95 Assertions_Enabled
:= Save
.Assertions_Enabled
;
96 Assume_No_Invalid_Values
:= Save
.Assume_No_Invalid_Values
;
97 Check_Float_Overflow
:= Save
.Check_Float_Overflow
;
98 Check_Policy_List
:= Save
.Check_Policy_List
;
99 Default_Pool
:= Save
.Default_Pool
;
100 Default_SSO
:= Save
.Default_SSO
;
101 Dynamic_Elaboration_Checks
:= Save
.Dynamic_Elaboration_Checks
;
102 Exception_Locations_Suppressed
:= Save
.Exception_Locations_Suppressed
;
103 External_Name_Exp_Casing
:= Save
.External_Name_Exp_Casing
;
104 External_Name_Imp_Casing
:= Save
.External_Name_Imp_Casing
;
105 Fast_Math
:= Save
.Fast_Math
;
106 Initialize_Scalars
:= Save
.Initialize_Scalars
;
107 No_Component_Reordering
:= Save
.No_Component_Reordering
;
108 Optimize_Alignment
:= Save
.Optimize_Alignment
;
109 Optimize_Alignment_Local
:= Save
.Optimize_Alignment_Local
;
110 Persistent_BSS_Mode
:= Save
.Persistent_BSS_Mode
;
111 Prefix_Exception_Messages
:= Save
.Prefix_Exception_Messages
;
112 SPARK_Mode
:= Save
.SPARK_Mode
;
113 SPARK_Mode_Pragma
:= Save
.SPARK_Mode_Pragma
;
114 Uneval_Old
:= Save
.Uneval_Old
;
115 Use_VADS_Size
:= Save
.Use_VADS_Size
;
116 Warnings_As_Errors_Count
:= Save
.Warnings_As_Errors_Count
;
118 -- Update consistently the value of Init_Or_Norm_Scalars. The value of
119 -- Normalize_Scalars is not saved/restored because after set to True its
120 -- value is never changed. That is, if a compilation unit has pragma
121 -- Normalize_Scalars then it forces that value for all with'ed units.
123 Init_Or_Norm_Scalars
:= Initialize_Scalars
or Normalize_Scalars
;
124 end Restore_Config_Switches
;
126 --------------------------
127 -- Save_Config_Switches --
128 --------------------------
130 function Save_Config_Switches
return Config_Switches_Type
is
133 (Ada_Version
=> Ada_Version
,
134 Ada_Version_Pragma
=> Ada_Version_Pragma
,
135 Ada_Version_Explicit
=> Ada_Version_Explicit
,
136 Assertions_Enabled
=> Assertions_Enabled
,
137 Assume_No_Invalid_Values
=> Assume_No_Invalid_Values
,
138 Check_Float_Overflow
=> Check_Float_Overflow
,
139 Check_Policy_List
=> Check_Policy_List
,
140 Default_Pool
=> Default_Pool
,
141 Default_SSO
=> Default_SSO
,
142 Dynamic_Elaboration_Checks
=> Dynamic_Elaboration_Checks
,
143 Exception_Locations_Suppressed
=> Exception_Locations_Suppressed
,
144 External_Name_Exp_Casing
=> External_Name_Exp_Casing
,
145 External_Name_Imp_Casing
=> External_Name_Imp_Casing
,
146 Fast_Math
=> Fast_Math
,
147 Initialize_Scalars
=> Initialize_Scalars
,
148 No_Component_Reordering
=> No_Component_Reordering
,
149 Normalize_Scalars
=> Normalize_Scalars
,
150 Optimize_Alignment
=> Optimize_Alignment
,
151 Optimize_Alignment_Local
=> Optimize_Alignment_Local
,
152 Persistent_BSS_Mode
=> Persistent_BSS_Mode
,
153 Prefix_Exception_Messages
=> Prefix_Exception_Messages
,
154 SPARK_Mode
=> SPARK_Mode
,
155 SPARK_Mode_Pragma
=> SPARK_Mode_Pragma
,
156 Uneval_Old
=> Uneval_Old
,
157 Use_VADS_Size
=> Use_VADS_Size
,
158 Warnings_As_Errors_Count
=> Warnings_As_Errors_Count
);
159 end Save_Config_Switches
;
161 -------------------------
162 -- Set_Config_Switches --
163 -------------------------
165 procedure Set_Config_Switches
166 (Internal_Unit
: Boolean;
170 -- Case of internal unit
172 if Internal_Unit
then
174 -- Set standard switches. Note we do NOT set Ada_Version_Explicit
175 -- since the whole point of this is that it still properly indicates
176 -- the configuration setting even in a run time unit.
178 Ada_Version
:= Ada_Version_Runtime
;
179 Ada_Version_Pragma
:= Empty
;
181 Dynamic_Elaboration_Checks
:= False;
182 External_Name_Exp_Casing
:= As_Is
;
183 External_Name_Imp_Casing
:= Lowercase
;
184 No_Component_Reordering
:= False;
185 Optimize_Alignment
:= 'O';
186 Optimize_Alignment_Local
:= True;
187 Persistent_BSS_Mode
:= False;
188 Prefix_Exception_Messages
:= True;
190 Use_VADS_Size
:= False;
191 Identifier_Char
('[') := False;
193 -- Note: we do not need to worry about Warnings_As_Errors_Count since
194 -- we do not expect to get any warnings from compiling such a unit.
196 -- For an internal unit, assertions/debug pragmas are off unless this
197 -- is the main unit and they were explicitly enabled, or unless the
198 -- main unit was compiled in GNAT mode. We also make sure we do not
199 -- assume that values are necessarily valid and that SPARK_Mode is
200 -- set to its configuration value.
203 Assertions_Enabled
:= Assertions_Enabled_Config
;
204 Assume_No_Invalid_Values
:= Assume_No_Invalid_Values_Config
;
205 Check_Policy_List
:= Check_Policy_List_Config
;
206 SPARK_Mode
:= SPARK_Mode_Config
;
207 SPARK_Mode_Pragma
:= SPARK_Mode_Pragma_Config
;
210 -- In GNATprove mode assertions should be always enabled, even
211 -- when analysing internal units.
213 if GNATprove_Mode
then
214 pragma Assert
(Assertions_Enabled
);
217 elsif GNAT_Mode_Config
then
218 Assertions_Enabled
:= Assertions_Enabled_Config
;
220 Assertions_Enabled
:= False;
223 Assume_No_Invalid_Values
:= False;
224 Check_Policy_List
:= Empty
;
226 SPARK_Mode_Pragma
:= Empty
;
229 -- Case of non-internal unit
232 Ada_Version
:= Ada_Version_Config
;
233 Ada_Version_Pragma
:= Ada_Version_Pragma_Config
;
234 Ada_Version_Explicit
:= Ada_Version_Explicit_Config
;
235 Assertions_Enabled
:= Assertions_Enabled_Config
;
236 Assume_No_Invalid_Values
:= Assume_No_Invalid_Values_Config
;
237 Check_Float_Overflow
:= Check_Float_Overflow_Config
;
238 Check_Policy_List
:= Check_Policy_List_Config
;
239 Default_SSO
:= Default_SSO_Config
;
240 Dynamic_Elaboration_Checks
:= Dynamic_Elaboration_Checks_Config
;
241 External_Name_Exp_Casing
:= External_Name_Exp_Casing_Config
;
242 External_Name_Imp_Casing
:= External_Name_Imp_Casing_Config
;
243 Fast_Math
:= Fast_Math_Config
;
244 Initialize_Scalars
:= Initialize_Scalars_Config
;
245 No_Component_Reordering
:= No_Component_Reordering_Config
;
246 Optimize_Alignment
:= Optimize_Alignment_Config
;
247 Optimize_Alignment_Local
:= False;
248 Persistent_BSS_Mode
:= Persistent_BSS_Mode_Config
;
249 Prefix_Exception_Messages
:= Prefix_Exception_Messages_Config
;
250 SPARK_Mode
:= SPARK_Mode_Config
;
251 SPARK_Mode_Pragma
:= SPARK_Mode_Pragma_Config
;
252 Uneval_Old
:= Uneval_Old_Config
;
253 Use_VADS_Size
:= Use_VADS_Size_Config
;
254 Warnings_As_Errors_Count
:= Warnings_As_Errors_Count_Config
;
256 -- Update consistently the value of Init_Or_Norm_Scalars. The value
257 -- of Normalize_Scalars is not saved/restored because once set to
258 -- True its value is never changed. That is, if a compilation unit
259 -- has pragma Normalize_Scalars then it forces that value for all
262 Init_Or_Norm_Scalars
:= Initialize_Scalars
or Normalize_Scalars
;
265 -- Values set for all units
267 Default_Pool
:= Default_Pool_Config
;
268 Exception_Locations_Suppressed
:= Exception_Locations_Suppressed_Config
;
269 Fast_Math
:= Fast_Math_Config
;
270 end Set_Config_Switches
;