From patchwork Mon Nov 14 13:51:46 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: 60584 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 9AB3C3844002 for ; Mon, 14 Nov 2022 13:52:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AB3C3844002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668433941; bh=q+vDyyppSvc8HmHs1Vj4kuQH6N3vxoK85ypQ+svTYqk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=bqISX8+3aQm1oKmGFXAyDdtbPz+wttcCoPHeVcMZtpabdTlOmcyI0RlJIuj3dFGWS ktYzQUkE0xNbFF2s+0l2iIMpJWSTSQeTU4LrXPtcf4eeX/YQsPzDrKcPwj0NT7ZHuV cPSINApNLlul1TzVHEXvJm82T7WzlY9s8xCeilqk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 3CBDC385843D for ; Mon, 14 Nov 2022 13:51:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3CBDC385843D Received: by mail-wm1-x329.google.com with SMTP id ja4-20020a05600c556400b003cf6e77f89cso9378296wmb.0 for ; Mon, 14 Nov 2022 05:51:50 -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=q+vDyyppSvc8HmHs1Vj4kuQH6N3vxoK85ypQ+svTYqk=; b=4HDzRj8vOkbKXDpic7DQ0C2rwNY7nb1DMZistBvL248E+L8WdP67PX2g9MIpXG96Q2 L2jGrxjHfpD05gqQM4JAHUZ2xSuY0b8kf80+nqbgwquDTVojOnEjcRgIoFlTqrVWnsZp 4cYSMKqTEUyj3nOpE1rGUjQgwWm4BHaUzFk6A6bZbRHKcty530+iooNC08Siv/V7NYVW FKY3mtKKp6df0WEyySP+olBPnYiXQEndA6nbjN1Gx1uVlpicBp0Wwb2ixbylkuZX6s9+ YC3hczv03hZ6VjCbdajgDqSFYyZWIcxGzDFYs/Nk2S+RCPGqsGvexCs1kyDdrBS9wh6L jRWg== X-Gm-Message-State: ANoB5pm3IinGAw9Eyg2GWpS9podRuDoRCIL6xxNKK9QvIIsG6WJjMcPI 4rsJaA2FjKVfCTMXSR1QHj3oe5mUEyvmxQ== X-Google-Smtp-Source: AA0mqf7xzJS7QXwIbiQint6hKKbQvfxm6nTQGLx5DJN0MVXpa69sV+xoc7Qh4LwH+tBJ/6Mv6lMFMQ== X-Received: by 2002:a05:600c:5549:b0:3cf:b73f:c062 with SMTP id iz9-20020a05600c554900b003cfb73fc062mr7887488wmb.204.1668433909047; Mon, 14 Nov 2022 05:51:49 -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 o18-20020adfe812000000b00228692033dcsm9613677wrm.91.2022.11.14.05.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 05:51:48 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [COMMITTED] ada: Improve location of error messages in instantiations Date: Mon, 14 Nov 2022 14:51:46 +0100 Message-Id: <20221114135146.52584-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, WEIRD_QUOTING 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: Yannick Moy When flag -gnatdF is used, source code lines are displayed to point the location of errors. The code of the instantiation was displayed in case of errors inside generic instances, which was not precise. Now the code inside the generic is displayed. gcc/ada/ * errout.adb (Error_Msg_Internal): Store span for Optr field, and adapt to new type of Optr. (Finalize. Output_JSON_Message, Remove_Warning_Messages): Adapt to new type of Optr. (Output_Messages): Use Optr instead of Sptr to display code snippet closer to error. * erroutc.adb (dmsg): Adapt to new type of Optr. * erroutc.ads (Error_Msg_Object): Make Optr a span like Sptr. * errutil.adb (Error_Msg): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/errout.adb | 19 ++++++++++--------- gcc/ada/erroutc.adb | 2 +- gcc/ada/erroutc.ads | 2 +- gcc/ada/errutil.adb | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 19ea1553260..dcd21778db3 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -1215,7 +1215,7 @@ package body Errout is Next => No_Error_Msg, Prev => No_Error_Msg, Sptr => Span, - Optr => Optr, + Optr => Opan, Insertion_Sloc => (if Has_Insertion_Line then Error_Msg_Sloc else No_Location), Sfile => Get_Source_File_Index (Sptr), @@ -1284,7 +1284,7 @@ package body Errout is or else (Sptr = Errors.Table (Last_Error_Msg).Sptr.Ptr and then - Optr > Errors.Table (Last_Error_Msg).Optr)) + Optr > Errors.Table (Last_Error_Msg).Optr.Ptr)) then Prev_Msg := Last_Error_Msg; Next_Msg := No_Error_Msg; @@ -1302,7 +1302,8 @@ package body Errout is then exit when Sptr < Errors.Table (Next_Msg).Sptr.Ptr or else (Sptr = Errors.Table (Next_Msg).Sptr.Ptr - and then Optr < Errors.Table (Next_Msg).Optr); + and then + Optr < Errors.Table (Next_Msg).Optr.Ptr); end if; Prev_Msg := Next_Msg; @@ -1681,8 +1682,8 @@ package body Errout is (Warning_Specifically_Suppressed (CE.Sptr.Ptr, CE.Text, Tag) /= No_String or else - Warning_Specifically_Suppressed (CE.Optr, CE.Text, Tag) /= - No_String) + Warning_Specifically_Suppressed (CE.Optr.Ptr, CE.Text, Tag) + /= No_String) then Delete_Warning (Cur); @@ -2232,9 +2233,9 @@ package body Errout is Write_Str (",""locations"":["); Write_JSON_Span (Errors.Table (E)); - if Errors.Table (E).Optr /= Errors.Table (E).Sptr.Ptr then + if Errors.Table (E).Optr.Ptr /= Errors.Table (E).Sptr.Ptr then Write_Str (",{""caret"":"); - Write_JSON_Location (Errors.Table (E).Optr); + Write_JSON_Location (Errors.Table (E).Optr.Ptr); Write_Str ("}"); end if; @@ -2954,7 +2955,7 @@ package body Errout is else SGR_Error); begin Write_Source_Code_Lines - (Errors.Table (E).Sptr, SGR_Span); + (Errors.Table (E).Optr, SGR_Span); end; end if; end if; @@ -3329,7 +3330,7 @@ package body Errout is -- Don't remove if location does not match - and then Errors.Table (E).Optr = Loc + and then Errors.Table (E).Optr.Ptr = Loc -- Don't remove if not warning/info message. Note that we do -- not remove style messages here. They are warning messages diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb index 9ecc97fb46d..7766c972730 100644 --- a/gcc/ada/erroutc.adb +++ b/gcc/ada/erroutc.adb @@ -324,7 +324,7 @@ package body Erroutc is Write_Str (" Optr = "); - Write_Location (E.Optr); + Write_Location (E.Optr.Ptr); Write_Eol; w (" Line = ", Int (E.Line)); diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads index 7957228a91b..c992bbaa183 100644 --- a/gcc/ada/erroutc.ads +++ b/gcc/ada/erroutc.ads @@ -209,7 +209,7 @@ package Erroutc is -- will be posted. Note that an error placed on an instantiation will -- have Sptr pointing to the instantiation point. - Optr : Source_Ptr; + Optr : Source_Span; -- Flag location used in the call to post the error. This is the same as -- Sptr, except when an error is posted on a particular instantiation of -- a generic. In such a case, Sptr will point to the original source diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb index 921de319f39..887dc8826bf 100644 --- a/gcc/ada/errutil.adb +++ b/gcc/ada/errutil.adb @@ -208,7 +208,7 @@ package body Errutil is Prev => No_Error_Msg, Sfile => Get_Source_File_Index (Sptr), Sptr => To_Span (Sptr), - Optr => Optr, + Optr => To_Span (Optr), Insertion_Sloc => No_Location, Line => Get_Physical_Line_Number (Sptr), Col => Get_Column_Number (Sptr),