From 7cbe60de258f6d09561d4fe32dac8892b52520fe Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 4 Jul 2019 08:07:19 +0000 Subject: [PATCH] [Ada] Clean up support for validity checks in the compiler This removes old code in the parser that serves no useful purpose and fixes minor issues in the Validsw package. No functional changes. 2019-07-04 Eric Botcazou 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. From-SVN: r273071 --- gcc/ada/ChangeLog | 11 +++++++++++ gcc/ada/gnat1drv.adb | 3 +-- gcc/ada/par-load.adb | 16 ++-------------- gcc/ada/validsw.adb | 9 +++++---- gcc/ada/validsw.ads | 48 ++++++++++++++++++++++++------------------------ 5 files changed, 43 insertions(+), 44 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 65aabe5..3ea8e47 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,14 @@ +2019-07-04 Eric Botcazou + + * 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. + 2019-07-04 Hristian Kirtchev * exp_ch3.adb, exp_ch4.adb, exp_ch4.ads, exp_ch5.adb, diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index 1f5817a..ded754d 100644 --- a/gcc/ada/gnat1drv.adb +++ b/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 diff --git a/gcc/ada/par-load.adb b/gcc/ada/par-load.adb index cb95500..70bc5cb 100644 --- a/gcc/ada/par-load.adb +++ b/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; diff --git a/gcc/ada/validsw.adb b/gcc/ada/validsw.adb index d08299d..ae155c3 100644 --- a/gcc/ada/validsw.adb +++ b/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); diff --git a/gcc/ada/validsw.ads b/gcc/ada/validsw.ads index 2dadc5c..5197bdf 100644 --- a/gcc/ada/validsw.ads +++ b/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 -- 2.7.4