public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Clean up support for validity checks in the compiler
@ 2019-07-04  8:50 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2019-07-04  8:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

[-- Attachment #1: Type: text/plain, Size: 609 bytes --]

This removes old code in the parser that serves no useful purpose and
fixes minor issues in the Validsw package.  No functional changes.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-07-04  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* gnat1drv.adb (Adjust_Global_Switches): Use proper interface to
	set the validity settings in CodePeer mode.
	* par-load.adb (Load): Remove all code dealing with validity
	settings.
	* validsw.ads (Validity_Check_Copies): Alphabetize.
	* validsw.adb (Reset_Validity_Check_Options): Set all options to
	off.
	(Save_Validity_Check_Options): Save all options.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 8402 bytes --]

--- gcc/ada/gnat1drv.adb
+++ gcc/ada/gnat1drv.adb
@@ -379,8 +379,7 @@ procedure Gnat1drv is
          --  enough useful info.
 
          Reset_Validity_Check_Options;
-         Validity_Check_Default       := True;
-         Validity_Check_Copies        := True;
+         Set_Validity_Check_Options ("dc");
          Check_Validity_Of_Parameters := False;
 
          --  Turn off style check options and ignore any style check pragmas

--- gcc/ada/par-load.adb
+++ gcc/ada/par-load.adb
@@ -36,7 +36,6 @@ with Uname;    use Uname;
 with Osint;    use Osint;
 with Sinput.L; use Sinput.L;
 with Stylesw;  use Stylesw;
-with Validsw;  use Validsw;
 
 with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
 
@@ -61,10 +60,6 @@ procedure Load is
    Save_Style_Checks : Style_Check_Options;
    --  Save style check so it can be restored later
 
-   Save_Validity_Check  : Boolean;
-   Save_Validity_Checks : Validity_Check_Options;
-   --  Save validity check so it can be restored later
-
    With_Cunit : Node_Id;
    --  Compilation unit node for withed unit
 
@@ -134,9 +129,6 @@ begin
    Save_Style_Check_Options (Save_Style_Checks);
    Save_Style_Check := Opt.Style_Check;
 
-   Save_Validity_Check_Options (Save_Validity_Checks);
-   Save_Validity_Check := Opt.Validity_Checks_On;
-
    --  If main unit, set Main_Unit_Entity (this will get overwritten if
    --  the main unit has a separate spec, that happens later on in Load)
 
@@ -318,11 +310,10 @@ begin
      or else Nkind (Unit (Curunit)) in N_Generic_Instantiation
      or else Nkind (Unit (Curunit)) in N_Renaming_Declaration
    then
-      --  Turn style and validity checks off for parent unit
+      --  Turn style checks off for parent unit
 
       if not GNAT_Mode then
          Reset_Style_Check_Options;
-         Reset_Validity_Check_Options;
       end if;
 
       Spec_Name := Get_Parent_Spec_Name (Unit_Name (Cur_Unum));
@@ -356,11 +347,10 @@ begin
       end if;
    end if;
 
-   --  Now we load with'ed units, with style/validity checks turned off
+   --  Now we load with'ed units, with style checks turned off
 
    if not GNAT_Mode then
       Reset_Style_Check_Options;
-      Reset_Validity_Check_Options;
    end if;
 
    --  Load the context items in two rounds: the first round handles normal
@@ -470,6 +460,4 @@ begin
 
    Set_Style_Check_Options (Save_Style_Checks);
    Opt.Style_Check := Save_Style_Check;
-   Set_Validity_Check_Options (Save_Validity_Checks);
-   Opt.Validity_Checks_On := Save_Validity_Check;
 end Load;

--- gcc/ada/validsw.adb
+++ gcc/ada/validsw.adb
@@ -36,11 +36,12 @@ package body Validsw is
    begin
       Validity_Check_Components     := False;
       Validity_Check_Copies         := False;
-      Validity_Check_Default        := True;
+      Validity_Check_Default        := False;
       Validity_Check_Floating_Point := False;
       Validity_Check_In_Out_Params  := False;
       Validity_Check_In_Params      := False;
       Validity_Check_Operands       := False;
+      Validity_Check_Parameters     := False;
       Validity_Check_Returns        := False;
       Validity_Check_Subscripts     := False;
       Validity_Check_Tests          := False;
@@ -73,14 +74,14 @@ package body Validsw is
          Options (K) := ' ';
       end loop;
 
-      Add ('n', not Validity_Check_Default);
-
-      Add ('c', Validity_Check_Copies);
       Add ('e', Validity_Check_Components);
+      Add ('c', Validity_Check_Copies);
+      Add ('d', Validity_Check_Default);
       Add ('f', Validity_Check_Floating_Point);
       Add ('i', Validity_Check_In_Params);
       Add ('m', Validity_Check_In_Out_Params);
       Add ('o', Validity_Check_Operands);
+      Add ('p', Validity_Check_Parameters);
       Add ('r', Validity_Check_Returns);
       Add ('s', Validity_Check_Subscripts);
       Add ('t', Validity_Check_Tests);

--- gcc/ada/validsw.ads
+++ gcc/ada/validsw.ads
@@ -40,33 +40,33 @@ package Validsw is
    --  or in the argument of a Validity_Checks pragma to activate the option.
    --  The corresponding upper case letter deactivates the option.
 
+   Validity_Check_Components : Boolean := False;
+   --  Controls validity checking for assignment to elementary components of
+   --  records. If this switch is set to True using -gnatVe, or an 'e' in the
+   --  argument of Validity_Checks pragma, then the right-hand side of an
+   --  assignment to such a component is checked for validity.
+
    Validity_Check_Copies : Boolean := False;
    --  Controls the validity checking of copies. If this switch is set to
-   --  true using -gnatVc, or a 'c' in the argument of a Validity_Checks
-   --  pragma, then the right side of assignments and also initializing
+   --  True using -gnatVc, or a 'c' in the argument of a Validity_Checks
+   --  pragma, then the right-hand side of assignments and also initializing
    --  expressions in object declarations are checked for validity.
 
-   Validity_Check_Components : Boolean := False;
-   --  Controls validity checking for assignment to elementary components of
-   --  records. If this switch is set true using -gnatVe, or an 'e' in the
-   --  argument of Validity_Checks pragma, then the right hand of an assignment
-   --  to such a component is checked for validity.
-
    Validity_Check_Default : Boolean := True;
    --  Controls default (reference manual) validity checking. If this switch is
    --  set to True using -gnatVd or a 'd' in the argument of a Validity_Checks
-   --  pragma (or the initial default value is used, set True), then left side
-   --  subscripts and case statement arguments are checked for validity. This
-   --  switch is also set by default if no -gnatV switch is used and no
+   --  pragma (or the initial default value is used, set True), then left-hand
+   --  side subscripts and case statement arguments are checked for validity.
+   --  This switch is also set by default if no -gnatV switch is used and no
    --  Validity_Checks pragma is processed.
 
    Validity_Check_Floating_Point : Boolean := False;
-   --  Normally validity checking applies only to discrete values (integer
-   --  and enumeration types). If this switch is set to True using -gnatVf
-   --  or an 'f' in the argument of a Validity_Checks pragma, then floating-
-   --  point values are also checked. The context in which such checks
-   --  occur depends on other flags, e.g. if Validity_Check_Copies is also
-   --  set then floating-point values on the right side of an assignment
+   --  Normally validity checking applies only to discrete values (integer and
+   --  enumeration types). If this switch is set to True using -gnatVf or an
+   --  'f' in the argument of a Validity_Checks pragma, then floating-point
+   --  values are also checked. If the context in which such checks occur
+   --  depends on other flags, e.g. if Validity_Check_Copies is also set,
+   --  then floating-point values on the right-hand side of an assignment
    --  will be validity checked.
 
    Validity_Check_In_Out_Params : Boolean := False;
@@ -103,13 +103,13 @@ package Validsw is
    --  pragma, then the expression in a RETURN statement is validity checked.
 
    Validity_Check_Subscripts : Boolean := False;
-   --  Controls validity checking of subscripts. If this switch is set to
-   --  True using -gnatVs, or an 's' in the argument of a Validity_Checks
-   --  pragma, then all subscripts are checked for validity. Note that left
-   --  side subscript checking is controlled also by Validity_Check_Default.
-   --  If Validity_Check_Subscripts is True, then all subscripts are checked,
-   --  otherwise if Validity_Check_Default is True, then left side subscripts
-   --  are checked, otherwise no subscripts are checked.
+   --  Controls validity checking of subscripts. If this switch is set to True
+   --  using -gnatVs, or an 's' in the argument of a Validity_Checks pragma,
+   --  then all subscripts are checked for validity. Note that left-hand side
+   --  subscript checking is also controlled by Validity_Check_Default. If
+   --  Validity_Check_Subscripts is True, then all subscripts are checked,
+   --  otherwise if Validity_Check_Default is True, then left-hand side
+   --  subscripts are checked; otherwise no subscripts are checked.
 
    Validity_Check_Tests : Boolean := False;
    --  Controls validity checking of tests that occur in conditions (i.e. the


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-07-04  8:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04  8:50 [Ada] Clean up support for validity checks in the compiler Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).