diff mbox series

[COMMITTED] ada: Move warnings switches

Message ID 20221121101405.259209-1-poulhies@adacore.com
State New
Headers show
Series [COMMITTED] ada: Move warnings switches | expand

Commit Message

Marc Poulhiès Nov. 21, 2022, 10:14 a.m. UTC
From: Bob Duff <duff@adacore.com>

This patch moves warning switches from Opt into Warnsw, fixes some minor
discrepancies, and cleans up the code.

No change in behavior.

gcc/ada/

	* warnsw.ads, warnsw.adb: Move warning flags here from package
	Opt. Rename Warning_Record to be Warnings_State. Use an array
	instead of a record; this simplifies the code. Add renamings of
	all the array components for easy reference outside this package.
	Pass the "Family" to Set_Warning_Switch. Use more table-driven
	code. Misc cleanup and comment fixes.
	* opt.ads: Move warning switches to Warnsw.
	* gnat1drv.adb
	(Adjust_Global_Switches): Expanded names needed.
	* inline.ads: Rename Warning_Record to be Warnings_State.
	* sem_ch12.adb: Likewise.
	* sem_prag.adb: Use new Set_Warning_Switch.
	* contracts.adb, errout.adb, exp_aggr.adb, exp_ch11.adb: Adjust
	imports for move to Warnsw.
	* exp_ch5.adb, exp_prag.adb, exp_util.adb, frontend.adb: Likewise.
	* layout.adb, lib-xref.adb, restrict.adb, scn.adb, sem_aggr.adb:
	Likewise.
	* sem_attr.adb, sem_case.adb, sem_ch10.adb, sem_ch11.adb:
	Likewise.
	* sem_ch13.adb, sem_ch3.adb, sem_ch4.adb, sem_ch5.adb: Likewise.
	* sem_ch6.adb, sem_ch7.adb, sem_ch8.adb, sem_elab.adb: Likewise.
	* sem_eval.adb, sem_res.adb, sem_util.adb, sem_warn.adb: Likewise.
	* switch-c.adb: Likewise.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/contracts.adb |   1 +
 gcc/ada/errout.adb    |   9 +-
 gcc/ada/exp_aggr.adb  |   1 +
 gcc/ada/exp_ch11.adb  |   1 +
 gcc/ada/exp_ch5.adb   |   1 +
 gcc/ada/exp_prag.adb  |   1 +
 gcc/ada/exp_util.adb  |   3 +-
 gcc/ada/frontend.adb  |   1 +
 gcc/ada/gnat1drv.adb  |   7 +-
 gcc/ada/inline.ads    |   2 +-
 gcc/ada/layout.adb    |   1 +
 gcc/ada/lib-xref.adb  |   1 +
 gcc/ada/opt.ads       | 271 ------------
 gcc/ada/restrict.adb  |   1 +
 gcc/ada/scn.adb       |   2 +-
 gcc/ada/sem_aggr.adb  |   1 +
 gcc/ada/sem_attr.adb  |   1 +
 gcc/ada/sem_case.adb  |   1 +
 gcc/ada/sem_ch10.adb  |   1 +
 gcc/ada/sem_ch11.adb  |   1 +
 gcc/ada/sem_ch12.adb  |   8 +-
 gcc/ada/sem_ch13.adb  |   2 +-
 gcc/ada/sem_ch3.adb   |   1 +
 gcc/ada/sem_ch4.adb   |   1 +
 gcc/ada/sem_ch5.adb   |   1 +
 gcc/ada/sem_ch6.adb   |   2 +-
 gcc/ada/sem_ch7.adb   |   1 +
 gcc/ada/sem_ch8.adb   |   1 +
 gcc/ada/sem_elab.adb  |   1 +
 gcc/ada/sem_eval.adb  |   1 +
 gcc/ada/sem_prag.adb  |   4 +-
 gcc/ada/sem_res.adb   |   1 +
 gcc/ada/sem_util.adb  |   1 +
 gcc/ada/sem_warn.adb  |   3 +-
 gcc/ada/switch-c.adb  |   6 +-
 gcc/ada/warnsw.adb    | 944 +++++++++++-------------------------------
 gcc/ada/warnsw.ads    | 527 ++++++++++++++++++-----
 37 files changed, 700 insertions(+), 1113 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb
index 218fd66852f..fef3d24870f 100644
--- a/gcc/ada/contracts.adb
+++ b/gcc/ada/contracts.adb
@@ -59,6 +59,7 @@  with Snames;         use Snames;
 with Stand;          use Stand;
 with Stringt;        use Stringt;
 with Tbuild;         use Tbuild;
+with Warnsw;         use Warnsw;
 
 package body Contracts is
 
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index dcd21778db3..afa30674fa3 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -53,8 +53,7 @@  with Stand;          use Stand;
 with Stylesw;        use Stylesw;
 with System.OS_Lib;
 with Uname;          use Uname;
-with Warnsw; pragma Unreferenced (Warnsw);
---  Will be referenced when various flags are moved to Warnsw.
+with Warnsw; pragma Unreferenced (Warnsw); -- disable spurious warning
 
 package body Errout is
 
@@ -989,14 +988,14 @@  package body Errout is
          --  after fixing the error, the use clause no longer looks like it was
          --  unused.
 
-         Check_Unreferenced := False;
-         Check_Unreferenced_Formals := False;
+         Warnsw.Check_Unreferenced := False;
+         Warnsw.Check_Unreferenced_Formals := False;
       end Handle_Serious_Error;
 
    --  Start of processing for Error_Msg_Internal
 
    begin
-      --  Detect common mistake of prefixing or suffing the message with a
+      --  Detect common mistake of prefixing or suffixing the message with a
       --  space character.
 
       pragma Assert (Msg (Msg'First) /= ' ' and then Msg (Msg'Last) /= ' ');
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index dde49d1e289..3f51ed6b457 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -71,6 +71,7 @@  with Stringt;        use Stringt;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
 with Urealp;         use Urealp;
+with Warnsw;         use Warnsw;
 
 package body Exp_Aggr is
 
diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb
index 98ce886c71c..5b83035ebd8 100644
--- a/gcc/ada/exp_ch11.adb
+++ b/gcc/ada/exp_ch11.adb
@@ -53,6 +53,7 @@  with Stringt;        use Stringt;
 with Targparm;       use Targparm;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 package body Exp_Ch11 is
 
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 1dbbff9e0e4..3ea6cbbd3e8 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -65,6 +65,7 @@  with Tbuild;         use Tbuild;
 with Ttypes;         use Ttypes;
 with Uintp;          use Uintp;
 with Validsw;        use Validsw;
+with Warnsw;         use Warnsw;
 
 package body Exp_Ch5 is
 
diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
index 2def83cc20c..cce0aa58a21 100644
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -58,6 +58,7 @@  with Stand;          use Stand;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
 with Validsw;        use Validsw;
+with Warnsw;         use Warnsw;
 
 package body Exp_Prag is
 
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 35667028df1..bcfb39ce21d 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -67,6 +67,7 @@  with Stringt;        use Stringt;
 with Tbuild;         use Tbuild;
 with Ttypes;         use Ttypes;
 with Validsw;        use Validsw;
+with Warnsw;         use Warnsw;
 
 with GNAT.HTable;
 package body Exp_Util is
@@ -2966,7 +2967,7 @@  package body Exp_Util is
          --  Output an info message when inheriting an invariant and the
          --  listing option is enabled.
 
-         if Inherited and Opt.List_Inherited_Aspects then
+         if Inherited and List_Inherited_Aspects then
             Error_Msg_Sloc := Sloc (Prag);
             Error_Msg_N
               ("info: & inherits `Invariant''Class` aspect from #?.l?", Typ);
diff --git a/gcc/ada/frontend.adb b/gcc/ada/frontend.adb
index cdca67bf397..033ecf3b7be 100644
--- a/gcc/ada/frontend.adb
+++ b/gcc/ada/frontend.adb
@@ -69,6 +69,7 @@  with SCIL_LL;
 with Tbuild;         use Tbuild;
 with Types;          use Types;
 with VAST;
+with Warnsw;         use Warnsw;
 
 procedure Frontend is
 begin
diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb
index 3217546d4b9..0b29c6f04c3 100644
--- a/gcc/ada/gnat1drv.adb
+++ b/gcc/ada/gnat1drv.adb
@@ -562,9 +562,10 @@  procedure Gnat1drv is
          --    - suspicious contracts, which are useful for SPARK code
 
          Reset_Style_Check_Options;
-         Restore_Warnings (W => (Elab_Warnings               => True,
-                                 Warn_On_Suspicious_Contract => True,
-                                 others                      => False));
+         Restore_Warnings
+           ((Warnings_Package.Elab_Warnings => True,
+             Warnings_Package.Warn_On_Suspicious_Contract => True,
+             others => False));
 
          --  Suppress the generation of name tables for enumerations, which are
          --  not needed for formal verification, and fall outside the SPARK
diff --git a/gcc/ada/inline.ads b/gcc/ada/inline.ads
index 05aaac751e6..82d48077625 100644
--- a/gcc/ada/inline.ads
+++ b/gcc/ada/inline.ads
@@ -94,7 +94,7 @@  package Inline is
       --  This means we have to capture this information from the current scope
       --  at the point of instantiation.
 
-      Warnings : Warning_Record;
+      Warnings : Warnings_State;
       --  Capture values of warning flags
    end record;
 
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
index 4f764bf0e75..b352c0643f4 100644
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -40,6 +40,7 @@  with Sinfo.Utils;    use Sinfo.Utils;
 with Snames;         use Snames;
 with Ttypes;         use Ttypes;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 package body Layout is
 
diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb
index 5a1538e523c..e5dcc85523b 100644
--- a/gcc/ada/lib-xref.adb
+++ b/gcc/ada/lib-xref.adb
@@ -47,6 +47,7 @@  with Snames;         use Snames;
 with Stringt;        use Stringt;
 with Stand;          use Stand;
 with Table;          use Table;
+with Warnsw;         use Warnsw;
 
 with GNAT.Heap_Sort_G;
 with GNAT.HTable;
diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads
index 6f3ced295e5..2ae9dd99f56 100644
--- a/gcc/ada/opt.ads
+++ b/gcc/ada/opt.ads
@@ -141,11 +141,6 @@  package Opt is
    --  The name of the Ada package generated by the binder (when in Ada mode).
    --  This variable may be modified by Gnatbind.Scan_Bind_Arg.
 
-   Address_Clause_Overlay_Warnings : Boolean := True;
-   --  GNAT
-   --  Set False to disable address clause warnings. Modified by use of
-   --  -gnatwo/O.
-
    Address_Is_Private : Boolean := False;
    --  GNAT, GNATBIND
    --  Set True if package System has the line "type Address is private;"
@@ -317,28 +312,11 @@  package Opt is
    --  GNATMAKE, GPBUILD
    --  Set to True to check compiler options during the make process
 
-   Check_Unreferenced : Boolean := False;
-   --  GNAT
-   --  Set to True to enable checking for unreferenced entities other
-   --  than formal parameters (for which see Check_Unreferenced_Formals)
-   --  Modified by use of -gnatwu/U.
-
-   Check_Unreferenced_Formals : Boolean := False;
-   --  GNAT
-   --  Set to True to check for unreferenced formals. This is turned on by
-   --  -gnatwa/wf/wu and turned off by -gnatwA/wF/wU.
-
    Check_Validity_Of_Parameters : Boolean := False;
    --  GNAT
    --  Set to True to check for proper scalar initialization of subprogram
    --  parameters on both entry and exit. This is turned on by -gnateV.
 
-   Check_Withs : Boolean := False;
-   --  GNAT
-   --  Set to True to enable checking for unused withs, and also the case
-   --  of withing a package and using none of the entities in the package.
-   --  Modified by use of -gnatwu/U.
-
    CodePeer_Mode : Boolean := False;
    --  GNAT, GNATBIND, GPRBUILD
    --  Enable full CodePeer mode (SCIL generation, disable switches that
@@ -385,11 +363,6 @@  package Opt is
    --  True, or if pragma No_Run_Time is used. See the spec of Rtsfind for
    --  details on the handling of the latter pragma.
 
-   Constant_Condition_Warnings : Boolean := False;
-   --  GNAT
-   --  Set to True to activate warnings on constant conditions. Modified by
-   --  use of -gnatwc/C.
-
    Create_Mapping_File : Boolean := False;
    --  GNATMAKE
    --  Set to True (-C switch) to indicate that the compiler will be invoked
@@ -525,18 +498,6 @@  package Opt is
    --  GNATBIND
    --  Set to True to output chosen elaboration order
 
-   Elab_Info_Messages : Boolean := False;
-   --  GNAT
-   --  Set to True to output info messages for static elabmodel (-gnatel)
-
-   Elab_Warnings : Boolean := True;
-   --  GNAT
-   --  Set to True to generate elaboration warnings (-gnatwl). The warnings are
-   --  enabled by default because they carry the same importance as errors. The
-   --  compiler cannot emit actual errors because elaboration diagnostics need
-   --  dataflow analysis, which is not available. This behavior parallels that
-   --  of the old ABE mechanism.
-
    Enable_128bit_Types : Boolean := False;
    --  GNAT
    --  Set to True to enable the support for 128-bit types in the compiler.
@@ -854,11 +815,6 @@  package Opt is
    --  reflect the starting node of the outermost ignored Ghost region. If a
    --  nested ignored Ghost region is entered, the value must remain unchanged.
 
-   Implementation_Unit_Warnings : Boolean := True;
-   --  GNAT
-   --  Set True to active warnings for use of implementation internal units.
-   --  Modified by use of -gnatwi/-gnatwI.
-
    Implicit_Packing : Boolean := False;
    --  GNAT
    --  If set True, then a Size attribute clause on an array is allowed to
@@ -869,14 +825,6 @@  package Opt is
    --  GNAT
    --  Set True to include the enclosing subprogram in compiler messages.
 
-   Ineffective_Inline_Warnings : Boolean := False;
-   --  GNAT
-   --  Set True to activate warnings if front-end inlining (-gnatN) is not able
-   --  to actually inline a particular call (or all calls). Can be controlled
-   --  by use of -gnatwp/-gnatwP. Also set True to activate warnings if
-   --  frontend inlining is not able to inline a subprogram expected to
-   --  be inlined in GNATprove mode.
-
    Init_Or_Norm_Scalars : Boolean := False;
    --  GNAT, GNATBIND
    --  Set True if a pragma Initialize_Scalars applies to the current unit.
@@ -962,17 +910,6 @@  package Opt is
    --  Set to True to skip compile and bind steps (except when Bind_Only is
    --  set to True).
 
-   List_Body_Required_Info : Boolean := False;
-   --  GNATMAKE
-   --  List info messages about why a package requires a body. Modified by use
-   --  of -gnatw.y/.Y.
-
-   List_Inherited_Aspects : Boolean := False;
-   --  GNAT
-   --  List inherited invariants, preconditions, and postconditions from
-   --  Invariant'Class, Pre'Class, and Post'Class aspects. Also list inherited
-   --  subtype predicates. Modified by use of -gnatw.l/.L.
-
    List_Restrictions : Boolean := False;
    --  GNATBIND
    --  Set to True to list restrictions pragmas that could apply to partition
@@ -1719,214 +1656,6 @@  package Opt is
    --  In High Verbosity, additional lines are output when the ALI file
    --  is part of an Ada library, is read-only or is part of the runtime.
 
-   Warn_On_Ada_2005_Compatibility : Boolean := True;
-   --  GNAT
-   --  Set to True to generate all warnings on Ada 2005 compatibility issues,
-   --  including warnings on Ada 2005 obsolescent features used in Ada 2005
-   --  mode. Set by default, modified by use of -gnatwy/Y.
-
-   Warn_On_Ada_2012_Compatibility : Boolean := True;
-   --  GNAT
-   --  Set to True to generate all warnings on Ada 2012 compatibility issues,
-   --  including warnings on Ada 2012 obsolescent features used in Ada 2012
-   --  mode. Modified by use of -gnatwy/Y.
-
-   Warn_On_Ada_2022_Compatibility : Boolean := True;
-   --  GNAT
-   --  Set to True to generate all warnings on Ada 2022 compatibility issues,
-   --  including warnings on Ada 2022 obsolescent features used in Ada 2022
-   --  mode.
-
-   Warn_On_All_Unread_Out_Parameters : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings in all cases where a variable is
-   --  modified by being passed as to an OUT formal, but the resulting value is
-   --  never read. The default is that this warning is suppressed. Modified
-   --  by use of gnatw.o/.O.
-
-   Warn_On_Assertion_Failure : Boolean := True;
-   --  GNAT
-   --  Set to True to activate warnings on assertions that can be determined
-   --  at compile time will always fail. Modified by use of -gnatw.a/.A.
-
-   Warn_On_Assumed_Low_Bound : Boolean := True;
-   --  GNAT
-   --  Set to True to activate warnings for string parameters that are indexed
-   --  with literals or S'Length, presumably assuming a lower bound of one.
-   --  Modified by use of -gnatww/W.
-
-   Warn_On_Atomic_Synchronization : Boolean := False;
-   --  GNAT
-   --  Set to True to generate information messages for atomic synchronization.
-   --  Modified by use of -gnatw.n/.N.
-
-   Warn_On_Bad_Fixed_Value : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for static fixed-point expression
-   --  values that are not an exact multiple of the small value of the type.
-   --  Odd by default, modified by use of -gnatwb/B.
-
-   Warn_On_Biased_Representation : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warnings for size clauses, component clauses
-   --  and component_size clauses that force biased representation. Modified
-   --  by use of -gnatw.b/.B.
-
-   Warn_On_Constant : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for variables that could be declared
-   --  as constants. Modified by use of -gnatwk/K.
-
-   Warn_On_Deleted_Code : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for code deleted by the front end
-   --  for conditional statements whose outcome is known at compile time.
-   --  Modified by use of -gnatwt/T.
-
-   Warn_On_Dereference : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for implicit dereferences for array
-   --  indexing and record component access. Modified by use of -gnatwd/D.
-
-   Warn_On_Export_Import : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warnings for suspicious use of export or
-   --  import pragmas. Modified by use of -gnatwx/X.
-
-   Warn_On_Elab_Access : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for P'Access in the case where
-   --  subprogram P is in the same package as the P'Access, and the P'Access is
-   --  evaluated at package elaboration time, and occurs before the body of P
-   --  has been elaborated.
-
-   Warn_On_Hiding : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings if a declared entity hides another
-   --  entity. The default is that this warning is suppressed. Modified by
-   --  use of -gnatwh/H.
-
-   Warn_On_Modified_Unread : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings if a variable is assigned but is never
-   --  read. Also controls warnings for similar cases involving out parameters,
-   --  but only if there is only one out parameter for the procedure involved.
-   --  The default is that this warning is suppressed, modified by use of
-   --  -gnatwm/M.
-
-   Warn_On_No_Value_Assigned : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warnings if no value is ever assigned to a
-   --  variable that is at least partially uninitialized. Set to false to
-   --  suppress such warnings. The default is that such warnings are enabled.
-   --  Modified by use of -gnatwv/V.
-
-   Warn_On_Non_Local_Exception : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for non-local exception raises and also
-   --  handlers that can never handle a local raise. This warning is only ever
-   --  generated if pragma Restrictions (No_Exception_Propagation) is set. The
-   --  default is not to generate the warnings except that if the source has
-   --  at least one exception handler, and this restriction is set, and the
-   --  warning was not explicitly turned off, then it is turned on by default.
-   --  Modified by use of -gnatw.x/.X.
-
-   No_Warn_On_Non_Local_Exception : Boolean := False;
-   --  GNAT
-   --  This is set to True if the above warning is explicitly suppressed. We
-   --  use this to avoid turning it on by default when No_Exception_Propagation
-   --  restriction is set and an exception handler is present.
-
-   Warn_On_Object_Renames_Function : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings when a function result is renamed as
-   --  an object. The default is that this warning is disabled. Modified by
-   --  use of -gnatw.r/.R.
-
-   Warn_On_Obsolescent_Feature : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings on use of any feature in Annex or if a
-   --  subprogram is called for which a pragma Obsolescent applies. Modified
-   --  by use of -gnatwj/J.
-
-   Warn_On_Overlap : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings when a writable actual overlaps with
-   --  another actual in a subprogram call. This applies only in modes before
-   --  Ada 2012. Starting with Ada 2012, such overlaps are illegal.
-   --  Modified by use of -gnatw.i/.I.
-
-   Warn_On_Questionable_Missing_Parens : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warnings for cases where parentheses are missing
-   --  and the usage is questionable, because the intent is unclear. On by
-   --  default, modified by use of -gnatwq/Q.
-
-   Warn_On_Parameter_Order : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for cases where the argument list for
-   --  a call is a sequence of identifiers that match the formal identifiers,
-   --  but are in the wrong order.
-
-   Warn_On_Redundant_Constructs : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for redundant constructs (e.g. useless
-   --  assignments/conversions). The default is that this warning is disabled.
-   --  Modified by use of -gnatwr/R.
-
-   Warn_On_Reverse_Bit_Order : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warning (informational) messages for component
-   --  clauses that are affected by non-standard bit-order. The default is
-   --  that this warning is enabled. Modified by -gnatw.v/.V.
-
-   Warn_On_Suspicious_Contract : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warnings for suspicious contracts expressed as
-   --  pragmas or aspects precondition and postcondition, as well as other
-   --  suspicious cases of expressions typically found in contracts like
-   --  quantified expressions and uses of Update attribute. The default is that
-   --  this warning is enabled. Modified by use of -gnatw.t/.T.
-
-   Warn_On_Suspicious_Modulus_Value : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warnings for suspicious modulus values, as well
-   --  as negative literals of a modular type. The default is that this warning
-   --  is enabled. Modified by -gnatw.m/.M.
-
-   Warn_On_Unchecked_Conversion : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warnings for unchecked conversions that may have
-   --  non-portable semantics (e.g. because sizes of types differ). Modified
-   --  by use of -gnatwz/Z.
-
-   Warn_On_Unordered_Enumeration_Type : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for inappropriate uses (comparisons
-   --  and explicit ranges) on unordered enumeration types (which includes
-   --  all enumeration types for which pragma Ordered is not given). The
-   --  default is that this warning is disabled. Modified by -gnat.u/.U.
-
-   Warn_On_Unrecognized_Pragma : Boolean := True;
-   --  GNAT
-   --  Set to True to generate warnings for unrecognized pragmas. The default
-   --  is that this warning is enabled. Modified by use of -gnatwg/G.
-
-   Warn_On_Unrepped_Components : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for the case of components of record
-   --  which have a record representation clause but this component does not
-   --  have a component clause. Modified by use of -gnatw.c/.C.
-
-   Warn_On_Warnings_Off : Boolean := False;
-   --  GNAT
-   --  Set to True to generate warnings for use of Pragma Warnings (Off, ent),
-   --  where either the pragma is never used, or it could be replaced by a
-   --  pragma Unmodified or Unreferenced. Also generates warnings for pragma
-   --  Warning (Off, string) which either has no matching pragma Warning On,
-   --  or where no warning has been suppressed by the use of the pragma.
-   --  Modified by use of -gnatw.w/.W.
-
    type Warning_Mode_Type is
      (Suppress, Normal, Treat_As_Error, Treat_Run_Time_Warnings_As_Errors);
    Warning_Mode : Warning_Mode_Type := Normal;
diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb
index cf43ca91e7d..9ef923b186c 100644
--- a/gcc/ada/restrict.adb
+++ b/gcc/ada/restrict.adb
@@ -41,6 +41,7 @@  with Sinput;         use Sinput;
 with Stand;          use Stand;
 with Targparm;       use Targparm;
 with Uname;          use Uname;
+with Warnsw;         use Warnsw;
 
 package body Restrict is
 
diff --git a/gcc/ada/scn.adb b/gcc/ada/scn.adb
index f8f030163f3..35d6981ad5c 100644
--- a/gcc/ada/scn.adb
+++ b/gcc/ada/scn.adb
@@ -26,7 +26,6 @@ 
 with Atree;          use Atree;
 with Csets;          use Csets;
 with Namet;          use Namet;
-with Opt;            use Opt;
 with Restrict;       use Restrict;
 with Rident;         use Rident;
 with Scans;          use Scans;
@@ -34,6 +33,7 @@  with Sinfo;          use Sinfo;
 with Sinfo.Nodes;    use Sinfo.Nodes;
 with Sinput;         use Sinput;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 package body Scn is
 
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 3a093d26007..3e978f93c46 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -70,6 +70,7 @@  with Targparm;       use Targparm;
 with Tbuild;         use Tbuild;
 with Ttypes;         use Ttypes;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 package body Sem_Aggr is
 
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index f7c03abe49a..4c76b9344c2 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -84,6 +84,7 @@  with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
 with Uname;          use Uname;
 with Urealp;         use Urealp;
+with Warnsw;         use Warnsw;
 
 with System.CRC32;   use System.CRC32;
 
diff --git a/gcc/ada/sem_case.adb b/gcc/ada/sem_case.adb
index f89c3ca386f..9577921a9ab 100644
--- a/gcc/ada/sem_case.adb
+++ b/gcc/ada/sem_case.adb
@@ -48,6 +48,7 @@  with Stringt;        use Stringt;
 with Table;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 with Ada.Unchecked_Deallocation;
 
diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb
index 8c1c00cc8b9..a93808370c2 100644
--- a/gcc/ada/sem_ch10.adb
+++ b/gcc/ada/sem_ch10.adb
@@ -74,6 +74,7 @@  with Style;          use Style;
 with Stylesw;        use Stylesw;
 with Tbuild;         use Tbuild;
 with Uname;          use Uname;
+with Warnsw;         use Warnsw;
 
 package body Sem_Ch10 is
 
diff --git a/gcc/ada/sem_ch11.adb b/gcc/ada/sem_ch11.adb
index 339edd35d91..ea6f9c872af 100644
--- a/gcc/ada/sem_ch11.adb
+++ b/gcc/ada/sem_ch11.adb
@@ -50,6 +50,7 @@  with Sinfo;          use Sinfo;
 with Sinfo.Nodes;    use Sinfo.Nodes;
 with Sinfo.Utils;    use Sinfo.Utils;
 with Stand;          use Stand;
+with Warnsw;         use Warnsw;
 
 package body Sem_Ch11 is
 
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 72c2eef7061..1ea95845a16 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -11892,7 +11892,7 @@  package body Sem_Ch12 is
       Saved_SM   : constant SPARK_Mode_Type          := SPARK_Mode;
       Saved_SMP  : constant Node_Id                  := SPARK_Mode_Pragma;
       Saved_SS   : constant Suppress_Record          := Scope_Suppress;
-      Saved_Warn : constant Warning_Record           := Save_Warnings;
+      Saved_Warn : constant Warnings_State           := Save_Warnings;
 
       Act_Body      : Node_Id;
       Act_Body_Id   : Entity_Id;
@@ -12429,7 +12429,7 @@  package body Sem_Ch12 is
       Saved_SM   : constant SPARK_Mode_Type          := SPARK_Mode;
       Saved_SMP  : constant Node_Id                  := SPARK_Mode_Pragma;
       Saved_SS   : constant Suppress_Record          := Scope_Suppress;
-      Saved_Warn : constant Warning_Record           := Save_Warnings;
+      Saved_Warn : constant Warnings_State           := Save_Warnings;
 
       Act_Body      : Node_Id;
       Act_Body_Id   : Entity_Id;
@@ -14432,7 +14432,7 @@  package body Sem_Ch12 is
    is
       Comp_Unit          : constant Node_Id := Cunit (Get_Source_Unit (Spec));
       Saved_Style_Check  : constant Boolean := Style_Check;
-      Saved_Warnings     : constant Warning_Record := Save_Warnings;
+      Saved_Warn         : constant Warnings_State := Save_Warnings;
       True_Parent        : Node_Id;
       Inst_Node          : Node_Id;
       OK                 : Boolean;
@@ -14763,7 +14763,7 @@  package body Sem_Ch12 is
             Expander_Mode_Save_And_Set (True);
             Load_Needed_Body (Comp_Unit, OK);
             Opt.Style_Check := Saved_Style_Check;
-            Restore_Warnings (Saved_Warnings);
+            Restore_Warnings (Saved_Warn);
             Expander_Mode_Restore;
 
             if not OK
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index bf84a10ded6..a4782747aff 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -9943,7 +9943,7 @@  package body Sem_Ch13 is
             --  generally suppress the message in instantiations, and also
             --  if it involves internal names.
 
-            if Opt.List_Inherited_Aspects
+            if List_Inherited_Aspects
               and then not Is_Generic_Actual_Type (Typ)
               and then Instantiation_Location (Sloc (Typ)) = No_Location
               and then not Is_Internal_Name (Chars (T))
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index dbe4d72626e..ce5a00b7fc8 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -87,6 +87,7 @@  with Tbuild;         use Tbuild;
 with Ttypes;         use Ttypes;
 with Uintp;          use Uintp;
 with Urealp;         use Urealp;
+with Warnsw;         use Warnsw;
 
 package body Sem_Ch3 is
 
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 23040d7033b..b724fbe57a6 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -65,6 +65,7 @@  with Sinfo.Utils;    use Sinfo.Utils;
 with Snames;         use Snames;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 package body Sem_Ch4 is
 
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index 7bca6d39dd2..b54f2708c8d 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -66,6 +66,7 @@  with Targparm;       use Targparm;
 with Tbuild;         use Tbuild;
 with Ttypes;         use Ttypes;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 package body Sem_Ch5 is
 
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 454db66dd2c..cb982b376a5 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -11669,7 +11669,7 @@  package body Sem_Ch6 is
 
    procedure List_Inherited_Pre_Post_Aspects (E : Entity_Id) is
    begin
-      if Opt.List_Inherited_Aspects
+      if List_Inherited_Aspects
         and then Is_Subprogram_Or_Generic_Subprogram (E)
       then
          declare
diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb
index 77d1b38b827..0fb9fe10ff6 100644
--- a/gcc/ada/sem_ch7.adb
+++ b/gcc/ada/sem_ch7.adb
@@ -72,6 +72,7 @@  with Sinfo.Utils;    use Sinfo.Utils;
 with Sinput;         use Sinput;
 with Style;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 with GNAT.HTable;
 
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 62b9cc03643..ca306663791 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -76,6 +76,7 @@  with Style;
 with Table;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 package body Sem_Ch8 is
 
diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb
index f912f8bfb0a..a1e8f1ef30b 100644
--- a/gcc/ada/sem_elab.adb
+++ b/gcc/ada/sem_elab.adb
@@ -64,6 +64,7 @@  with Table;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
 with Uname;          use Uname;
+with Warnsw;         use Warnsw;
 
 with GNAT;                 use GNAT;
 with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
index 5d9b2d0484d..bec91add25c 100644
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -61,6 +61,7 @@  with Snames;         use Snames;
 with Stand;          use Stand;
 with Stringt;        use Stringt;
 with Tbuild;         use Tbuild;
+with Warnsw;         use Warnsw;
 
 package body Sem_Eval is
 
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 77fcb1c505f..72ad0cd9d81 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -25784,7 +25784,7 @@  package body Sem_Prag is
                                  C := Get_String_Char (Str, J);
                                  Chr := Get_Character (C);
 
-                                 if not Set_Dot_Warning_Switch (Chr) then
+                                 if not Set_Warning_Switch ('.', Chr) then
                                     Error_Pragma_Arg
                                       ("invalid warning switch character "
                                        & '.' & Chr, Arg1);
@@ -25793,7 +25793,7 @@  package body Sem_Prag is
                               --  Non-Dot case
 
                               else
-                                 OK := Set_Warning_Switch (Chr);
+                                 OK := Set_Warning_Switch (Plain, Chr);
                               end if;
 
                               if not OK then
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index c8652c959b7..e702df68a32 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -90,6 +90,7 @@  with Targparm;       use Targparm;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
 with Urealp;         use Urealp;
+with Warnsw;         use Warnsw;
 
 package body Sem_Res is
 
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index e43581ec6e9..67baf7abfad 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -71,6 +71,7 @@  with Targparm;       use Targparm;
 with Tbuild;         use Tbuild;
 with Ttypes;         use Ttypes;
 with Uname;          use Uname;
+with Warnsw;         use Warnsw;
 
 with GNAT.Heap_Sort_G;
 with GNAT.HTable;    use GNAT.HTable;
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index 0a46c66ae80..cbfabd2ceb3 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -51,6 +51,7 @@  with Stand;          use Stand;
 with Stringt;        use Stringt;
 with Tbuild;         use Tbuild;
 with Uintp;          use Uintp;
+with Warnsw;         use Warnsw;
 
 package body Sem_Warn is
 
@@ -2706,7 +2707,7 @@  package body Sem_Warn is
    begin
       --  Immediate return if no semantics or warning flag not set
 
-      if not Opt.Check_Withs or else Operating_Mode = Check_Syntax then
+      if not Check_Withs or else Operating_Mode = Check_Syntax then
          return;
       end if;
 
diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb
index 364ff55a4a6..db01d53ef29 100644
--- a/gcc/ada/switch-c.adb
+++ b/gcc/ada/switch-c.adb
@@ -1326,7 +1326,7 @@  package body Switch.C is
                      Ptr := Ptr + 1;
                      C := Switch_Chars (Ptr);
 
-                     if Set_Dot_Warning_Switch (C) then
+                     if Set_Warning_Switch ('.', C) then
                         Store_Compilation_Switch ("-gnatw." & C);
                      else
                         Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
@@ -1338,7 +1338,7 @@  package body Switch.C is
                      Ptr := Ptr + 1;
                      C := Switch_Chars (Ptr);
 
-                     if Set_Underscore_Warning_Switch (C) then
+                     if Set_Warning_Switch ('_', C) then
                         Store_Compilation_Switch ("-gnatw_" & C);
                      else
                         Bad_Switch ("-gnatw_" & Switch_Chars (Ptr .. Max));
@@ -1347,7 +1347,7 @@  package body Switch.C is
                   --  Normal case
 
                   else
-                     if Set_Warning_Switch (C) then
+                     if Set_Warning_Switch (Plain, C) then
                         Store_Compilation_Switch ("-gnatw" & C);
                      else
                         Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
diff --git a/gcc/ada/warnsw.adb b/gcc/ada/warnsw.adb
index dd40c8844c3..6fabafb9096 100644
--- a/gcc/ada/warnsw.adb
+++ b/gcc/ada/warnsw.adb
@@ -26,523 +26,149 @@ 
 with Opt;      use Opt;
 with Output;   use Output;
 
-package body Warnsw is
-
-   --  Local Subprograms
-
-   procedure All_Warnings (Setting : Boolean);
-   --  Sets all warnings off if Setting = False, and on if Setting = True
+with System.Case_Util; use System.Case_Util;
 
-   procedure WA_Warnings;
-   --  Turn on all warnings set by -gnatwa (also used by -gnatw.g)
+package body Warnsw is
 
-   ------------------
-   -- All_Warnings --
-   ------------------
-
-   procedure All_Warnings (Setting : Boolean) is
-   begin
-      Address_Clause_Overlay_Warnings      := Setting;
-      Check_Unreferenced                   := Setting;
-      Check_Unreferenced_Formals           := Setting;
-      Check_Withs                          := Setting;
-      Constant_Condition_Warnings          := Setting;
-      Elab_Warnings                        := Setting;
-      Implementation_Unit_Warnings         := Setting;
-      Ineffective_Inline_Warnings          := Setting;
-      List_Body_Required_Info              := Setting;
-      List_Inherited_Aspects               := Setting;
-      Warn_On_Ada_2005_Compatibility       := Setting;
-      Warn_On_Ada_2012_Compatibility       := Setting;
-      Warn_On_All_Unread_Out_Parameters    := Setting;
-      Warn_On_Anonymous_Allocators         := Setting;
-      Warn_On_Assertion_Failure            := Setting;
-      Warn_On_Assumed_Low_Bound            := Setting;
-      Warn_On_Atomic_Synchronization       := Setting;
-      Warn_On_Bad_Fixed_Value              := Setting;
-      Warn_On_Biased_Representation        := Setting;
-      Warn_On_Constant                     := Setting;
-      Warn_On_Deleted_Code                 := Setting;
-      Warn_On_Dereference                  := Setting;
-      Warn_On_Export_Import                := Setting;
-      Warn_On_Hiding                       := Setting;
-      Warn_On_Late_Primitives              := Setting;
-      Warn_On_Modified_Unread              := Setting;
-      Warn_On_No_Value_Assigned            := Setting;
-      Warn_On_Non_Local_Exception          := Setting;
-      Warn_On_Object_Renames_Function      := Setting;
-      Warn_On_Obsolescent_Feature          := Setting;
-      Warn_On_Overlap                      := Setting;
-      Warn_On_Overridden_Size              := Setting;
-      Warn_On_Parameter_Order              := Setting;
-      Warn_On_Pedantic_Checks              := Setting;
-      Warn_On_Questionable_Layout          := Setting;
-      Warn_On_Questionable_Missing_Parens  := Setting;
-      Warn_On_Record_Holes                 := Setting;
-      Warn_On_Ignored_Equality             := Setting;
-      Warn_On_Component_Order              := Setting;
-      Warn_On_Redundant_Constructs         := Setting;
-      Warn_On_Reverse_Bit_Order            := Setting;
-      Warn_On_Size_Alignment               := Setting;
-      Warn_On_Standard_Redefinition        := Setting;
-      Warn_On_Suspicious_Contract          := Setting;
-      Warn_On_Suspicious_Modulus_Value     := Setting;
-      Warn_On_Unchecked_Conversion         := Setting;
-      Warn_On_Unknown_Compile_Time_Warning := Setting;
-      Warn_On_Unordered_Enumeration_Type   := Setting;
-      Warn_On_Unrecognized_Pragma          := Setting;
-      Warn_On_Unrepped_Components          := Setting;
-      Warn_On_Warnings_Off                 := Setting;
-   end All_Warnings;
+   subtype Lowercase is Character range 'a' .. 'z';
+   --  Warning-enable switches are lowercase letters
+
+   Switch_To_Flag_Mapping : constant array (Warning_Family, Lowercase) of
+     --  Mapping from the letter after "-gnatw", "-gnatw." or "-gnatw_" to
+     --  the corresponding flag for the warning it enables. Special_Case means
+     --  Set_Warning_Switch must do something special, as opposed to simply
+     --  setting the corresponding flag. No_Such_Warning means the letter
+     --  is not a defined warning switch, which is an error.
+     X.Opt_Warnings_Enum :=
+       (Plain =>
+         ('a' | 'e' | 'n' | 's' | 'u' | 'y' => Special_Case,
+
+          'b' => X.Warn_On_Bad_Fixed_Value,
+          'c' => X.Constant_Condition_Warnings,
+          'd' => X.Warn_On_Dereference,
+          'f' => X.Check_Unreferenced_Formals,
+          'g' => X.Warn_On_Unrecognized_Pragma,
+          'h' => X.Warn_On_Hiding,
+          'i' => X.Implementation_Unit_Warnings,
+          'j' => X.Warn_On_Obsolescent_Feature,
+          'k' => X.Warn_On_Constant,
+          'l' => X.Elab_Warnings,
+          'm' => X.Warn_On_Modified_Unread,
+          'o' => X.Address_Clause_Overlay_Warnings,
+          'p' => X.Ineffective_Inline_Warnings,
+          'q' => X.Warn_On_Questionable_Missing_Parens,
+          'r' => X.Warn_On_Redundant_Constructs,
+          't' => X.Warn_On_Deleted_Code,
+          'v' => X.Warn_On_No_Value_Assigned,
+          'w' => X.Warn_On_Assumed_Low_Bound,
+          'x' => X.Warn_On_Export_Import,
+          'z' => X.Warn_On_Unchecked_Conversion),
+
+        '.' =>
+         ('e' | 'g' | 'x' => Special_Case,
+
+          'a' => X.Warn_On_Assertion_Failure,
+          'b' => X.Warn_On_Biased_Representation,
+          'c' => X.Warn_On_Unrepped_Components,
+          'd' => X.Warning_Doc_Switch,
+          'f' => X.Warn_On_Elab_Access,
+          'h' => X.Warn_On_Record_Holes,
+          'i' => X.Warn_On_Overlap,
+          'j' => X.Warn_On_Late_Primitives,
+          'k' => X.Warn_On_Standard_Redefinition,
+          'l' => X.List_Inherited_Aspects,
+          'm' => X.Warn_On_Suspicious_Modulus_Value,
+          'n' => X.Warn_On_Atomic_Synchronization,
+          'o' => X.Warn_On_All_Unread_Out_Parameters,
+          'p' => X.Warn_On_Parameter_Order,
+          'q' => X.Warn_On_Questionable_Layout,
+          'r' => X.Warn_On_Object_Renames_Function,
+          's' => X.Warn_On_Overridden_Size,
+          't' => X.Warn_On_Suspicious_Contract,
+          'u' => X.Warn_On_Unordered_Enumeration_Type,
+          'v' => X.Warn_On_Reverse_Bit_Order,
+          'w' => X.Warn_On_Warnings_Off,
+          'y' => X.List_Body_Required_Info,
+          'z' => X.Warn_On_Size_Alignment),
+
+        '_' =>
+         ('b' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' |
+          'n' | 'o' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' =>
+           No_Such_Warning,
+
+          'a' => X.Warn_On_Anonymous_Allocators,
+          'c' => X.Warn_On_Unknown_Compile_Time_Warning,
+          'p' => X.Warn_On_Pedantic_Checks,
+          'q' => X.Warn_On_Ignored_Equality,
+          'r' => X.Warn_On_Component_Order));
+
+   All_Warnings : constant Warnings_State := --  Warnings set by -gnatw.e
+     (X.Elab_Info_Messages |
+      X.Warning_Doc_Switch |
+      X.Warn_On_Ada_2022_Compatibility |
+      X.Warn_On_Elab_Access |
+      X.No_Warn_On_Non_Local_Exception => False,
+      others => True);
+   --  Warning_Doc_Switch is not really a warning to be enabled, but controls
+   --  the form of warnings printed. No_Warn_On_Non_Local_Exception is handled
+   --  specially (see Warn_On_Non_Local_Exception). The others are not part of
+   --  -gnatw.e for historical reasons.
+
+   WA_Warnings : constant Warnings_State := --  Warnings set by -gnatwa
+     (X.Check_Unreferenced                  | -- -gnatwf/-gnatwu
+      X.Check_Unreferenced_Formals          | -- -gnatwf/-gnatwu
+      X.Check_Withs                         | -- -gnatwu
+      X.Constant_Condition_Warnings         | -- -gnatwc
+      X.Implementation_Unit_Warnings        | -- -gnatwi
+      X.Ineffective_Inline_Warnings         | -- -gnatwp
+      X.Warn_On_Ada_2005_Compatibility      | -- -gnatwy
+      X.Warn_On_Ada_2012_Compatibility      | -- -gnatwy
+      X.Warn_On_Anonymous_Allocators        | -- -gnatw_a
+      X.Warn_On_Assertion_Failure           | -- -gnatw.a
+      X.Warn_On_Assumed_Low_Bound           | -- -gnatww
+      X.Warn_On_Bad_Fixed_Value             | -- -gnatwb
+      X.Warn_On_Biased_Representation       | -- -gnatw.b
+      X.Warn_On_Constant                    | -- -gnatwk
+      X.Warn_On_Export_Import               | -- -gnatwx
+      X.Warn_On_Late_Primitives             | -- -gnatw.j
+      X.Warn_On_Modified_Unread             | -- -gnatwm
+      X.Warn_On_No_Value_Assigned           | -- -gnatwv
+      X.Warn_On_Non_Local_Exception         | -- -gnatw.x
+      X.Warn_On_Object_Renames_Function     | -- -gnatw.r
+      X.Warn_On_Obsolescent_Feature         | -- -gnatwj
+      X.Warn_On_Overlap                     | -- -gnatw.i
+      X.Warn_On_Parameter_Order             | -- -gnatw.p
+      X.Warn_On_Questionable_Missing_Parens | -- -gnatwq
+      X.Warn_On_Redundant_Constructs        | -- -gnatwr
+      X.Warn_On_Reverse_Bit_Order           | -- -gnatw.v
+      X.Warn_On_Size_Alignment              | -- -gnatw.z
+      X.Warn_On_Suspicious_Contract         | -- -gnatw.t
+      X.Warn_On_Suspicious_Modulus_Value    | -- -gnatw.m
+      X.Warn_On_Unchecked_Conversion        | -- -gnatwz
+      X.Warn_On_Unrecognized_Pragma         | -- -gnatwg
+      X.Warn_On_Unrepped_Components         => -- -gnatw.c
+        True,
+
+      others => False);
 
    ----------------------
    -- Restore_Warnings --
    ----------------------
 
-   procedure Restore_Warnings (W : Warning_Record) is
+   procedure Restore_Warnings (W : Warnings_State) is
    begin
-      Address_Clause_Overlay_Warnings      :=
-        W.Address_Clause_Overlay_Warnings;
-      Check_Unreferenced                   :=
-        W.Check_Unreferenced;
-      Check_Unreferenced_Formals           :=
-        W.Check_Unreferenced_Formals;
-      Check_Withs                          :=
-        W.Check_Withs;
-      Constant_Condition_Warnings          :=
-        W.Constant_Condition_Warnings;
-      Elab_Warnings                        :=
-        W.Elab_Warnings;
-      Elab_Info_Messages                   :=
-        W.Elab_Info_Messages;
-      Implementation_Unit_Warnings         :=
-        W.Implementation_Unit_Warnings;
-      Ineffective_Inline_Warnings          :=
-        W.Ineffective_Inline_Warnings;
-      List_Body_Required_Info              :=
-        W.List_Body_Required_Info;
-      List_Inherited_Aspects               :=
-        W.List_Inherited_Aspects;
-      No_Warn_On_Non_Local_Exception       :=
-        W.No_Warn_On_Non_Local_Exception;
-      Warning_Doc_Switch                   :=
-        W.Warning_Doc_Switch;
-      Warn_On_Ada_2005_Compatibility       :=
-        W.Warn_On_Ada_2005_Compatibility;
-      Warn_On_Ada_2012_Compatibility       :=
-        W.Warn_On_Ada_2012_Compatibility;
-      Warn_On_All_Unread_Out_Parameters    :=
-        W.Warn_On_All_Unread_Out_Parameters;
-      Warn_On_Anonymous_Allocators         :=
-        W.Warn_On_Anonymous_Allocators;
-      Warn_On_Assertion_Failure            :=
-        W.Warn_On_Assertion_Failure;
-      Warn_On_Assumed_Low_Bound            :=
-        W.Warn_On_Assumed_Low_Bound;
-      Warn_On_Atomic_Synchronization       :=
-        W.Warn_On_Atomic_Synchronization;
-      Warn_On_Bad_Fixed_Value              :=
-        W.Warn_On_Bad_Fixed_Value;
-      Warn_On_Biased_Representation        :=
-        W.Warn_On_Biased_Representation;
-      Warn_On_Constant                     :=
-        W.Warn_On_Constant;
-      Warn_On_Deleted_Code                 :=
-        W.Warn_On_Deleted_Code;
-      Warn_On_Dereference                  :=
-        W.Warn_On_Dereference;
-      Warn_On_Export_Import                :=
-        W.Warn_On_Export_Import;
-      Warn_On_Hiding                       :=
-        W.Warn_On_Hiding;
-      Warn_On_Late_Primitives              :=
-        W.Warn_On_Late_Primitives;
-      Warn_On_Modified_Unread              :=
-        W.Warn_On_Modified_Unread;
-      Warn_On_No_Value_Assigned            :=
-        W.Warn_On_No_Value_Assigned;
-      Warn_On_Non_Local_Exception          :=
-        W.Warn_On_Non_Local_Exception;
-      Warn_On_Object_Renames_Function      :=
-        W.Warn_On_Object_Renames_Function;
-      Warn_On_Obsolescent_Feature          :=
-        W.Warn_On_Obsolescent_Feature;
-      Warn_On_Overlap                      :=
-        W.Warn_On_Overlap;
-      Warn_On_Overridden_Size              :=
-        W.Warn_On_Overridden_Size;
-      Warn_On_Parameter_Order              :=
-        W.Warn_On_Parameter_Order;
-      Warn_On_Pedantic_Checks              :=
-        W.Warn_On_Pedantic_Checks;
-      Warn_On_Questionable_Layout          :=
-        W.Warn_On_Questionable_Layout;
-      Warn_On_Questionable_Missing_Parens  :=
-        W.Warn_On_Questionable_Missing_Parens;
-      Warn_On_Record_Holes                 :=
-        W.Warn_On_Record_Holes;
-      Warn_On_Ignored_Equality              :=
-        W.Warn_On_Ignored_Equality;
-      Warn_On_Component_Order              :=
-        W.Warn_On_Component_Order;
-      Warn_On_Redundant_Constructs         :=
-        W.Warn_On_Redundant_Constructs;
-      Warn_On_Reverse_Bit_Order            :=
-        W.Warn_On_Reverse_Bit_Order;
-      Warn_On_Size_Alignment               :=
-        W.Warn_On_Size_Alignment;
-      Warn_On_Standard_Redefinition        :=
-        W.Warn_On_Standard_Redefinition;
-      Warn_On_Suspicious_Contract          :=
-        W.Warn_On_Suspicious_Contract;
-      Warn_On_Unchecked_Conversion         :=
-        W.Warn_On_Unchecked_Conversion;
-      Warn_On_Unknown_Compile_Time_Warning :=
-        W.Warn_On_Unknown_Compile_Time_Warning;
-      Warn_On_Unordered_Enumeration_Type   :=
-        W.Warn_On_Unordered_Enumeration_Type;
-      Warn_On_Unrecognized_Pragma          :=
-        W.Warn_On_Unrecognized_Pragma;
-      Warn_On_Unrepped_Components          :=
-        W.Warn_On_Unrepped_Components;
-      Warn_On_Warnings_Off                 :=
-        W.Warn_On_Warnings_Off;
+      Warning_Flags := W;
    end Restore_Warnings;
 
    -------------------
    -- Save_Warnings --
    -------------------
 
-   function Save_Warnings return Warning_Record is
-      W : Warning_Record;
-
+   function Save_Warnings return Warnings_State is
    begin
-      W.Address_Clause_Overlay_Warnings      :=
-        Address_Clause_Overlay_Warnings;
-      W.Check_Unreferenced                   :=
-        Check_Unreferenced;
-      W.Check_Unreferenced_Formals           :=
-        Check_Unreferenced_Formals;
-      W.Check_Withs                          :=
-        Check_Withs;
-      W.Constant_Condition_Warnings          :=
-        Constant_Condition_Warnings;
-      W.Elab_Info_Messages                   :=
-        Elab_Info_Messages;
-      W.Elab_Warnings                        :=
-        Elab_Warnings;
-      W.Implementation_Unit_Warnings         :=
-        Implementation_Unit_Warnings;
-      W.Ineffective_Inline_Warnings          :=
-        Ineffective_Inline_Warnings;
-      W.List_Body_Required_Info              :=
-        List_Body_Required_Info;
-      W.List_Inherited_Aspects               :=
-        List_Inherited_Aspects;
-      W.No_Warn_On_Non_Local_Exception       :=
-        No_Warn_On_Non_Local_Exception;
-      W.Warning_Doc_Switch                   :=
-        Warning_Doc_Switch;
-      W.Warn_On_Ada_2005_Compatibility       :=
-        Warn_On_Ada_2005_Compatibility;
-      W.Warn_On_Ada_2012_Compatibility       :=
-        Warn_On_Ada_2012_Compatibility;
-      W.Warn_On_All_Unread_Out_Parameters    :=
-        Warn_On_All_Unread_Out_Parameters;
-      W.Warn_On_Anonymous_Allocators         :=
-        Warn_On_Anonymous_Allocators;
-      W.Warn_On_Assertion_Failure            :=
-        Warn_On_Assertion_Failure;
-      W.Warn_On_Assumed_Low_Bound            :=
-        Warn_On_Assumed_Low_Bound;
-      W.Warn_On_Atomic_Synchronization       :=
-        Warn_On_Atomic_Synchronization;
-      W.Warn_On_Bad_Fixed_Value              :=
-        Warn_On_Bad_Fixed_Value;
-      W.Warn_On_Biased_Representation        :=
-        Warn_On_Biased_Representation;
-      W.Warn_On_Constant                     :=
-        Warn_On_Constant;
-      W.Warn_On_Deleted_Code                 :=
-        Warn_On_Deleted_Code;
-      W.Warn_On_Dereference                  :=
-        Warn_On_Dereference;
-      W.Warn_On_Export_Import                :=
-        Warn_On_Export_Import;
-      W.Warn_On_Hiding                       :=
-        Warn_On_Hiding;
-      W.Warn_On_Late_Primitives              :=
-        Warn_On_Late_Primitives;
-      W.Warn_On_Modified_Unread              :=
-        Warn_On_Modified_Unread;
-      W.Warn_On_No_Value_Assigned            :=
-        Warn_On_No_Value_Assigned;
-      W.Warn_On_Non_Local_Exception          :=
-        Warn_On_Non_Local_Exception;
-      W.Warn_On_Object_Renames_Function      :=
-        Warn_On_Object_Renames_Function;
-      W.Warn_On_Obsolescent_Feature          :=
-        Warn_On_Obsolescent_Feature;
-      W.Warn_On_Overlap                      :=
-        Warn_On_Overlap;
-      W.Warn_On_Overridden_Size              :=
-        Warn_On_Overridden_Size;
-      W.Warn_On_Parameter_Order              :=
-        Warn_On_Parameter_Order;
-      W.Warn_On_Pedantic_Checks              :=
-        Warn_On_Pedantic_Checks;
-      W.Warn_On_Questionable_Layout          :=
-        Warn_On_Questionable_Layout;
-      W.Warn_On_Questionable_Missing_Parens  :=
-        Warn_On_Questionable_Missing_Parens;
-      W.Warn_On_Record_Holes                 :=
-        Warn_On_Record_Holes;
-      W.Warn_On_Ignored_Equality             :=
-        Warn_On_Ignored_Equality;
-      W.Warn_On_Component_Order              :=
-        Warn_On_Component_Order;
-      W.Warn_On_Redundant_Constructs         :=
-        Warn_On_Redundant_Constructs;
-      W.Warn_On_Reverse_Bit_Order            :=
-        Warn_On_Reverse_Bit_Order;
-      W.Warn_On_Size_Alignment               :=
-        Warn_On_Size_Alignment;
-      W.Warn_On_Standard_Redefinition        :=
-        Warn_On_Standard_Redefinition;
-      W.Warn_On_Suspicious_Contract          :=
-        Warn_On_Suspicious_Contract;
-      W.Warn_On_Unchecked_Conversion         :=
-        Warn_On_Unchecked_Conversion;
-      W.Warn_On_Unknown_Compile_Time_Warning :=
-        Warn_On_Unknown_Compile_Time_Warning;
-      W.Warn_On_Unordered_Enumeration_Type   :=
-        Warn_On_Unordered_Enumeration_Type;
-      W.Warn_On_Unrecognized_Pragma          :=
-        Warn_On_Unrecognized_Pragma;
-      W.Warn_On_Unrepped_Components          :=
-        Warn_On_Unrepped_Components;
-      W.Warn_On_Warnings_Off                 :=
-        Warn_On_Warnings_Off;
-      return W;
+      return Warning_Flags;
    end Save_Warnings;
 
-   ----------------------------
-   -- Set_Dot_Warning_Switch --
-   ----------------------------
-
-   function Set_Dot_Warning_Switch (C : Character) return Boolean is
-   begin
-      case C is
-         when 'a' =>
-            Warn_On_Assertion_Failure           := True;
-
-         when 'A' =>
-            Warn_On_Assertion_Failure           := False;
-
-         when 'b' =>
-            Warn_On_Biased_Representation       := True;
-
-         when 'B' =>
-            Warn_On_Biased_Representation       := False;
-
-         when 'c' =>
-            Warn_On_Unrepped_Components         := True;
-
-         when 'C' =>
-            Warn_On_Unrepped_Components         := False;
-
-         when 'd' =>
-            Warning_Doc_Switch                  := True;
-
-         when 'D' =>
-            Warning_Doc_Switch                  := False;
-
-         when 'e' =>
-            All_Warnings (True);
-
-         when 'f' =>
-            Warn_On_Elab_Access                 := True;
-
-         when 'F' =>
-            Warn_On_Elab_Access                 := False;
-
-         when 'g' =>
-            Set_GNAT_Mode_Warnings;
-
-         when 'h' =>
-            Warn_On_Record_Holes                := True;
-
-         when 'H' =>
-            Warn_On_Record_Holes                := False;
-
-         when 'i' =>
-            Warn_On_Overlap                     := True;
-
-         when 'I' =>
-            Warn_On_Overlap                     := False;
-
-         when 'j' =>
-            Warn_On_Late_Primitives             := True;
-
-         when 'J' =>
-            Warn_On_Late_Primitives             := False;
-
-         when 'k' =>
-            Warn_On_Standard_Redefinition       := True;
-
-         when 'K' =>
-            Warn_On_Standard_Redefinition       := False;
-
-         when 'l' =>
-            List_Inherited_Aspects              := True;
-
-         when 'L' =>
-            List_Inherited_Aspects              := False;
-
-         when 'm' =>
-            Warn_On_Suspicious_Modulus_Value    := True;
-
-         when 'M' =>
-            Warn_On_Suspicious_Modulus_Value    := False;
-
-         when 'n' =>
-            Warn_On_Atomic_Synchronization      := True;
-
-         when 'N' =>
-            Warn_On_Atomic_Synchronization      := False;
-
-         when 'o' =>
-            Warn_On_All_Unread_Out_Parameters   := True;
-
-         when 'O' =>
-            Warn_On_All_Unread_Out_Parameters   := False;
-
-         when 'p' =>
-            Warn_On_Parameter_Order             := True;
-
-         when 'P' =>
-            Warn_On_Parameter_Order             := False;
-
-         when 'q' =>
-            Warn_On_Questionable_Layout         := True;
-
-         when 'Q' =>
-            Warn_On_Questionable_Layout         := False;
-
-         when 'r' =>
-            Warn_On_Object_Renames_Function     := True;
-
-         when 'R' =>
-            Warn_On_Object_Renames_Function     := False;
-
-         when 's' =>
-            Warn_On_Overridden_Size             := True;
-
-         when 'S' =>
-            Warn_On_Overridden_Size             := False;
-
-         when 't' =>
-            Warn_On_Suspicious_Contract         := True;
-
-         when 'T' =>
-            Warn_On_Suspicious_Contract         := False;
-
-         when 'u' =>
-            Warn_On_Unordered_Enumeration_Type  := True;
-
-         when 'U' =>
-            Warn_On_Unordered_Enumeration_Type  := False;
-
-         when 'v' =>
-            Warn_On_Reverse_Bit_Order           := True;
-
-         when 'V' =>
-            Warn_On_Reverse_Bit_Order           := False;
-
-         when 'w' =>
-            Warn_On_Warnings_Off                := True;
-
-         when 'W' =>
-            Warn_On_Warnings_Off                := False;
-
-         when 'x' =>
-            Warn_On_Non_Local_Exception         := True;
-
-         when 'X' =>
-            Warn_On_Non_Local_Exception         := False;
-            No_Warn_On_Non_Local_Exception      := True;
-
-         when 'y' =>
-            List_Body_Required_Info             := True;
-
-         when 'Y' =>
-            List_Body_Required_Info             := False;
-
-         when 'z' =>
-            Warn_On_Size_Alignment              := True;
-
-         when 'Z' =>
-            Warn_On_Size_Alignment              := False;
-
-         when others =>
-            if Ignore_Unrecognized_VWY_Switches then
-               Write_Line ("unrecognized switch -gnatw." & C & " ignored");
-            else
-               return False;
-            end if;
-      end case;
-
-      return True;
-   end Set_Dot_Warning_Switch;
-
-   -----------------------------------
-   -- Set_Underscore_Warning_Switch --
-   -----------------------------------
-
-   function Set_Underscore_Warning_Switch (C : Character) return Boolean is
-   begin
-      case C is
-         when 'a' =>
-            Warn_On_Anonymous_Allocators := True;
-
-         when 'A' =>
-            Warn_On_Anonymous_Allocators := False;
-
-         when 'c' =>
-            Warn_On_Unknown_Compile_Time_Warning := True;
-
-         when 'C' =>
-            Warn_On_Unknown_Compile_Time_Warning := False;
-
-         when 'p' =>
-            Warn_On_Pedantic_Checks := True;
-
-         when 'P' =>
-            Warn_On_Pedantic_Checks := False;
-
-         when 'q' =>
-            Warn_On_Ignored_Equality := True;
-
-         when 'Q' =>
-            Warn_On_Ignored_Equality := False;
-
-         when 'r' =>
-            Warn_On_Component_Order := True;
-
-         when 'R' =>
-            Warn_On_Component_Order := False;
-
-         when others =>
-            if Ignore_Unrecognized_VWY_Switches then
-               Write_Line ("unrecognized switch -gnatw_" & C & " ignored");
-            else
-               return False;
-            end if;
-      end case;
-
-      return True;
-   end Set_Underscore_Warning_Switch;
-
    ----------------------------
    -- Set_GNAT_Mode_Warnings --
    ----------------------------
@@ -551,8 +177,7 @@  package body Warnsw is
    begin
       --  Set -gnatwa warnings and no others
 
-      All_Warnings (False);
-      WA_Warnings;
+      Warning_Flags := (Warning_Flags and not All_Warnings) or WA_Warnings;
 
       --  These warnings are added to the -gnatwa set
 
@@ -574,215 +199,118 @@  package body Warnsw is
    -- Set_Warning_Switch --
    ------------------------
 
-   function Set_Warning_Switch (C : Character) return Boolean is
+   function Set_Warning_Switch
+     (Family : Warning_Family; C : Character) return Boolean
+   is
+      L : constant Character := To_Lower (C);
    begin
-      case C is
-         when 'a' =>
-            WA_Warnings;
-
-         when 'A' =>
-            All_Warnings (False);
-            No_Warn_On_Non_Local_Exception      := True;
-
-         when 'b' =>
-            Warn_On_Bad_Fixed_Value             := True;
-
-         when 'B' =>
-            Warn_On_Bad_Fixed_Value             := False;
-
-         when 'c' =>
-            Constant_Condition_Warnings         := True;
-
-         when 'C' =>
-            Constant_Condition_Warnings         := False;
-
-         when 'd' =>
-            Warn_On_Dereference                 := True;
-
-         when 'D' =>
-            Warn_On_Dereference                 := False;
-
-         when 'e' =>
-            Warning_Mode                        := Treat_As_Error;
-
-         when 'E' =>
-            Warning_Mode := Treat_Run_Time_Warnings_As_Errors;
-
-         when 'f' =>
-            Check_Unreferenced_Formals          := True;
-
-         when 'F' =>
-            Check_Unreferenced_Formals          := False;
-
-         when 'g' =>
-            Warn_On_Unrecognized_Pragma         := True;
-
-         when 'G' =>
-            Warn_On_Unrecognized_Pragma         := False;
-
-         when 'h' =>
-            Warn_On_Hiding                      := True;
-
-         when 'H' =>
-            Warn_On_Hiding                      := False;
-
-         when 'i' =>
-            Implementation_Unit_Warnings        := True;
-
-         when 'I' =>
-            Implementation_Unit_Warnings        := False;
-
-         when 'j' =>
-            Warn_On_Obsolescent_Feature         := True;
-
-         when 'J' =>
-            Warn_On_Obsolescent_Feature         := False;
-
-         when 'k' =>
-            Warn_On_Constant                    := True;
-
-         when 'K' =>
-            Warn_On_Constant                    := False;
-
-         when 'l' =>
-            Elab_Warnings                       := True;
-
-         when 'L' =>
-            Elab_Warnings                       := False;
-
-         when 'm' =>
-            Warn_On_Modified_Unread             := True;
-
-         when 'M' =>
-            Warn_On_Modified_Unread             := False;
-
-         when 'n' =>
-            Warning_Mode                        := Normal;
-
-         when 'o' =>
-            Address_Clause_Overlay_Warnings     := True;
-
-         when 'O' =>
-            Address_Clause_Overlay_Warnings     := False;
-
-         when 'p' =>
-            Ineffective_Inline_Warnings         := True;
-
-         when 'P' =>
-            Ineffective_Inline_Warnings         := False;
-
-         when 'q' =>
-            Warn_On_Questionable_Missing_Parens := True;
-
-         when 'Q' =>
-            Warn_On_Questionable_Missing_Parens := False;
-
-         when 'r' =>
-            Warn_On_Redundant_Constructs        := True;
-
-         when 'R' =>
-            Warn_On_Redundant_Constructs        := False;
-
-         when 's' =>
-            Warning_Mode                        := Suppress;
-
-         when 't' =>
-            Warn_On_Deleted_Code                := True;
-
-         when 'T' =>
-            Warn_On_Deleted_Code                := False;
-
-         when 'u' =>
-            Check_Unreferenced                  := True;
-            Check_Withs                         := True;
-            Check_Unreferenced_Formals          := True;
-
-         when 'U' =>
-            Check_Unreferenced                  := False;
-            Check_Withs                         := False;
-            Check_Unreferenced_Formals          := False;
-
-         when 'v' =>
-            Warn_On_No_Value_Assigned           := True;
-
-         when 'V' =>
-            Warn_On_No_Value_Assigned           := False;
-
-         when 'w' =>
-            Warn_On_Assumed_Low_Bound           := True;
-
-         when 'W' =>
-            Warn_On_Assumed_Low_Bound           := False;
-
-         when 'x' =>
-            Warn_On_Export_Import               := True;
-
-         when 'X' =>
-            Warn_On_Export_Import               := False;
-
-         when 'y' =>
-            Warn_On_Ada_2005_Compatibility      := True;
-            Warn_On_Ada_2012_Compatibility      := True;
-
-         when 'Y' =>
-            Warn_On_Ada_2005_Compatibility      := False;
-            Warn_On_Ada_2012_Compatibility      := False;
-
-         when 'z' =>
-            Warn_On_Unchecked_Conversion        := True;
-
-         when 'Z' =>
-            Warn_On_Unchecked_Conversion        := False;
-
-         when others =>
-            if Ignore_Unrecognized_VWY_Switches then
-               Write_Line ("unrecognized switch -gnatw" & C & " ignored");
-            else
-               return False;
-            end if;
-      end case;
+      --  Error case
+
+      if L not in Lowercase
+        or else Switch_To_Flag_Mapping (Family, L) = No_Such_Warning
+      then
+         if Ignore_Unrecognized_VWY_Switches then
+            declare
+               Family_Switch : constant String :=
+                 (case Family is
+                   when Plain => "", when '.' => ".", when '_' => "_");
+            begin
+               Write_Line
+                 ("unrecognized switch -gnatw" & Family_Switch & C &
+                  " ignored");
+            end;
+            return True;
+         else
+            return False;
+         end if;
+      end if;
+
+      --  Special cases that don't fall into the normal pattern below
+
+      if Switch_To_Flag_Mapping (Family, L) = Special_Case then
+         case Family is
+            when Plain =>
+               case C is
+                  when 'a' =>
+                     --  "or" in the -gnatwa flags, possibly leaving others set
+                     Warning_Flags := Warning_Flags or WA_Warnings;
+
+                  when 'A' =>
+                     --  Turn off the All_Warnings flags, except that
+                     --  No_Warn_On_Non_Local_Exception is a special case.
+                     Warning_Flags := Warning_Flags and not All_Warnings;
+                     No_Warn_On_Non_Local_Exception := True;
+
+                  when 'e' =>
+                     Warning_Mode := Treat_As_Error;
+
+                  when 'E' =>
+                     Warning_Mode := Treat_Run_Time_Warnings_As_Errors;
+
+                  when 'n' =>
+                     Warning_Mode := Normal;
+
+                  when 's' =>
+                     Warning_Mode := Suppress;
+
+                  when 'u' =>
+                     Check_Unreferenced := True;
+                     Check_Withs := True;
+                     Check_Unreferenced_Formals := True;
+
+                  when 'U' =>
+                     Check_Unreferenced := False;
+                     Check_Withs := False;
+                     Check_Unreferenced_Formals := False;
+
+                  when 'y' =>
+                     Warn_On_Ada_2005_Compatibility := True;
+                     Warn_On_Ada_2012_Compatibility := True;
+
+                  when 'Y' =>
+                     Warn_On_Ada_2005_Compatibility := False;
+                     Warn_On_Ada_2012_Compatibility := False;
+
+                  when others => raise Program_Error;
+               end case;
+
+            when '.' =>
+               case C is
+                  when 'e' =>
+                     --  "or" in the All_Warnings flags
+                     Warning_Flags := Warning_Flags or All_Warnings;
+                  when 'g' =>
+                     Set_GNAT_Mode_Warnings;
+
+                  when 'x' =>
+                     Warn_On_Non_Local_Exception := True;
+
+                  when 'X' =>
+                     Warn_On_Non_Local_Exception := False;
+                     No_Warn_On_Non_Local_Exception := True;
+
+                  when others => raise Program_Error;
+               end case;
+
+            when '_' =>
+               raise Program_Error;
+         end case;
+
+         return True;
+      end if;
+
+      --  Normal pattern (lower case enables the warning, upper case disables
+      --  the warning).
+
+      if C in Lowercase then
+         Warning_Flags (Switch_To_Flag_Mapping (Family, C)) := True;
+      elsif L in Lowercase then
+         Warning_Flags (Switch_To_Flag_Mapping (Family, L)) := False;
+      else
+         raise Program_Error;
+      end if;
 
       return True;
    end Set_Warning_Switch;
 
-   -----------------
-   -- WA_Warnings --
-   -----------------
-
-   procedure WA_Warnings is
-   begin
-      Check_Unreferenced                  := True; -- -gnatwf/-gnatwu
-      Check_Unreferenced_Formals          := True; -- -gnatwf/-gnatwu
-      Check_Withs                         := True; -- -gnatwu
-      Constant_Condition_Warnings         := True; -- -gnatwc
-      Implementation_Unit_Warnings        := True; -- -gnatwi
-      Ineffective_Inline_Warnings         := True; -- -gnatwp
-      Warn_On_Ada_2005_Compatibility      := True; -- -gnatwy
-      Warn_On_Ada_2012_Compatibility      := True; -- -gnatwy
-      Warn_On_Anonymous_Allocators        := True; -- -gnatw_a
-      Warn_On_Assertion_Failure           := True; -- -gnatw.a
-      Warn_On_Assumed_Low_Bound           := True; -- -gnatww
-      Warn_On_Bad_Fixed_Value             := True; -- -gnatwb
-      Warn_On_Biased_Representation       := True; -- -gnatw.b
-      Warn_On_Constant                    := True; -- -gnatwk
-      Warn_On_Export_Import               := True; -- -gnatwx
-      Warn_On_Late_Primitives             := True; -- -gnatw.j
-      Warn_On_Modified_Unread             := True; -- -gnatwm
-      Warn_On_No_Value_Assigned           := True; -- -gnatwv
-      Warn_On_Non_Local_Exception         := True; -- -gnatw.x
-      Warn_On_Object_Renames_Function     := True; -- -gnatw.r
-      Warn_On_Obsolescent_Feature         := True; -- -gnatwj
-      Warn_On_Overlap                     := True; -- -gnatw.i
-      Warn_On_Parameter_Order             := True; -- -gnatw.p
-      Warn_On_Questionable_Missing_Parens := True; -- -gnatwq
-      Warn_On_Redundant_Constructs        := True; -- -gnatwr
-      Warn_On_Reverse_Bit_Order           := True; -- -gnatw.v
-      Warn_On_Size_Alignment              := True; -- -gnatw.z
-      Warn_On_Suspicious_Contract         := True; -- -gnatw.t
-      Warn_On_Suspicious_Modulus_Value    := True; -- -gnatw.m
-      Warn_On_Unchecked_Conversion        := True; -- -gnatwz
-      Warn_On_Unrecognized_Pragma         := True; -- -gnatwg
-      Warn_On_Unrepped_Components         := True; -- -gnatw.c
-   end WA_Warnings;
-
 end Warnsw;
diff --git a/gcc/ada/warnsw.ads b/gcc/ada/warnsw.ads
index 645094509f4..46ae75211e5 100644
--- a/gcc/ada/warnsw.ads
+++ b/gcc/ada/warnsw.ads
@@ -24,6 +24,7 @@ 
 ------------------------------------------------------------------------------
 
 --  This unit contains the routines used to handle setting of warning options
+--  in the GNAT compiler.
 
 package Warnsw is
 
@@ -34,11 +35,206 @@  package Warnsw is
    --  These flags are activated or deactivated by -gnatw switches and control
    --  whether warnings of a given class will be generated or not.
 
-   --  Note: most of these flags are still in opt, but the plan is to move them
-   --  here as time goes by. And in fact a really nice idea would be to put
-   --  them all in a Warn_Record so that they would be easy to save/restore.
+   package Warnings_Package is
+      type Opt_Warnings_Enum is
+        --  List of all warnings that can be enabled, plus the two null-ish
+        --  values.
+        (No_Such_Warning, Special_Case, -- see body
 
-   Warning_Doc_Switch : Boolean := True;
+         Address_Clause_Overlay_Warnings,
+         Check_Unreferenced,
+         Check_Unreferenced_Formals,
+         Check_Withs,
+         Constant_Condition_Warnings,
+         Elab_Info_Messages,
+         Elab_Warnings,
+         Implementation_Unit_Warnings,
+         Ineffective_Inline_Warnings,
+         List_Body_Required_Info,
+         List_Inherited_Aspects,
+         Warning_Doc_Switch,
+         Warn_On_Ada_2005_Compatibility,
+         Warn_On_Ada_2012_Compatibility,
+         Warn_On_Ada_2022_Compatibility,
+         Warn_On_All_Unread_Out_Parameters,
+         Warn_On_Anonymous_Allocators,
+         Warn_On_Assertion_Failure,
+         Warn_On_Assumed_Low_Bound,
+         Warn_On_Atomic_Synchronization,
+         Warn_On_Bad_Fixed_Value,
+         Warn_On_Biased_Representation,
+         Warn_On_Component_Order,
+         Warn_On_Constant,
+         Warn_On_Deleted_Code,
+         Warn_On_Dereference,
+         Warn_On_Elab_Access,
+         Warn_On_Export_Import,
+         Warn_On_Hiding,
+         Warn_On_Ignored_Equality,
+         Warn_On_Late_Primitives,
+         Warn_On_Modified_Unread,
+         Warn_On_No_Value_Assigned,
+         Warn_On_Non_Local_Exception,
+         No_Warn_On_Non_Local_Exception,
+         Warn_On_Object_Renames_Function,
+         Warn_On_Obsolescent_Feature,
+         Warn_On_Overlap,
+         Warn_On_Overridden_Size,
+         Warn_On_Parameter_Order,
+         Warn_On_Pedantic_Checks,
+         Warn_On_Questionable_Layout,
+         Warn_On_Questionable_Missing_Parens,
+         Warn_On_Record_Holes,
+         Warn_On_Redundant_Constructs,
+         Warn_On_Reverse_Bit_Order,
+         Warn_On_Size_Alignment,
+         Warn_On_Standard_Redefinition,
+         Warn_On_Suspicious_Contract,
+         Warn_On_Suspicious_Modulus_Value,
+         Warn_On_Unchecked_Conversion,
+         Warn_On_Unknown_Compile_Time_Warning,
+         Warn_On_Unordered_Enumeration_Type,
+         Warn_On_Unrecognized_Pragma,
+         Warn_On_Unrepped_Components,
+         Warn_On_Warnings_Off); -- Opt_Warnings_Enum
+
+      subtype Warnings_Enum is Opt_Warnings_Enum
+        range Opt_Warnings_Enum'Succ (Special_Case) .. Opt_Warnings_Enum'Last;
+      --  Just the warning switches, without the null-ish values
+   end Warnings_Package;
+   use Warnings_Package;
+
+   type Warnings_State is array (Warnings_Enum) of Boolean;
+   pragma Pack (Warnings_State);
+   --  Without Pack, we can have bootstrapping failures, because the compiler
+   --  generates calls to System.Boolean_Array_Operations, which is not
+   --  currently part of the compiler.
+
+   Warning_Flags : Warnings_State :=
+   --  Current state of warnings -- True/False means enabled/disabled.
+   --  The following initializes the flags to their default values,
+   --  and warning switches modify them.
+     (Address_Clause_Overlay_Warnings |
+      Elab_Warnings |
+      Implementation_Unit_Warnings |
+      Warning_Doc_Switch |
+      Warn_On_Ada_2005_Compatibility |
+      Warn_On_Ada_2012_Compatibility |
+      Warn_On_Ada_2022_Compatibility |
+      Warn_On_Assertion_Failure |
+      Warn_On_Assumed_Low_Bound |
+      Warn_On_Biased_Representation |
+      Warn_On_Export_Import |
+      Warn_On_No_Value_Assigned |
+      Warn_On_Questionable_Missing_Parens |
+      Warn_On_Reverse_Bit_Order |
+      Warn_On_Size_Alignment |
+      Warn_On_Suspicious_Contract |
+      Warn_On_Suspicious_Modulus_Value |
+      Warn_On_Unchecked_Conversion |
+      Warn_On_Unknown_Compile_Time_Warning |
+      Warn_On_Unrecognized_Pragma =>
+        True,
+
+      Check_Unreferenced |
+      Check_Unreferenced_Formals |
+      Check_Withs |
+      Constant_Condition_Warnings |
+      Elab_Info_Messages |
+      Ineffective_Inline_Warnings |
+      List_Body_Required_Info |
+      List_Inherited_Aspects |
+      Warn_On_All_Unread_Out_Parameters |
+      Warn_On_Anonymous_Allocators |
+      Warn_On_Atomic_Synchronization |
+      Warn_On_Bad_Fixed_Value |
+      Warn_On_Component_Order |
+      Warn_On_Constant |
+      Warn_On_Deleted_Code |
+      Warn_On_Dereference |
+      Warn_On_Elab_Access |
+      Warn_On_Hiding |
+      Warn_On_Ignored_Equality |
+      Warn_On_Late_Primitives |
+      Warn_On_Modified_Unread |
+      Warn_On_Non_Local_Exception |
+      No_Warn_On_Non_Local_Exception |
+      Warn_On_Object_Renames_Function |
+      Warn_On_Obsolescent_Feature |
+      Warn_On_Overlap |
+      Warn_On_Overridden_Size |
+      Warn_On_Parameter_Order |
+      Warn_On_Pedantic_Checks |
+      Warn_On_Questionable_Layout |
+      Warn_On_Record_Holes |
+      Warn_On_Redundant_Constructs |
+      Warn_On_Standard_Redefinition |
+      Warn_On_Unordered_Enumeration_Type |
+      Warn_On_Unrepped_Components |
+      Warn_On_Warnings_Off =>
+        False);
+
+   package X renames Warnings_Package;
+   F : Warnings_State renames Warning_Flags;
+   --  Short-hand names used only locally to this package
+
+   --  The following rename all the components of Warning_Flags for convenient
+   --  access throughout the compiler.
+
+   pragma Style_Checks ("M120");
+   Address_Clause_Overlay_Warnings : Boolean renames F (X.Address_Clause_Overlay_Warnings);
+   --  Set False to disable address clause warnings. Modified by use of
+   --  -gnatwo/O.
+
+   Check_Unreferenced : Boolean renames F (X.Check_Unreferenced);
+   --  Set to True to enable checking for unreferenced entities other
+   --  than formal parameters (for which see Check_Unreferenced_Formals)
+   --  Modified by use of -gnatwu/U.
+
+   Check_Unreferenced_Formals : Boolean renames F (X.Check_Unreferenced_Formals);
+   --  Set to True to check for unreferenced formals. This is turned on by
+   --  -gnatwa/wf/wu and turned off by -gnatwA/wF/wU.
+
+   Check_Withs : Boolean renames F (X.Check_Withs);
+   --  Set to True to enable checking for unused withs, and also the case
+   --  of withing a package and using none of the entities in the package.
+   --  Modified by use of -gnatwu/U.
+
+   Constant_Condition_Warnings : Boolean renames F (X.Constant_Condition_Warnings);
+   --  Set to True to activate warnings on constant conditions. Modified by
+   --  use of -gnatwc/C.
+
+   Elab_Info_Messages : Boolean renames F (X.Elab_Info_Messages);
+   --  Set to True to output info messages for static elabmodel (-gnatel)
+
+   Elab_Warnings : Boolean renames F (X.Elab_Warnings);
+   --  Set to True to generate elaboration warnings (-gnatwl). The warnings are
+   --  enabled by default because they carry the same importance as errors. The
+   --  compiler cannot emit actual errors because elaboration diagnostics need
+   --  dataflow analysis, which is not available. This behavior parallels that
+   --  of the old ABE mechanism.
+
+   Implementation_Unit_Warnings : Boolean renames F (X.Implementation_Unit_Warnings);
+   --  Set True to active warnings for use of implementation internal units.
+   --  Modified by use of -gnatwi/-gnatwI.
+
+   Ineffective_Inline_Warnings : Boolean renames F (X.Ineffective_Inline_Warnings);
+   --  Set True to activate warnings if front-end inlining (-gnatN) is not able
+   --  to actually inline a particular call (or all calls). Can be controlled
+   --  by use of -gnatwp/-gnatwP. Also set True to activate warnings if
+   --  frontend inlining is not able to inline a subprogram expected to
+   --  be inlined in GNATprove mode.
+
+   List_Body_Required_Info : Boolean renames F (X.List_Body_Required_Info);
+   --  List info messages about why a package requires a body. Modified by use
+   --  of -gnatw.y/.Y.
+
+   List_Inherited_Aspects : Boolean renames F (X.List_Inherited_Aspects);
+   --  List inherited invariants, preconditions, and postconditions from
+   --  Invariant'Class, Pre'Class, and Post'Class aspects. Also list inherited
+   --  subtype predicates. Modified by use of -gnatw.l/.L.
+
+   Warning_Doc_Switch : Boolean renames F (X.Warning_Doc_Switch);
    --  If this is set True, then the ??/?*?/?$?/?x?/?.x?/?_x? insertion
    --  sequences in error messages generate appropriate tags for the output
    --  error messages. If this switch is False, then these sequences are still
@@ -47,35 +243,162 @@  package Warnsw is
    --  in adding the error message tag. The -gnatw.d switch sets this flag
    --  True, -gnatw.D sets this flag False.
 
-   Warn_On_Anonymous_Allocators : Boolean := False;
+   Warn_On_Ada_2005_Compatibility : Boolean renames F (X.Warn_On_Ada_2005_Compatibility);
+   --  Set to True to generate all warnings on Ada 2005 compatibility issues,
+   --  including warnings on Ada 2005 obsolescent features used in Ada 2005
+   --  mode. Set by default, modified by use of -gnatwy/Y.
+
+   Warn_On_Ada_2012_Compatibility : Boolean renames F (X.Warn_On_Ada_2012_Compatibility);
+   --  Set to True to generate all warnings on Ada 2012 compatibility issues,
+   --  including warnings on Ada 2012 obsolescent features used in Ada 2012
+   --  mode. Modified by use of -gnatwy/Y.
+
+   Warn_On_Ada_2022_Compatibility : Boolean renames F (X.Warn_On_Ada_2022_Compatibility);
+   --  Set to True to generate all warnings on Ada 2022 compatibility issues,
+   --  including warnings on Ada 2022 obsolescent features used in Ada 2022
+   --  mode. There is no switch controlling this option.
+
+   Warn_On_All_Unread_Out_Parameters : Boolean renames F (X.Warn_On_All_Unread_Out_Parameters);
+   --  Set to True to generate warnings in all cases where a variable is
+   --  modified by being passed as to an OUT formal, but the resulting value is
+   --  never read. The default is that this warning is suppressed. Modified
+   --  by use of gnatw.o/.O.
+
+   Warn_On_Anonymous_Allocators : Boolean renames F (X.Warn_On_Anonymous_Allocators);
    --  Warn when allocators for anonymous access types are present, which,
    --  although not illegal in Ada, may be confusing to users due to how
    --  accessibility checks get generated. Off by default, modified by use
    --  of -gnatw_a/_A and set as part of -gnatwa.
 
-   Warn_On_Late_Primitives : Boolean := False;
+   Warn_On_Assertion_Failure : Boolean renames F (X.Warn_On_Assertion_Failure);
+   --  Set to True to activate warnings on assertions that can be determined
+   --  at compile time will always fail. Modified by use of -gnatw.a/.A.
+
+   Warn_On_Assumed_Low_Bound : Boolean renames F (X.Warn_On_Assumed_Low_Bound);
+   --  Set to True to activate warnings for string parameters that are indexed
+   --  with literals or S'Length, presumably assuming a lower bound of one.
+   --  Modified by use of -gnatww/W.
+
+   Warn_On_Atomic_Synchronization : Boolean renames F (X.Warn_On_Atomic_Synchronization);
+   --  Set to True to generate information messages for atomic synchronization.
+   --  Modified by use of -gnatw.n/.N.
+
+   Warn_On_Bad_Fixed_Value : Boolean renames F (X.Warn_On_Bad_Fixed_Value);
+   --  Set to True to generate warnings for static fixed-point expression
+   --  values that are not an exact multiple of the small value of the type.
+   --  Odd by default, modified by use of -gnatwb/B.
+
+   Warn_On_Biased_Representation : Boolean renames F (X.Warn_On_Biased_Representation);
+   --  Set to True to generate warnings for size clauses, component clauses
+   --  and component_size clauses that force biased representation. Modified
+   --  by use of -gnatw.b/.B.
+
+   Warn_On_Component_Order : Boolean renames F (X.Warn_On_Component_Order);
+   --  Warn when record component clauses are out of order with respect to the
+   --  component declarations, or if the memory layout is out of order with
+   --  respect to component declarations and clauses.  Off by default, set by
+   --  -gnatw_r (but not -gnatwa).
+
+   Warn_On_Constant : Boolean renames F (X.Warn_On_Constant);
+   --  Set to True to generate warnings for variables that could be declared
+   --  as constants. Modified by use of -gnatwk/K.
+
+   Warn_On_Deleted_Code : Boolean renames F (X.Warn_On_Deleted_Code);
+   --  Set to True to generate warnings for code deleted by the front end
+   --  for conditional statements whose outcome is known at compile time.
+   --  Modified by use of -gnatwt/T.
+
+   Warn_On_Dereference : Boolean renames F (X.Warn_On_Dereference);
+   --  Set to True to generate warnings for implicit dereferences for array
+   --  indexing and record component access. Modified by use of -gnatwd/D.
+
+   Warn_On_Elab_Access : Boolean renames F (X.Warn_On_Elab_Access);
+   --  Set to True to generate warnings for P'Access in the case where
+   --  subprogram P is in the same package as the P'Access, and the P'Access is
+   --  evaluated at package elaboration time, and occurs before the body of P
+   --  has been elaborated. Modified by use of -gnatw.f/.F.
+
+   Warn_On_Export_Import : Boolean renames F (X.Warn_On_Export_Import);
+   --  Set to True to generate warnings for suspicious use of export or
+   --  import pragmas. Modified by use of -gnatwx/X.
+
+   Warn_On_Hiding : Boolean renames F (X.Warn_On_Hiding);
+   --  Set to True to generate warnings if a declared entity hides another
+   --  entity. The default is that this warning is suppressed. Modified by
+   --  use of -gnatwh/H.
+
+   Warn_On_Ignored_Equality : Boolean renames F (X.Warn_On_Ignored_Equality);
+   --  Warn when a user-defined "=" function does not compose (i.e. is ignored
+   --  for a predefined "=" for a composite type containing a component of
+   --  whose type has the user-defined "=" as primitive). Off by default, and
+   --  set by -gnatw_q (but not -gnatwa).
+
+   Warn_On_Late_Primitives : Boolean renames F (X.Warn_On_Late_Primitives);
    --  Warn when tagged type public primitives are defined after its private
    --  extensions.
 
-   Warn_On_Unknown_Compile_Time_Warning : Boolean := True;
-   --  Warn on a pragma Compile_Time_Warning whose condition has a value that
-   --  is not known at compile time. On by default, modified by use
-   --  of -gnatw_c/_C and set as part of -gnatwa.
+   Warn_On_Modified_Unread : Boolean renames F (X.Warn_On_Modified_Unread);
+   --  Set to True to generate warnings if a variable is assigned but is never
+   --  read. Also controls warnings for similar cases involving out parameters,
+   --  but only if there is only one out parameter for the procedure involved.
+   --  The default is that this warning is suppressed, modified by use of
+   --  -gnatwm/M.
+
+   Warn_On_No_Value_Assigned : Boolean renames F (X.Warn_On_No_Value_Assigned);
+   --  Set to True to generate warnings if no value is ever assigned to a
+   --  variable that is at least partially uninitialized. Set to false to
+   --  suppress such warnings. The default is that such warnings are enabled.
+   --  Modified by use of -gnatwv/V.
 
-   Warn_On_Overridden_Size : Boolean := False;
+   Warn_On_Non_Local_Exception : Boolean renames F (X.Warn_On_Non_Local_Exception);
+   --  Set to True to generate warnings for non-local exception raises and also
+   --  handlers that can never handle a local raise. This warning is only ever
+   --  generated if pragma Restrictions (No_Exception_Propagation) is set. The
+   --  default is not to generate the warnings except that if the source has
+   --  at least one exception handler, and this restriction is set, and the
+   --  warning was not explicitly turned off, then it is turned on by default.
+   --  Modified by use of -gnatw.x/.X.
+
+   No_Warn_On_Non_Local_Exception : Boolean renames F (X.No_Warn_On_Non_Local_Exception);
+   --  This is set to True if the above warning is explicitly suppressed. We
+   --  use this to avoid turning it on by default when No_Exception_Propagation
+   --  restriction is set and an exception handler is present.
+
+   Warn_On_Object_Renames_Function : Boolean renames F (X.Warn_On_Object_Renames_Function);
+   --  Set to True to generate warnings when a function result is renamed as
+   --  an object. The default is that this warning is disabled. Modified by
+   --  use of -gnatw.r/.R.
+
+   Warn_On_Obsolescent_Feature : Boolean renames F (X.Warn_On_Obsolescent_Feature);
+   --  Set to True to generate warnings on use of any feature in Annex or if a
+   --  subprogram is called for which a pragma Obsolescent applies. Modified
+   --  by use of -gnatwj/J.
+
+   Warn_On_Overlap : Boolean renames F (X.Warn_On_Overlap);
+   --  Set to True to generate warnings when a writable actual overlaps with
+   --  another actual in a subprogram call. This applies only in modes before
+   --  Ada 2012. Starting with Ada 2012, such overlaps are illegal.
+   --  Modified by use of -gnatw.i/.I.
+
+   Warn_On_Overridden_Size : Boolean renames F (X.Warn_On_Overridden_Size);
    --  Warn when explicit record component clause or array component_size
    --  clause specifies a size that overrides a size for the type which was
    --  set with an explicit size clause. Off by default, modified by use of
    --  -gnatw.s/.S (but not -gnatwa).
 
-   Warn_On_Pedantic_Checks : Boolean := False;
+   Warn_On_Parameter_Order : Boolean renames F (X.Warn_On_Parameter_Order);
+   --  Set to True to generate warnings for cases where the argument list for
+   --  a call is a sequence of identifiers that match the formal identifiers,
+   --  but are in the wrong order.
+
+   Warn_On_Pedantic_Checks : Boolean renames F (X.Warn_On_Pedantic_Checks);
    --  Warn for violation of miscellaneous pedantic rules (such as when the
    --  subtype of a formal parameter given in a subprogram body's specification
    --  comes from a different subtype declaration that the subtype of the
    --  formal in the subprogram declaration). Off by default, and set by
    --  -gnatw_p (but not -gnatwa).
 
-   Warn_On_Questionable_Layout : Boolean := False;
+   Warn_On_Questionable_Layout : Boolean renames F (X.Warn_On_Questionable_Layout);
    --  Warn when default layout of a record type is questionable for run-time
    --  efficiency reasons and would be improved by reordering the components.
    --  Off by default, modified by use of -gnatw.q/.Q (but not -gnatwa).
@@ -84,130 +407,112 @@  package Warnsw is
      (Warn_On_Questionable_Layout);
    --  WARNING: There is a matching C declaration of this function in fe.h
 
-   Warn_On_Record_Holes : Boolean := False;
+   Warn_On_Questionable_Missing_Parens : Boolean renames F (X.Warn_On_Questionable_Missing_Parens);
+   --  Set to True to generate warnings for cases where parentheses are missing
+   --  and the usage is questionable, because the intent is unclear. On by
+   --  default, modified by use of -gnatwq/Q.
+
+   Warn_On_Record_Holes : Boolean renames F (X.Warn_On_Record_Holes);
    --  Warn when explicit record component clauses leave uncovered holes (gaps)
    --  in a record layout. Off by default, set by -gnatw.h (but not -gnatwa).
 
-   Warn_On_Ignored_Equality : Boolean := False;
-   --  Warn when a user-defined "=" function does not compose (i.e. is ignored
-   --  for a predefined "=" for a composite type containing a component of
-   --  whose type has the user-defined "=" as primitive). Off by default, and
-   --  set by -gnatw_q (but not -gnatwa).
+   Warn_On_Redundant_Constructs : Boolean renames F (X.Warn_On_Redundant_Constructs);
+   --  Set to True to generate warnings for redundant constructs (e.g. useless
+   --  assignments/conversions). The default is that this warning is disabled.
+   --  Modified by use of -gnatwr/R.
 
-   Warn_On_Component_Order : Boolean := False;
-   --  Warn when record component clauses are out of order with respect to the
-   --  component declarations, or if the memory layout is out of order with
-   --  respect to component declarations and clauses.  Off by default, set by
-   --  -gnatw_r (but not -gnatwa).
+   Warn_On_Reverse_Bit_Order : Boolean renames F (X.Warn_On_Reverse_Bit_Order);
+   --  Set to True to generate warning (informational) messages for component
+   --  clauses that are affected by non-standard bit-order. The default is
+   --  that this warning is enabled. Modified by -gnatw.v/.V.
 
-   Warn_On_Size_Alignment : Boolean := True;
+   Warn_On_Size_Alignment : Boolean renames F (X.Warn_On_Size_Alignment);
    --  Warn when explicit Size and Alignment clauses are given for a type, and
    --  the size is not a multiple of the alignment. Off by default, modified
    --  by use of -gnatw.z/.Z and set as part of -gnatwa.
 
-   Warn_On_Standard_Redefinition : Boolean := False;
+   Warn_On_Standard_Redefinition : Boolean renames F (X.Warn_On_Standard_Redefinition);
    --  Warn when a program defines an identifier that matches a name in
    --  Standard. Off by default, modified by use of -gnatw.k/.K (but not
    --  by -gnatwa).
 
+   Warn_On_Suspicious_Contract : Boolean renames F (X.Warn_On_Suspicious_Contract);
+   --  Set to True to generate warnings for suspicious contracts expressed as
+   --  pragmas or aspects precondition and postcondition, as well as other
+   --  suspicious cases of expressions typically found in contracts like
+   --  quantified expressions and uses of Update attribute. The default is that
+   --  this warning is enabled. Modified by use of -gnatw.t/.T.
+
+   Warn_On_Suspicious_Modulus_Value : Boolean renames F (X.Warn_On_Suspicious_Modulus_Value);
+   --  Set to True to generate warnings for suspicious modulus values, as well
+   --  as negative literals of a modular type. The default is that this warning
+   --  is enabled. Modified by -gnatw.m/.M.
+
+   Warn_On_Unchecked_Conversion : Boolean renames F (X.Warn_On_Unchecked_Conversion);
+   --  Set to True to generate warnings for unchecked conversions that may have
+   --  non-portable semantics (e.g. because sizes of types differ). Modified
+   --  by use of -gnatwz/Z.
+
+   Warn_On_Unknown_Compile_Time_Warning : Boolean renames F (X.Warn_On_Unknown_Compile_Time_Warning);
+   --  Warn on a pragma Compile_Time_Warning whose condition has a value that
+   --  is not known at compile time. On by default, modified by use
+   --  of -gnatw_c/_C and set as part of -gnatwa.
+
+   Warn_On_Unordered_Enumeration_Type : Boolean renames F (X.Warn_On_Unordered_Enumeration_Type);
+   --  Set to True to generate warnings for inappropriate uses (comparisons
+   --  and explicit ranges) on unordered enumeration types (which includes
+   --  all enumeration types for which pragma Ordered is not given). The
+   --  default is that this warning is disabled. Modified by -gnat.u/.U.
+
+   Warn_On_Unrecognized_Pragma : Boolean renames F (X.Warn_On_Unrecognized_Pragma);
+   --  Set to True to generate warnings for unrecognized pragmas. The default
+   --  is that this warning is enabled. Modified by use of -gnatwg/G.
+
+   Warn_On_Unrepped_Components : Boolean renames F (X.Warn_On_Unrepped_Components);
+   --  Set to True to generate warnings for the case of components of record
+   --  which have a record representation clause but this component does not
+   --  have a component clause. Modified by use of -gnatw.c/.C.
+
+   Warn_On_Warnings_Off : Boolean renames F (X.Warn_On_Warnings_Off);
+   --  Set to True to generate warnings for use of Pragma Warnings (Off, ent),
+   --  where either the pragma is never used, or it could be replaced by a
+   --  pragma Unmodified or Unreferenced. Also generates warnings for pragma
+   --  Warning (Off, string) which either has no matching pragma Warning On,
+   --  or where no warning has been suppressed by the use of the pragma.
+   --  Modified by use of -gnatw.w/.W.
+   pragma Style_Checks ("M79");
+
    -----------------------------------
    -- Saving and Restoring Warnings --
    -----------------------------------
 
-   --  Type used to save and restore warnings
-
-   type Warning_Record is record
-      Address_Clause_Overlay_Warnings      : Boolean;
-      Check_Unreferenced                   : Boolean;
-      Check_Unreferenced_Formals           : Boolean;
-      Check_Withs                          : Boolean;
-      Constant_Condition_Warnings          : Boolean;
-      Elab_Info_Messages                   : Boolean;
-      Elab_Warnings                        : Boolean;
-      Implementation_Unit_Warnings         : Boolean;
-      Ineffective_Inline_Warnings          : Boolean;
-      List_Body_Required_Info              : Boolean;
-      List_Inherited_Aspects               : Boolean;
-      No_Warn_On_Non_Local_Exception       : Boolean;
-      Warning_Doc_Switch                   : Boolean;
-      Warn_On_Ada_2005_Compatibility       : Boolean;
-      Warn_On_Ada_2012_Compatibility       : Boolean;
-      Warn_On_All_Unread_Out_Parameters    : Boolean;
-      Warn_On_Anonymous_Allocators         : Boolean;
-      Warn_On_Assertion_Failure            : Boolean;
-      Warn_On_Assumed_Low_Bound            : Boolean;
-      Warn_On_Atomic_Synchronization       : Boolean;
-      Warn_On_Bad_Fixed_Value              : Boolean;
-      Warn_On_Biased_Representation        : Boolean;
-      Warn_On_Constant                     : Boolean;
-      Warn_On_Deleted_Code                 : Boolean;
-      Warn_On_Dereference                  : Boolean;
-      Warn_On_Export_Import                : Boolean;
-      Warn_On_Hiding                       : Boolean;
-      Warn_On_Late_Primitives              : Boolean;
-      Warn_On_Modified_Unread              : Boolean;
-      Warn_On_No_Value_Assigned            : Boolean;
-      Warn_On_Non_Local_Exception          : Boolean;
-      Warn_On_Object_Renames_Function      : Boolean;
-      Warn_On_Obsolescent_Feature          : Boolean;
-      Warn_On_Overlap                      : Boolean;
-      Warn_On_Overridden_Size              : Boolean;
-      Warn_On_Parameter_Order              : Boolean;
-      Warn_On_Pedantic_Checks              : Boolean;
-      Warn_On_Questionable_Layout          : Boolean;
-      Warn_On_Questionable_Missing_Parens  : Boolean;
-      Warn_On_Record_Holes                 : Boolean;
-      Warn_On_Ignored_Equality             : Boolean;
-      Warn_On_Component_Order              : Boolean;
-      Warn_On_Redundant_Constructs         : Boolean;
-      Warn_On_Reverse_Bit_Order            : Boolean;
-      Warn_On_Size_Alignment               : Boolean;
-      Warn_On_Standard_Redefinition        : Boolean;
-      Warn_On_Suspicious_Contract          : Boolean;
-      Warn_On_Suspicious_Modulus_Value     : Boolean;
-      Warn_On_Unchecked_Conversion         : Boolean;
-      Warn_On_Unknown_Compile_Time_Warning : Boolean;
-      Warn_On_Unordered_Enumeration_Type   : Boolean;
-      Warn_On_Unrecognized_Pragma          : Boolean;
-      Warn_On_Unrepped_Components          : Boolean;
-      Warn_On_Warnings_Off                 : Boolean;
-   end record;
-
-   function Save_Warnings return Warning_Record;
+   function Save_Warnings return Warnings_State;
    --  Returns current settings of warnings
 
-   procedure Restore_Warnings (W : Warning_Record);
+   procedure Restore_Warnings (W : Warnings_State);
    --  Restores current settings of warning flags from W
 
    -----------------
    -- Subprograms --
    -----------------
 
-   function Set_Warning_Switch (C : Character) return Boolean;
-   --  This function sets the warning switch or switches corresponding to the
-   --  given character. It is used to process a -gnatw switch on the command
-   --  line, or a character in a string literal in pragma Warnings. Returns
-   --  True for valid warning character C, False for invalid character.
-
-   function Set_Dot_Warning_Switch (C : Character) return Boolean;
-   --  This function sets the warning switch or switches corresponding to the
-   --  given character preceded by a dot. Used to process a -gnatw. switch on
-   --  the command line or .C in a string literal in pragma Warnings. Returns
-   --  True for valid warning character C, False for invalid character.
-
-   function Set_Underscore_Warning_Switch (C : Character) return Boolean;
-   --  This function sets the warning switch or switches corresponding to the
-   --  given character preceded by an underscore. Used to process a -gnatw_
-   --  switch on the command line or _C in a string literal in pragma Warnings.
-   --  Returns True for valid warnings character C, False for invalid
-   --  character.
+   type Warning_Family is
+     --  The "family" indicates the form of warning switch:
+     (Plain, -- form "-gnatwx"
+      '.',   -- form "-gnatw.x"
+      '_');  -- form "-gnatw_x"
+     --  where "x" is a lowercase letter that enables a particular warning.
+     --  Typically, uppercase of "x" disables the warning, but there are some
+     --  switches that do not follow that pattern.
+
+   function Set_Warning_Switch
+     (Family : Warning_Family; C : Character) return Boolean;
+   --  Set the warning switch or switches corresponding to the given family and
+   --  character. Returns True for valid warning switch, False for invalid.
+   --  Called for -gnatw... switches, and for pragma Warnings.
 
    procedure Set_GNAT_Mode_Warnings;
-   --  This is called in -gnatg mode to set the warnings for gnat mode. It is
-   --  also used to set the proper warning statuses for -gnatw.g. Note that
-   --  this set of warnings is neither a subset nor a superset of -gnatwa, it
-   --  enables warnings that are not included in -gnatwa and disables warnings
-   --  that are included in -gnatwa (such as Warn_On_Implementation_Units, that
-   --  we clearly want to be False for units built with -gnatg).
+   --  Called for -gnatg and -gnatw.g to set GNAT mode warnings. This set of
+   --  warnings is neither a subset nor a superset of -gnatwa.
 
 end Warnsw;