| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- W A R N S W -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1999-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 |
-- This unit contains the routines used to handle setting of warning options |
| 27 |
-- in the GNAT compiler. |
| 28 |
|
| 29 |
package Warnsw is |
| 30 |
|
| 31 |
------------------- |
| 32 |
-- Warning Flags -- |
| 33 |
------------------- |
| 34 |
|
| 35 |
-- These flags are activated or deactivated by -gnatw switches and control |
| 36 |
-- whether warnings of a given class will be generated or not. |
| 37 |
|
| 38 |
package Warnings_Package is |
| 39 |
type Opt_Warnings_Enum is |
| 40 |
-- List of all warnings that can be enabled, plus the two null-ish |
| 41 |
-- values. |
| 42 |
(No_Such_Warning, Special_Case, -- see body |
| 43 |
|
| 44 |
Address_Clause_Overlay_Warnings, |
| 45 |
Check_Unreferenced, |
| 46 |
Check_Unreferenced_Formals, |
| 47 |
Check_Withs, |
| 48 |
Constant_Condition_Warnings, |
| 49 |
Elab_Info_Messages, |
| 50 |
Elab_Warnings, |
| 51 |
Implementation_Unit_Warnings, |
| 52 |
Ineffective_Inline_Warnings, |
| 53 |
List_Body_Required_Info, |
| 54 |
List_Inherited_Aspects, |
| 55 |
Warning_Doc_Switch, |
| 56 |
Warn_On_Ada_2005_Compatibility, |
| 57 |
Warn_On_Ada_2012_Compatibility, |
| 58 |
Warn_On_Ada_2022_Compatibility, |
| 59 |
Warn_On_All_Unread_Out_Parameters, |
| 60 |
Warn_On_Anonymous_Allocators, |
| 61 |
Warn_On_Assertion_Failure, |
| 62 |
Warn_On_Assumed_Low_Bound, |
| 63 |
Warn_On_Atomic_Synchronization, |
| 64 |
Warn_On_Bad_Fixed_Value, |
| 65 |
Warn_On_Biased_Representation, |
| 66 |
Warn_On_Component_Order, |
| 67 |
Warn_On_Constant, |
| 68 |
Warn_On_Deleted_Code, |
| 69 |
Warn_On_Dereference, |
| 70 |
Warn_On_Elab_Access, |
| 71 |
Warn_On_Export_Import, |
| 72 |
Warn_On_GNAT_Extension_Compatibility, |
| 73 |
Warn_On_Hiding, |
| 74 |
Warn_On_Ignored_Equality, |
| 75 |
Warn_On_Ineffective_Predicate_Test, |
| 76 |
Warn_On_Inherently_Limited_Type, |
| 77 |
Warn_On_Late_Primitives, |
| 78 |
Warn_On_Modified_Unread, |
| 79 |
Warn_On_No_Value_Assigned, |
| 80 |
Warn_On_Non_Dispatching_Primitives, |
| 81 |
Warn_On_Non_Local_Exception, |
| 82 |
No_Warn_On_Non_Local_Exception, |
| 83 |
Warn_On_Object_Renames_Function, |
| 84 |
Warn_On_Obsolescent_Feature, |
| 85 |
Warn_On_Overlap, |
| 86 |
Warn_On_Overridden_Size, |
| 87 |
Warn_On_Parameter_Order, |
| 88 |
Warn_On_Pedantic_Checks, |
| 89 |
Warn_On_Questionable_Layout, |
| 90 |
Warn_On_Questionable_Missing_Parens, |
| 91 |
Warn_On_Record_Holes, |
| 92 |
Warn_On_Redundant_Constructs, |
| 93 |
Warn_On_Reverse_Bit_Order, |
| 94 |
Warn_On_Size_Alignment, |
| 95 |
Warn_On_Standard_Redefinition, |
| 96 |
Warn_On_Suspicious_Contract, |
| 97 |
Warn_On_Suspicious_Modulus_Value, |
| 98 |
Warn_On_Unchecked_Conversion, |
| 99 |
Warn_On_Unknown_Compile_Time_Warning, |
| 100 |
Warn_On_Unordered_Enumeration_Type, |
| 101 |
Warn_On_Unrecognized_Pragma, |
| 102 |
Warn_On_Unrepped_Components, |
| 103 |
Warn_On_Warnings_Off); -- Opt_Warnings_Enum |
| 104 |
|
| 105 |
subtype Warnings_Enum is Opt_Warnings_Enum |
| 106 |
range Opt_Warnings_Enum'Succ (Special_Case) .. Opt_Warnings_Enum'Last; |
| 107 |
-- Just the warning switches, without the null-ish values |
| 108 |
end Warnings_Package; |
| 109 |
use Warnings_Package; |
| 110 |
|
| 111 |
type Warnings_State is array (Warnings_Enum) of Boolean; |
| 112 |
pragma Pack (Warnings_State); |
| 113 |
-- Without Pack, we can have bootstrapping failures, because the compiler |
| 114 |
-- generates calls to System.Boolean_Array_Operations, which is not |
| 115 |
-- currently part of the compiler. |
| 116 |
|
| 117 |
Warning_Flags : Warnings_State := |
| 118 |
-- Current state of warnings -- True/False means enabled/disabled. |
| 119 |
-- The following initializes the flags to their default values, |
| 120 |
-- and warning switches modify them. |
| 121 |
(Address_Clause_Overlay_Warnings | |
| 122 |
Elab_Warnings | |
| 123 |
Implementation_Unit_Warnings | |
| 124 |
Warning_Doc_Switch | |
| 125 |
Warn_On_Ada_2005_Compatibility | |
| 126 |
Warn_On_Ada_2012_Compatibility | |
| 127 |
Warn_On_Ada_2022_Compatibility | |
| 128 |
Warn_On_Assertion_Failure | |
| 129 |
Warn_On_Assumed_Low_Bound | |
| 130 |
Warn_On_Biased_Representation | |
| 131 |
Warn_On_Export_Import | |
| 132 |
Warn_On_GNAT_Extension_Compatibility | |
| 133 |
Warn_On_No_Value_Assigned | |
| 134 |
Warn_On_Questionable_Missing_Parens | |
| 135 |
Warn_On_Reverse_Bit_Order | |
| 136 |
Warn_On_Size_Alignment | |
| 137 |
Warn_On_Suspicious_Contract | |
| 138 |
Warn_On_Suspicious_Modulus_Value | |
| 139 |
Warn_On_Unchecked_Conversion | |
| 140 |
Warn_On_Unknown_Compile_Time_Warning | |
| 141 |
Warn_On_Unrecognized_Pragma => |
| 142 |
True, |
| 143 |
|
| 144 |
Check_Unreferenced | |
| 145 |
Check_Unreferenced_Formals | |
| 146 |
Check_Withs | |
| 147 |
Constant_Condition_Warnings | |
| 148 |
Elab_Info_Messages | |
| 149 |
Ineffective_Inline_Warnings | |
| 150 |
List_Body_Required_Info | |
| 151 |
List_Inherited_Aspects | |
| 152 |
Warn_On_All_Unread_Out_Parameters | |
| 153 |
Warn_On_Anonymous_Allocators | |
| 154 |
Warn_On_Atomic_Synchronization | |
| 155 |
Warn_On_Bad_Fixed_Value | |
| 156 |
Warn_On_Component_Order | |
| 157 |
Warn_On_Constant | |
| 158 |
Warn_On_Deleted_Code | |
| 159 |
Warn_On_Dereference | |
| 160 |
Warn_On_Elab_Access | |
| 161 |
Warn_On_Hiding | |
| 162 |
Warn_On_Ignored_Equality | |
| 163 |
Warn_On_Ineffective_Predicate_Test | |
| 164 |
Warn_On_Inherently_Limited_Type | |
| 165 |
Warn_On_Late_Primitives | |
| 166 |
Warn_On_Modified_Unread | |
| 167 |
Warn_On_Non_Dispatching_Primitives | |
| 168 |
Warn_On_Non_Local_Exception | |
| 169 |
No_Warn_On_Non_Local_Exception | |
| 170 |
Warn_On_Object_Renames_Function | |
| 171 |
Warn_On_Obsolescent_Feature | |
| 172 |
Warn_On_Overlap | |
| 173 |
Warn_On_Overridden_Size | |
| 174 |
Warn_On_Parameter_Order | |
| 175 |
Warn_On_Pedantic_Checks | |
| 176 |
Warn_On_Questionable_Layout | |
| 177 |
Warn_On_Record_Holes | |
| 178 |
Warn_On_Redundant_Constructs | |
| 179 |
Warn_On_Standard_Redefinition | |
| 180 |
Warn_On_Unordered_Enumeration_Type | |
| 181 |
Warn_On_Unrepped_Components | |
| 182 |
Warn_On_Warnings_Off => |
| 183 |
False); |
| 184 |
|
| 185 |
package X renames Warnings_Package; |
| 186 |
F : Warnings_State renames Warning_Flags; |
| 187 |
-- Short-hand names used only locally to this package |
| 188 |
|
| 189 |
-- The following rename all the components of Warning_Flags for convenient |
| 190 |
-- access throughout the compiler. |
| 191 |
|
| 192 |
pragma Style_Checks ("M120"); |
| 193 |
Address_Clause_Overlay_Warnings : Boolean renames F (X.Address_Clause_Overlay_Warnings); |
| 194 |
-- Set False to disable address clause warnings. Modified by use of |
| 195 |
-- -gnatwo/O. |
| 196 |
|
| 197 |
Check_Unreferenced : Boolean renames F (X.Check_Unreferenced); |
| 198 |
-- Set to True to enable checking for unreferenced entities other |
| 199 |
-- than formal parameters (for which see Check_Unreferenced_Formals) |
| 200 |
-- Modified by use of -gnatwu/U. |
| 201 |
|
| 202 |
Check_Unreferenced_Formals : Boolean renames F (X.Check_Unreferenced_Formals); |
| 203 |
-- Set to True to check for unreferenced formals. This is turned on by |
| 204 |
-- -gnatwa/wf/wu and turned off by -gnatwA/wF/wU. |
| 205 |
|
| 206 |
Check_Withs : Boolean renames F (X.Check_Withs); |
| 207 |
-- Set to True to enable checking for unused withs, and also the case |
| 208 |
-- of withing a package and using none of the entities in the package. |
| 209 |
-- Modified by use of -gnatwu/U. |
| 210 |
|
| 211 |
Constant_Condition_Warnings : Boolean renames F (X.Constant_Condition_Warnings); |
| 212 |
-- Set to True to activate warnings on constant conditions. Modified by |
| 213 |
-- use of -gnatwc/C. |
| 214 |
|
| 215 |
Elab_Info_Messages : Boolean renames F (X.Elab_Info_Messages); |
| 216 |
-- Set to True to output info messages for static elabmodel (-gnatel) |
| 217 |
|
| 218 |
Elab_Warnings : Boolean renames F (X.Elab_Warnings); |
| 219 |
-- Set to True to generate elaboration warnings (-gnatwl). The warnings are |
| 220 |
-- enabled by default because they carry the same importance as errors. The |
| 221 |
-- compiler cannot emit actual errors because elaboration diagnostics need |
| 222 |
-- dataflow analysis, which is not available. This behavior parallels that |
| 223 |
-- of the old ABE mechanism. |
| 224 |
|
| 225 |
Implementation_Unit_Warnings : Boolean renames F (X.Implementation_Unit_Warnings); |
| 226 |
-- Set True to activate warnings for use of implementation internal units. |
| 227 |
-- Modified by use of -gnatwi/-gnatwI. |
| 228 |
|
| 229 |
Ineffective_Inline_Warnings : Boolean renames F (X.Ineffective_Inline_Warnings); |
| 230 |
-- Set True to activate warnings if front-end inlining (-gnatN) is not able |
| 231 |
-- to actually inline a particular call (or all calls). Can be controlled |
| 232 |
-- by use of -gnatwp/-gnatwP. Also set True to activate warnings if |
| 233 |
-- frontend inlining is not able to inline a subprogram expected to |
| 234 |
-- be inlined in GNATprove mode. |
| 235 |
|
| 236 |
List_Body_Required_Info : Boolean renames F (X.List_Body_Required_Info); |
| 237 |
-- List info messages about why a package requires a body. Modified by use |
| 238 |
-- of -gnatw.y/.Y. |
| 239 |
|
| 240 |
List_Inherited_Aspects : Boolean renames F (X.List_Inherited_Aspects); |
| 241 |
-- List inherited invariants, preconditions, and postconditions from |
| 242 |
-- Invariant'Class, Pre'Class, and Post'Class aspects. Also list inherited |
| 243 |
-- subtype predicates. Modified by use of -gnatw.l/.L. |
| 244 |
|
| 245 |
Warning_Doc_Switch : Boolean renames F (X.Warning_Doc_Switch); |
| 246 |
-- If this is set True, then the ??/?*?/?$?/?x?/?.x?/?_x? insertion |
| 247 |
-- sequences in error messages generate appropriate tags for the output |
| 248 |
-- error messages. If this switch is False, then these sequences are still |
| 249 |
-- recognized (for the purposes of implementing the pattern matching in |
| 250 |
-- pragmas Warnings (Off,..) and Warning_As_Error(...) but do not result |
| 251 |
-- in adding the error message tag. The -gnatw.d switch sets this flag |
| 252 |
-- True, -gnatw.D sets this flag False. |
| 253 |
|
| 254 |
Warn_On_Ada_2005_Compatibility : Boolean renames F (X.Warn_On_Ada_2005_Compatibility); |
| 255 |
-- Set to True to generate all warnings on Ada 2005 compatibility issues, |
| 256 |
-- including warnings on Ada 2005 obsolescent features used in Ada 2005 |
| 257 |
-- mode. Set by default, modified by use of -gnatwy/Y. |
| 258 |
|
| 259 |
Warn_On_Ada_2012_Compatibility : Boolean renames F (X.Warn_On_Ada_2012_Compatibility); |
| 260 |
-- Set to True to generate all warnings on Ada 2012 compatibility issues, |
| 261 |
-- including warnings on Ada 2012 obsolescent features used in Ada 2012 |
| 262 |
-- mode. Modified by use of -gnatwy/Y. |
| 263 |
|
| 264 |
Warn_On_Ada_2022_Compatibility : Boolean renames F (X.Warn_On_Ada_2022_Compatibility); |
| 265 |
-- Set to True to generate all warnings on Ada 2022 compatibility issues, |
| 266 |
-- including warnings on Ada 2022 obsolescent features used in Ada 2022 |
| 267 |
-- mode. There is no switch controlling this option. |
| 268 |
|
| 269 |
Warn_On_All_Unread_Out_Parameters : Boolean renames F (X.Warn_On_All_Unread_Out_Parameters); |
| 270 |
-- Set to True to generate warnings in all cases where a variable is |
| 271 |
-- modified by being passed as to an OUT formal, but the resulting value is |
| 272 |
-- never read. The default is that this warning is suppressed. Modified |
| 273 |
-- by use of gnatw.o/.O. |
| 274 |
|
| 275 |
Warn_On_Anonymous_Allocators : Boolean renames F (X.Warn_On_Anonymous_Allocators); |
| 276 |
-- Warn when allocators for anonymous access types are present, which, |
| 277 |
-- although not illegal in Ada, may be confusing to users due to how |
| 278 |
-- accessibility checks get generated. Off by default, modified by use |
| 279 |
-- of -gnatw_a/_A and set as part of -gnatwa. |
| 280 |
|
| 281 |
Warn_On_Assertion_Failure : Boolean renames F (X.Warn_On_Assertion_Failure); |
| 282 |
-- Set to True to activate warnings on assertions that can be determined |
| 283 |
-- at compile time will always fail. Modified by use of -gnatw.a/.A. |
| 284 |
|
| 285 |
Warn_On_Assumed_Low_Bound : Boolean renames F (X.Warn_On_Assumed_Low_Bound); |
| 286 |
-- Set to True to activate warnings for string parameters that are indexed |
| 287 |
-- with literals or S'Length, presumably assuming a lower bound of one. |
| 288 |
-- Modified by use of -gnatww/W. |
| 289 |
|
| 290 |
Warn_On_Atomic_Synchronization : Boolean renames F (X.Warn_On_Atomic_Synchronization); |
| 291 |
-- Set to True to generate information messages for atomic synchronization. |
| 292 |
-- Modified by use of -gnatw.n/.N. |
| 293 |
|
| 294 |
Warn_On_Bad_Fixed_Value : Boolean renames F (X.Warn_On_Bad_Fixed_Value); |
| 295 |
-- Set to True to generate warnings for static fixed-point expression |
| 296 |
-- values that are not an exact multiple of the small value of the type. |
| 297 |
-- Odd by default, modified by use of -gnatwb/B. |
| 298 |
|
| 299 |
Warn_On_Biased_Representation : Boolean renames F (X.Warn_On_Biased_Representation); |
| 300 |
-- Set to True to generate warnings for size clauses, component clauses |
| 301 |
-- and component_size clauses that force biased representation. Modified |
| 302 |
-- by use of -gnatw.b/.B. |
| 303 |
|
| 304 |
Warn_On_Component_Order : Boolean renames F (X.Warn_On_Component_Order); |
| 305 |
-- Warn when record component clauses are out of order with respect to the |
| 306 |
-- component declarations, or if the memory layout is out of order with |
| 307 |
-- respect to component declarations and clauses. Off by default, set by |
| 308 |
-- -gnatw_r (but not -gnatwa). |
| 309 |
|
| 310 |
Warn_On_Constant : Boolean renames F (X.Warn_On_Constant); |
| 311 |
-- Set to True to generate warnings for variables that could be declared |
| 312 |
-- as constants. Modified by use of -gnatwk/K. |
| 313 |
|
| 314 |
Warn_On_Deleted_Code : Boolean renames F (X.Warn_On_Deleted_Code); |
| 315 |
-- Set to True to generate warnings for code deleted by the front end |
| 316 |
-- for conditional statements whose outcome is known at compile time. |
| 317 |
-- Modified by use of -gnatwt/T. |
| 318 |
|
| 319 |
Warn_On_Dereference : Boolean renames F (X.Warn_On_Dereference); |
| 320 |
-- Set to True to generate warnings for implicit dereferences for array |
| 321 |
-- indexing and record component access. Modified by use of -gnatwd/D. |
| 322 |
|
| 323 |
Warn_On_Elab_Access : Boolean renames F (X.Warn_On_Elab_Access); |
| 324 |
-- Set to True to generate warnings for P'Access in the case where |
| 325 |
-- subprogram P is in the same package as the P'Access, and the P'Access is |
| 326 |
-- evaluated at package elaboration time, and occurs before the body of P |
| 327 |
-- has been elaborated. Modified by use of -gnatw.f/.F. |
| 328 |
|
| 329 |
Warn_On_Export_Import : Boolean renames F (X.Warn_On_Export_Import); |
| 330 |
-- Set to True to generate warnings for suspicious use of export or |
| 331 |
-- import pragmas. Modified by use of -gnatwx/X. |
| 332 |
|
| 333 |
Warn_On_GNAT_Extension_Compatibility : Boolean renames F (X.Warn_On_GNAT_Extension_Compatibility); |
| 334 |
-- Set to True to generate all warnings on GNAT extension compatibility |
| 335 |
-- issues. There is no switch controlling this option. |
| 336 |
|
| 337 |
Warn_On_Hiding : Boolean renames F (X.Warn_On_Hiding); |
| 338 |
-- Set to True to generate warnings if a declared entity hides another |
| 339 |
-- entity. The default is that this warning is suppressed. Modified by |
| 340 |
-- use of -gnatwh/H. |
| 341 |
|
| 342 |
Warn_On_Ignored_Equality : Boolean renames F (X.Warn_On_Ignored_Equality); |
| 343 |
-- Warn when a user-defined "=" function does not compose (i.e. is ignored |
| 344 |
-- for a predefined "=" for a composite type containing a component of |
| 345 |
-- whose type has the user-defined "=" as primitive). Off by default, and |
| 346 |
-- set by -gnatw_q (but not -gnatwa). |
| 347 |
|
| 348 |
Warn_On_Ineffective_Predicate_Test : Boolean renames F (X.Warn_On_Ineffective_Predicate_Test); |
| 349 |
-- Set to True to generate warnings if a static predicate is testing for |
| 350 |
-- values that do not belong to the parent subtype. Modified by use of |
| 351 |
-- -gnatw_s/S. |
| 352 |
|
| 353 |
Warn_On_Inherently_Limited_Type : Boolean renames F (X.Warn_On_Inherently_Limited_Type); |
| 354 |
-- Set to True to generate warnings if a record type does not have a |
| 355 |
-- limited keyword, but is inherently limited. Modified by use of |
| 356 |
-- -gnatw_l/L. |
| 357 |
|
| 358 |
Warn_On_Late_Primitives : Boolean renames F (X.Warn_On_Late_Primitives); |
| 359 |
-- Warn when tagged type public primitives are defined after its private |
| 360 |
-- extensions. |
| 361 |
|
| 362 |
Warn_On_Modified_Unread : Boolean renames F (X.Warn_On_Modified_Unread); |
| 363 |
-- Set to True to generate warnings if a variable is assigned but is never |
| 364 |
-- read. Also controls warnings for similar cases involving out parameters, |
| 365 |
-- but only if there is only one out parameter for the procedure involved. |
| 366 |
-- The default is that this warning is suppressed, modified by use of |
| 367 |
-- -gnatwm/M. |
| 368 |
|
| 369 |
Warn_On_No_Value_Assigned : Boolean renames F (X.Warn_On_No_Value_Assigned); |
| 370 |
-- Set to True to generate warnings if no value is ever assigned to a |
| 371 |
-- variable that is at least partially uninitialized. Set to false to |
| 372 |
-- suppress such warnings. The default is that such warnings are enabled. |
| 373 |
-- Modified by use of -gnatwv/V. |
| 374 |
|
| 375 |
Warn_On_Non_Dispatching_Primitives : Boolean renames F (X.Warn_On_Non_Dispatching_Primitives); |
| 376 |
-- Set to True to generate warnings for non dispatching primitives of tagged |
| 377 |
-- types that have aspect/pragma First_Controlling_Parameter set to True. |
| 378 |
-- This is turned on by -gnatw_j and turned off by -gnatw_J |
| 379 |
|
| 380 |
Warn_On_Non_Local_Exception : Boolean renames F (X.Warn_On_Non_Local_Exception); |
| 381 |
-- Set to True to generate warnings for non-local exception raises and also |
| 382 |
-- handlers that can never handle a local raise. This warning is only ever |
| 383 |
-- generated if pragma Restrictions (No_Exception_Propagation) is set. The |
| 384 |
-- default is not to generate the warnings except that if the source has |
| 385 |
-- at least one exception handler, and this restriction is set, and the |
| 386 |
-- warning was not explicitly turned off, then it is turned on by default. |
| 387 |
-- Modified by use of -gnatw.x/.X. |
| 388 |
|
| 389 |
No_Warn_On_Non_Local_Exception : Boolean renames F (X.No_Warn_On_Non_Local_Exception); |
| 390 |
-- This is set to True if the above warning is explicitly suppressed. We |
| 391 |
-- use this to avoid turning it on by default when No_Exception_Propagation |
| 392 |
-- restriction is set and an exception handler is present. |
| 393 |
|
| 394 |
Warn_On_Object_Renames_Function : Boolean renames F (X.Warn_On_Object_Renames_Function); |
| 395 |
-- Set to True to generate warnings when a function result is renamed as |
| 396 |
-- an object. The default is that this warning is disabled. Modified by |
| 397 |
-- use of -gnatw.r/.R. |
| 398 |
|
| 399 |
Warn_On_Obsolescent_Feature : Boolean renames F (X.Warn_On_Obsolescent_Feature); |
| 400 |
-- Set to True to generate warnings on use of any feature in Annex or if a |
| 401 |
-- subprogram is called for which a pragma Obsolescent applies. Modified |
| 402 |
-- by use of -gnatwj/J. |
| 403 |
|
| 404 |
Warn_On_Overlap : Boolean renames F (X.Warn_On_Overlap); |
| 405 |
-- Set to True to generate warnings when a writable actual overlaps with |
| 406 |
-- another actual in a subprogram call. This applies only in modes before |
| 407 |
-- Ada 2012. Starting with Ada 2012, such overlaps are illegal. |
| 408 |
-- Modified by use of -gnatw.i/.I. |
| 409 |
|
| 410 |
Warn_On_Overridden_Size : Boolean renames F (X.Warn_On_Overridden_Size); |
| 411 |
-- Warn when explicit record component clause or array component_size |
| 412 |
-- clause specifies a size that overrides a size for the type which was |
| 413 |
-- set with an explicit size clause. Off by default, modified by use of |
| 414 |
-- -gnatw.s/.S (but not -gnatwa). |
| 415 |
|
| 416 |
Warn_On_Parameter_Order : Boolean renames F (X.Warn_On_Parameter_Order); |
| 417 |
-- Set to True to generate warnings for cases where the argument list for |
| 418 |
-- a call is a sequence of identifiers that match the formal identifiers, |
| 419 |
-- but are in the wrong order. |
| 420 |
|
| 421 |
Warn_On_Pedantic_Checks : Boolean renames F (X.Warn_On_Pedantic_Checks); |
| 422 |
-- Warn for violation of miscellaneous pedantic rules (such as when the |
| 423 |
-- subtype of a formal parameter given in a subprogram body's specification |
| 424 |
-- comes from a different subtype declaration that the subtype of the |
| 425 |
-- formal in the subprogram declaration). Off by default, and set by |
| 426 |
-- -gnatw_p (but not -gnatwa). |
| 427 |
|
| 428 |
Warn_On_Questionable_Layout : Boolean renames F (X.Warn_On_Questionable_Layout); |
| 429 |
-- Warn when default layout of a record type is questionable for run-time |
| 430 |
-- efficiency reasons and would be improved by reordering the components. |
| 431 |
-- Off by default, modified by use of -gnatw.q/.Q (but not -gnatwa). |
| 432 |
|
| 433 |
function Get_Warn_On_Questionable_Layout return Boolean is |
| 434 |
(Warn_On_Questionable_Layout); |
| 435 |
-- WARNING: There is a matching C declaration of this function in fe.h |
| 436 |
|
| 437 |
Warn_On_Questionable_Missing_Parens : Boolean renames F (X.Warn_On_Questionable_Missing_Parens); |
| 438 |
-- Set to True to generate warnings for cases where parentheses are missing |
| 439 |
-- and the usage is questionable, because the intent is unclear. On by |
| 440 |
-- default, modified by use of -gnatwq/Q. |
| 441 |
|
| 442 |
Warn_On_Record_Holes : Boolean renames F (X.Warn_On_Record_Holes); |
| 443 |
-- Warn when explicit record component clauses leave uncovered holes (gaps) |
| 444 |
-- in a record layout. Off by default, set by -gnatw.h (but not -gnatwa). |
| 445 |
|
| 446 |
Warn_On_Redundant_Constructs : Boolean renames F (X.Warn_On_Redundant_Constructs); |
| 447 |
-- Set to True to generate warnings for redundant constructs (e.g. useless |
| 448 |
-- assignments/conversions). The default is that this warning is disabled. |
| 449 |
-- Modified by use of -gnatwr/R. |
| 450 |
|
| 451 |
Warn_On_Reverse_Bit_Order : Boolean renames F (X.Warn_On_Reverse_Bit_Order); |
| 452 |
-- Set to True to generate warning (informational) messages for component |
| 453 |
-- clauses that are affected by non-standard bit-order. The default is |
| 454 |
-- that this warning is enabled. Modified by -gnatw.v/.V. |
| 455 |
|
| 456 |
Warn_On_Size_Alignment : Boolean renames F (X.Warn_On_Size_Alignment); |
| 457 |
-- Warn when explicit Size and Alignment clauses are given for a type, and |
| 458 |
-- the size is not a multiple of the alignment. Off by default, modified |
| 459 |
-- by use of -gnatw.z/.Z and set as part of -gnatwa. |
| 460 |
|
| 461 |
Warn_On_Standard_Redefinition : Boolean renames F (X.Warn_On_Standard_Redefinition); |
| 462 |
-- Warn when a program defines an identifier that matches a name in |
| 463 |
-- Standard. Off by default, modified by use of -gnatw.k/.K (but not |
| 464 |
-- by -gnatwa). |
| 465 |
|
| 466 |
Warn_On_Suspicious_Contract : Boolean renames F (X.Warn_On_Suspicious_Contract); |
| 467 |
-- Set to True to generate warnings for suspicious contracts expressed as |
| 468 |
-- pragmas or aspects precondition and postcondition, as well as other |
| 469 |
-- suspicious cases of expressions typically found in contracts like |
| 470 |
-- quantified expressions and uses of Update attribute. The default is that |
| 471 |
-- this warning is enabled. Modified by use of -gnatw.t/.T. |
| 472 |
|
| 473 |
Warn_On_Suspicious_Modulus_Value : Boolean renames F (X.Warn_On_Suspicious_Modulus_Value); |
| 474 |
-- Set to True to generate warnings for suspicious modulus values, as well |
| 475 |
-- as negative literals of a modular type. The default is that this warning |
| 476 |
-- is enabled. Modified by -gnatw.m/.M. |
| 477 |
|
| 478 |
Warn_On_Unchecked_Conversion : Boolean renames F (X.Warn_On_Unchecked_Conversion); |
| 479 |
-- Set to True to generate warnings for unchecked conversions that may have |
| 480 |
-- non-portable semantics (e.g. because sizes of types differ). Modified |
| 481 |
-- by use of -gnatwz/Z. |
| 482 |
|
| 483 |
Warn_On_Unknown_Compile_Time_Warning : Boolean renames F (X.Warn_On_Unknown_Compile_Time_Warning); |
| 484 |
-- Warn on a pragma Compile_Time_Warning whose condition has a value that |
| 485 |
-- is not known at compile time. On by default, modified by use |
| 486 |
-- of -gnatw_c/_C and set as part of -gnatwa. |
| 487 |
|
| 488 |
Warn_On_Unordered_Enumeration_Type : Boolean renames F (X.Warn_On_Unordered_Enumeration_Type); |
| 489 |
-- Set to True to generate warnings for inappropriate uses (comparisons |
| 490 |
-- and explicit ranges) on unordered enumeration types (which includes |
| 491 |
-- all enumeration types for which pragma Ordered is not given). The |
| 492 |
-- default is that this warning is disabled. Modified by -gnat.u/.U. |
| 493 |
|
| 494 |
Warn_On_Unrecognized_Pragma : Boolean renames F (X.Warn_On_Unrecognized_Pragma); |
| 495 |
-- Set to True to generate warnings for unrecognized pragmas. The default |
| 496 |
-- is that this warning is enabled. Modified by use of -gnatwg/G. |
| 497 |
|
| 498 |
Warn_On_Unrepped_Components : Boolean renames F (X.Warn_On_Unrepped_Components); |
| 499 |
-- Set to True to generate warnings for the case of components of record |
| 500 |
-- which have a record representation clause but this component does not |
| 501 |
-- have a component clause. Modified by use of -gnatw.c/.C. |
| 502 |
|
| 503 |
Warn_On_Warnings_Off : Boolean renames F (X.Warn_On_Warnings_Off); |
| 504 |
-- Set to True to generate warnings for use of Pragma Warnings (Off, ent), |
| 505 |
-- where either the pragma is never used, or it could be replaced by a |
| 506 |
-- pragma Unmodified or Unreferenced. Also generates warnings for pragma |
| 507 |
-- Warning (Off, string) which either has no matching pragma Warning On, |
| 508 |
-- or where no warning has been suppressed by the use of the pragma. |
| 509 |
-- Modified by use of -gnatw.w/.W. |
| 510 |
pragma Style_Checks ("M79"); |
| 511 |
|
| 512 |
----------------------------------- |
| 513 |
-- Saving and Restoring Warnings -- |
| 514 |
----------------------------------- |
| 515 |
|
| 516 |
function Save_Warnings return Warnings_State; |
| 517 |
-- Returns current settings of warnings |
| 518 |
|
| 519 |
procedure Restore_Warnings (W : Warnings_State); |
| 520 |
-- Restores current settings of warning flags from W |
| 521 |
|
| 522 |
----------------- |
| 523 |
-- Subprograms -- |
| 524 |
----------------- |
| 525 |
|
| 526 |
type Warning_Family is |
| 527 |
-- The "family" indicates the form of warning switch: |
| 528 |
(Plain, -- form "-gnatwx" |
| 529 |
'.', -- form "-gnatw.x" |
| 530 |
'_'); -- form "-gnatw_x" |
| 531 |
-- where "x" is a lowercase letter that enables a particular warning. |
| 532 |
-- Typically, uppercase of "x" disables the warning, but there are some |
| 533 |
-- switches that do not follow that pattern. |
| 534 |
|
| 535 |
function Set_Warning_Switch |
| 536 |
(Family : Warning_Family; C : Character) return Boolean; |
| 537 |
-- Set the warning switch or switches corresponding to the given family and |
| 538 |
-- character. Returns True for valid warning switch, False for invalid. |
| 539 |
-- Called for -gnatw... switches, and for pragma Warnings. |
| 540 |
|
| 541 |
procedure Set_GNAT_Mode_Warnings; |
| 542 |
-- Called for -gnatg and -gnatw.g to set GNAT mode warnings. This set of |
| 543 |
-- warnings is neither a subset nor a superset of -gnatwa. |
| 544 |
|
| 545 |
end Warnsw; |