aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2022-11-07 09:25:31 -0500
committerMarc Poulhiès <poulhies@adacore.com>2022-11-14 14:46:51 +0100
commit438f878718f81302205b5241dd325bb841c8c92c (patch)
tree257239eb0a0285effb6af91c9e650d8275619a73 /gcc
parent0e194d289d4d1c9aa16d14c4b94caf11c2506da3 (diff)
downloadgcc-438f878718f81302205b5241dd325bb841c8c92c.zip
gcc-438f878718f81302205b5241dd325bb841c8c92c.tar.gz
gcc-438f878718f81302205b5241dd325bb841c8c92c.tar.bz2
ada: Remove incorrect comments about initialization
Cleanup only; no change in behavior. This patch removes and rewrites some comments regarding initialization. These initializions are needed, so there's no need to apologize for initializing these variables. Note that -gnatVa is not relevant; reads of uninitialized variables are wrong, whether or not we get caught. gcc/ada/ * atree.ads: Remove some comments. * err_vars.ads: Likewise. * scans.ads: Likewise. * sinput.ads: Likewise. * checks.ads: Likewise. Also add a "???" comment indicating an obsolete comment that is too difficult to correct at this time. * sem_attr.adb: Minor comment rewrite.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/atree.ads6
-rw-r--r--gcc/ada/checks.ads25
-rw-r--r--gcc/ada/err_vars.ads7
-rw-r--r--gcc/ada/scans.ads27
-rw-r--r--gcc/ada/sem_attr.adb2
-rw-r--r--gcc/ada/sinput.ads2
6 files changed, 25 insertions, 44 deletions
diff --git a/gcc/ada/atree.ads b/gcc/ada/atree.ads
index 0c809f5..cc66ab3 100644
--- a/gcc/ada/atree.ads
+++ b/gcc/ada/atree.ads
@@ -148,7 +148,6 @@ package Atree is
-- This is a count of errors that are serious enough to stop expansion,
-- and hence to prevent generation of an object file even if the
-- switch -gnatQ is set. Initialized to zero at the start of compilation.
- -- Initialized for -gnatVa use, see comment above.
-- WARNING: There is a matching C declaration of this variable in fe.h
@@ -156,12 +155,11 @@ package Atree is
-- Number of errors detected so far. Includes count of serious errors and
-- non-serious errors, so this value is always greater than or equal to the
-- Serious_Errors_Detected value. Initialized to zero at the start of
- -- compilation. Initialized for -gnatVa use, see comment above.
+ -- compilation.
Warnings_Detected : Nat := 0;
-- Number of warnings detected. Initialized to zero at the start of
- -- compilation. Initialized for -gnatVa use, see comment above. This
- -- count includes the count of style and info messages.
+ -- compilation. This count includes the count of style and info messages.
Warning_Info_Messages : Nat := 0;
-- Number of info messages generated as warnings. Info messages are never
diff --git a/gcc/ada/checks.ads b/gcc/ada/checks.ads
index 48678cd..a7d05a3 100644
--- a/gcc/ada/checks.ads
+++ b/gcc/ada/checks.ads
@@ -776,12 +776,14 @@ package Checks is
-- itself lead to erroneous or unpredictable execution, or to
-- other objects becoming abnormal.
- -- We quote the rules in full here since they are quite delicate. Most
- -- of the time, we can just compute away with wrong values, and get a
- -- possibly wrong result, which is well within the range of allowed
- -- implementation defined behavior. The two tricky cases are subscripted
- -- array assignments, where we don't want to do wild stores, and case
- -- statements where we don't want to do wild jumps.
+ -- We quote the rules in full here since they are quite delicate.
+ -- (???The rules quoted here are obsolete; see the GNAT User's Guide for a
+ -- description of all the -gnatV switches.) Most of the time, we can just
+ -- compute away with wrong values, and get a possibly wrong result, which
+ -- is well within the range of allowed implementation defined behavior. The
+ -- two tricky cases are subscripted array assignments, where we don't want
+ -- to do wild stores, and case statements where we don't want to do wild
+ -- jumps.
-- In GNAT, we control validity checking with a switch -gnatV that can take
-- three parameters, n/d/f for None/Default/Full. These modes have the
@@ -799,15 +801,8 @@ package Checks is
-- alternatives will be executed. Wild jumps cannot result even
-- in this mode, since we always do a range check
- -- For subscripted array assignments, wild stores will result in
- -- the expected manner when addresses are calculated using values
- -- of subscripts that are out of range.
-
- -- It could perhaps be argued that this mode is still conformant with
- -- the letter of the RM, since implementation defined is a rather
- -- broad category, but certainly it is not in the spirit of the
- -- RM requirement, since wild stores certainly seem to be a case of
- -- erroneous behavior.
+ -- For subscripted array assignments, wild stores can result in
+ -- overwriting arbitrary memory locations.
-- Default (default standard RM-compatible validity checking)
diff --git a/gcc/ada/err_vars.ads b/gcc/ada/err_vars.ads
index 79d5f31..66c4bb0 100644
--- a/gcc/ada/err_vars.ads
+++ b/gcc/ada/err_vars.ads
@@ -32,12 +32,6 @@ with Uintp; use Uintp;
package Err_Vars is
- -- All of these variables are set when needed, so they do not need to be
- -- initialized. However, there is code that saves and restores existing
- -- values, which may malfunction in -gnatVa mode if the variable has never
- -- been initialized, so we initialize some variables to avoid exceptions
- -- from invalid values in such cases.
-
-- Note on error counts (Serious_Errors_Detected, Total_Errors_Detected,
-- Warnings_Detected, Warning_Info_Messages, Report_Info_Messages). These
-- counts might more logically appear in this unit, but we place them
@@ -68,7 +62,6 @@ package Err_Vars is
-- resulting from illegalities, and also for substitution of more
-- appropriate error messages from higher semantic levels. It is
-- a counter so that the increment/decrement protocol nests neatly.
- -- Initialized for -gnatVa use, see comment above.
Error_Msg_Exception : exception;
-- Exception raised if Raise_Exception_On_Error is true
diff --git a/gcc/ada/scans.ads b/gcc/ada/scans.ads
index dbe9e5a..ddb4c3e 100644
--- a/gcc/ada/scans.ads
+++ b/gcc/ada/scans.ads
@@ -358,38 +358,35 @@ package Scans is
-- Note: these variables can only be referenced during the parsing of a
-- file. Reference to any of them from Sem or the expander is wrong.
- -- These variables are initialized as required by Scn.Initialize_Scanner,
- -- and should not be referenced before such a call. However, there are
- -- situations in which these variables are saved and restored, and this
- -- may happen before the first Initialize_Scanner call, resulting in the
- -- assignment of invalid values. To avoid this, and allow building with
- -- the -gnatVa switch, we initialize some variables to known valid values.
-
- Scan_Ptr : Source_Ptr := No_Location; -- init for -gnatVa
+ -- These variables are initialized by Scn.Initialize_Scanner, and should
+ -- not be referenced before such a call, except for saving and restoring
+ -- them.
+
+ Scan_Ptr : Source_Ptr := No_Location;
-- Current scan pointer location. After a call to Scan, this points
-- just past the end of the token just scanned.
- Token : Token_Type := No_Token; -- init for -gnatVa
+ Token : Token_Type := No_Token;
-- Type of current token
- Token_Ptr : Source_Ptr := No_Location; -- init for -gnatVa
+ Token_Ptr : Source_Ptr := No_Location;
-- Pointer to first character of current token
- Current_Line_Start : Source_Ptr := No_Location; -- init for -gnatVa
+ Current_Line_Start : Source_Ptr := No_Location;
-- Pointer to first character of line containing current token
- Start_Column : Column_Number := No_Column_Number; -- init for -gnatVa
+ Start_Column : Column_Number := No_Column_Number;
-- Starting column number (zero origin) of the first non-blank character
-- on the line containing the current token. This is used for error
-- recovery circuits which depend on looking at the column line up.
- Type_Token_Location : Source_Ptr := No_Location; -- init for -gnatVa
+ Type_Token_Location : Source_Ptr := No_Location;
-- Within a type declaration, gives the location of the TYPE keyword that
-- opened the type declaration. Used in checking the end column of a record
-- declaration, which can line up either with the TYPE keyword, or with the
-- start of the line containing the RECORD keyword.
- Checksum : Word := 0; -- init for -gnatVa
+ Checksum : Word := 0;
-- Used to accumulate a CRC representing the tokens in the source
-- file being compiled. This CRC includes only program tokens, and
-- excludes comments.
@@ -399,7 +396,7 @@ package Scans is
-- limited view of a package, i.e. visible type names and related
-- tagged indicators.
- First_Non_Blank_Location : Source_Ptr := No_Location; -- init for -gnatVa
+ First_Non_Blank_Location : Source_Ptr := No_Location;
-- Location of first non-blank character on the line containing the
-- current token (i.e. the location of the character whose column number
-- is stored in Start_Column).
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 5166b4b..f7c03ab 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -1138,7 +1138,7 @@ package body Sem_Attr is
-- pointer can be used to modify the variable, and we might
-- not detect this, leading to some junk warnings.
- -- We only do this for source references, since otherwise
+ -- We do this only for source references, since otherwise
-- we can suppress warnings, e.g. from the unrestricted
-- access generated for validity checks in -gnatVa mode.
diff --git a/gcc/ada/sinput.ads b/gcc/ada/sinput.ads
index af2fec7..febb2ef 100644
--- a/gcc/ada/sinput.ads
+++ b/gcc/ada/sinput.ads
@@ -409,8 +409,6 @@ package Sinput is
Current_Source_File : Source_File_Index := No_Source_File;
-- Source_File table index of source file currently being scanned.
- -- Initialized so that some tools (such as gprbuild) can be built with
- -- -gnatVa and pragma Initialize_Scalars without problems.
Current_Source_Unit : Unit_Number_Type := No_Unit;
-- Unit number of source file currently being scanned. Initialized to