From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 34F9F385737D; Fri, 4 Nov 2022 13:55:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34F9F385737D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667570124; bh=pfca5lAabH9BGG1x/QXnmCr1Eo2WLl4pyFzPyNvB648=; h=From:To:Subject:Date:From; b=rMYjT8a4gy6oX5NR8X/L8XZMsyYM8ioGA06i+bK5s2k/EoVNAy5VCFIR71Ci0rNQQ 0GjRw7O2NG5mEdNToTfKVtDD1Jugz95foBB3vxeJxsskoXz3GOIEHr9uPEYl/5L/9Z l6mQN1sLNvxmym8HXUwwfggTFhK+G8n2L+Oro1Ks= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3679] ada: Cleanup code for unreferenced variables X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 72baa4e2b7f8dfdb2c49950e12a397ef00d3bc16 X-Git-Newrev: 31392801794f057dab9df4b3f4cd7b516210c199 Message-Id: <20221104135524.34F9F385737D@sourceware.org> Date: Fri, 4 Nov 2022 13:55:24 +0000 (GMT) List-Id: https://gcc.gnu.org/g:31392801794f057dab9df4b3f4cd7b516210c199 commit r13-3679-g31392801794f057dab9df4b3f4cd7b516210c199 Author: Piotr Trojanek Date: Tue Aug 23 15:59:32 2022 +0200 ada: Cleanup code for unreferenced variables Further cleanups related to warnings about unreferenced objects. gcc/ada/ * sem_warn.adb (Check_References): Remove useless query for "spec" of a variable; refactor nested if-statements into a single condition. Diff: --- gcc/ada/sem_warn.adb | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 423754f5df8..a7f220bfbc7 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -1221,7 +1221,7 @@ package body Sem_Warn is elsif Warn_On_Constant and then Ekind (E1) = E_Variable and then Has_Initial_Value (E1) - and then Never_Set_In_Source_Check_Spec (E1) + and then Never_Set_In_Source (E1) and then not Generic_Package_Spec_Entity (E1) then -- A special case, if this variable is volatile and not @@ -1248,24 +1248,15 @@ package body Sem_Warn is -- Here we give the warning if referenced and no pragma -- Unreferenced or Unmodified is present. - else - -- Variable case - - if Ekind (E1) = E_Variable then - if Referenced_Check_Spec (E1) - and then not Has_Pragma_Unreferenced_Check_Spec (E1) - and then not Has_Pragma_Unmodified_Check_Spec (E1) - then - if not Warnings_Off_E1 - and then not Has_Junk_Name (E1) - then - Error_Msg_N -- CODEFIX - ("?k?& is not modified, " - & "could be declared constant!", - E1); - end if; - end if; - end if; + elsif Referenced (E1) + and then not Has_Unreferenced (E1) + and then not Has_Unmodified (E1) + and then not Warnings_Off_E1 + and then not Has_Junk_Name (E1) + then + Error_Msg_N -- CODEFIX + ("?k?& is not modified, could be declared constant!", + E1); end if; -- Other cases of a variable or parameter never set in source