public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-1963] ada: Pass Error_Node to calls to Error_Msg in lib-load.adb
Date: Tue, 20 Jun 2023 07:46:01 +0000 (GMT)	[thread overview]
Message-ID: <20230620074601.15EA13858C5E@sourceware.org> (raw)

https://gcc.gnu.org/g:2071134b54aa4f9af01d7d6212dacf7747168448

commit r14-1963-g2071134b54aa4f9af01d7d6212dacf7747168448
Author: Ghjuvan Lacambre <lacambre@adacore.com>
Date:   Tue May 23 17:50:24 2023 +0200

    ada: Pass Error_Node to calls to Error_Msg in lib-load.adb
    
    When not passing Error_Node, Error_Msg will treat Current_Node as the
    node attached to the message. When this happens in lib-load.adb due to a
    file that cannot be loaded, Current_Node might reference a node that
    doesn't actually exist. This is a problem when using -gnatdJ and
    -fdiagnostics-format, as in this case GNAT will attempt to retrieve
    information from the node attached to the message and thus crash when
    said node is invalid.
    
    gcc/ada/
    
            * lib-load.adb (Load_Unit): Pass Error_Node to calls to Error_Msg.

Diff:
---
 gcc/ada/lib-load.adb | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/lib-load.adb b/gcc/ada/lib-load.adb
index d79ee438243..72196b437f5 100644
--- a/gcc/ada/lib-load.adb
+++ b/gcc/ada/lib-load.adb
@@ -645,11 +645,16 @@ package body Lib.Load is
                   if Is_Predefined_File_Name (Fname) then
                      Error_Msg_Unit_1 := Uname_Actual;
                      Error_Msg
-                       ("$$ is not a language defined unit", Load_Msg_Sloc);
+                       ("$$ is not a language defined unit",
+                        Load_Msg_Sloc,
+                        Error_Node);
                   else
                      Error_Msg_File_1 := Fname;
                      Error_Msg_Unit_1 := Uname_Actual;
-                     Error_Msg ("file{ does not contain unit$", Load_Msg_Sloc);
+                     Error_Msg
+                       ("file{ does not contain unit$",
+                        Load_Msg_Sloc,
+                        Error_Node);
                   end if;
 
                   Write_Dependency_Chain;
@@ -697,7 +702,8 @@ package body Lib.Load is
             end if;
 
             if Present (Error_Node) then
-               Error_Msg ("circular unit dependency", Load_Msg_Sloc);
+               Error_Msg
+                 ("circular unit dependency", Load_Msg_Sloc, Error_Node);
                Write_Dependency_Chain;
             else
                Load_Stack.Decrement_Last;
@@ -798,11 +804,14 @@ package body Lib.Load is
             then
                Error_Msg_File_1 := Unit_File_Name (Corr_Body);
                Error_Msg
-                 ("cannot compile subprogram in file {!", Load_Msg_Sloc);
+                 ("cannot compile subprogram in file {!",
+                  Load_Msg_Sloc,
+                  Error_Node);
                Error_Msg_File_1 := Unit_File_Name (Unum);
                Error_Msg
                  ("\incorrect spec in file { must be removed first!",
-                  Load_Msg_Sloc);
+                  Load_Msg_Sloc,
+                  Error_Node);
                Unum := No_Unit;
                goto Done;
             end if;
@@ -879,15 +888,21 @@ package body Lib.Load is
 
                   Error_Msg_Unit_1 := Uname_Actual;
                   Error_Msg -- CODEFIX
-                    ("$$ is not a predefined library unit", Load_Msg_Sloc);
+                    ("$$ is not a predefined library unit",
+                     Load_Msg_Sloc,
+                     Error_Node);
 
                else
                   Error_Msg_File_1 := Fname;
 
                   if Src_Ind = No_Access_To_Source_File then
-                     Error_Msg ("no read access to file{", Load_Msg_Sloc);
+                     Error_Msg
+                       ("no read access to file{",
+                        Load_Msg_Sloc,
+                        Error_Node
+                        );
                   else
-                     Error_Msg ("file{ not found", Load_Msg_Sloc);
+                     Error_Msg ("file{ not found", Load_Msg_Sloc, Error_Node);
                   end if;
                end if;

                 reply	other threads:[~2023-06-20  7:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230620074601.15EA13858C5E@sourceware.org \
    --to=dkm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).