From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 9466938A9425; Tue, 11 Jan 2022 13:28:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9466938A9425 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-6471] [Ada] Include generic instance names in non-visible entity errors X-Act-Checkin: gcc X-Git-Author: Justin Squirek X-Git-Refname: refs/heads/master X-Git-Oldrev: 805655c137088519751e4ca18df722355a512d88 X-Git-Newrev: 10608753db567042934872db8447f13eb15b5f8b Message-Id: <20220111132841.9466938A9425@sourceware.org> Date: Tue, 11 Jan 2022 13:28:41 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2022 13:28:41 -0000 https://gcc.gnu.org/g:10608753db567042934872db8447f13eb15b5f8b commit r12-6471-g10608753db567042934872db8447f13eb15b5f8b Author: Justin Squirek Date: Thu Dec 23 02:27:43 2021 +0000 [Ada] Include generic instance names in non-visible entity errors gcc/ada/ * sem_ch8.adb (Nvis_Messages): Add generic instance name to error message. Diff: --- gcc/ada/sem_ch8.adb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index e5b019c3019..e5756029246 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -5689,8 +5689,27 @@ package body Sem_Ch8 is null; else - Error_Msg_N -- CODEFIX - ("non-visible declaration#!", N); + -- When the entity comes from a generic instance the + -- normal error message machinery will give the line + -- number of the generic package and the location of + -- the generic instance, but not the name of the + -- the instance. + + -- So, in order to give more descriptive error messages + -- in this case, we include the name of the generic + -- package. + + if Is_Generic_Instance (Scope (Ent)) then + Error_Msg_Name_1 := Chars (Scope (Ent)); + Error_Msg_N -- CODEFIX + ("non-visible declaration from %#!", N); + + -- Otherwise print the message normally + + else + Error_Msg_N -- CODEFIX + ("non-visible declaration#!", N); + end if; if Ekind (Scope (Ent)) /= E_Generic_Package then Found := True;