From patchwork Mon Nov 14 13:52:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 60595 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F34F43898C71 for ; Mon, 14 Nov 2022 13:56:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F34F43898C71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668434199; bh=cW1yQ0Z9J5etx9S5KyAaNQoQQHCtAdCa/QBkvTTVZ+4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=urCP5bZjGku/2CNzLnJDPT1O8PG5ePG5p/nehITGEI5CfcRKBG0ok4gfA1sDYsi90 JrRyk4cTajn5ZsxPzzMIcFtNJGJJZVZ7+XKg4CzQ+QOMx+xOvT7CvX215psluncOph gYemKduDPO1KfQOp4sMXLVPFh+H16a/GmuGxamko= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 135E738518B9 for ; Mon, 14 Nov 2022 13:52:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 135E738518B9 Received: by mail-wm1-x331.google.com with SMTP id o30so7532352wms.2 for ; Mon, 14 Nov 2022 05:52:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cW1yQ0Z9J5etx9S5KyAaNQoQQHCtAdCa/QBkvTTVZ+4=; b=OfHhuMqTn18tUGUuGnOfE4fGH1aFo18cYgY+foeAREbndzfoxUxM4VXjmh/ffC10iJ Ya8ZI7yVBmossB6wTEoXwCQeB892Av5u6GWzMpOrhIutJUvWt5KyzuUJw84S1d5JOjRY U9SnPYyPfAPxH60LxCg9H2voDk0siyAcaKQIyYeZ+43puuss4DRS9STry84RTExtpBSe srXYFzHcMigFm4Q9MTh53BDkyqfTUe4nAJUtgFbAEWncZsB0O/7jqHoVzb3ayTc1kI5j bDHKjn4h6kVjBXAUNmo6PUwXzVW3eWVttNyggKb1pXGFVCrCc48gmxlSOdUqkCkZFw1G 9xVw== X-Gm-Message-State: ANoB5pntRDW09SMVqEKQ9veIidjnIwCLVqIK8ij0iYTWz0furDgkQkNo jHeEm6Bg3lH8MVOcPfQiG9zAV0/vOU7pXA== X-Google-Smtp-Source: AA0mqf4VzPpqnmriWKJw/wxKla9JCwrydZ6w4pZNHASGuNiO8wZ2ts8zq+CvvdlukvspmOMJBmmIKw== X-Received: by 2002:a7b:ce86:0:b0:3cf:88d3:5685 with SMTP id q6-20020a7bce86000000b003cf88d35685mr7987486wmj.38.1668433974854; Mon, 14 Nov 2022 05:52:54 -0800 (PST) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id l26-20020a05600c2cda00b003cf774c31a0sm19343296wmc.16.2022.11.14.05.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 05:52:54 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED] ada: Remove incorrect comments about initialization Date: Mon, 14 Nov 2022 14:52:52 +0100 Message-Id: <20221114135252.53221-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Bob Duff 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/atree.ads | 6 ++---- gcc/ada/checks.ads | 25 ++++++++++--------------- gcc/ada/err_vars.ads | 7 ------- gcc/ada/scans.ads | 27 ++++++++++++--------------- gcc/ada/sem_attr.adb | 2 +- gcc/ada/sinput.ads | 2 -- 6 files changed, 25 insertions(+), 44 deletions(-) diff --git a/gcc/ada/atree.ads b/gcc/ada/atree.ads index 0c809f56435..cc66ab3777c 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 48678cd01df..a7d05a3fa39 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 79d5f319f59..66c4bb09b4c 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 dbe9e5a7242..ddb4c3efb72 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 5166b4be4e9..f7c03abe49a 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 af2fec74cf4..febb2ef781b 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