summaryrefslogtreecommitdiff
path: root/gcc/ada/prj-err.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/prj-err.adb')
-rw-r--r--gcc/ada/prj-err.adb51
1 files changed, 50 insertions, 1 deletions
diff --git a/gcc/ada/prj-err.adb b/gcc/ada/prj-err.adb
index 9ed4cb4df91..abe4224f098 100644
--- a/gcc/ada/prj-err.adb
+++ b/gcc/ada/prj-err.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2002-2007, Free Software Foundation, Inc. --
+-- Copyright (C) 2002-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -68,4 +68,53 @@ package body Prj.Err is
end if;
end Post_Scan;
+ ---------------
+ -- Error_Msg --
+ ---------------
+
+ procedure Error_Msg
+ (Flags : Processing_Flags;
+ Msg : String;
+ Location : Source_Ptr := No_Location;
+ Project : Project_Id := null)
+ is
+ Real_Location : Source_Ptr := Location;
+
+ begin
+ -- Display the error message in the traces so that it appears in the
+ -- correct location in the traces (otherwise error messages are only
+ -- displayed at the end and it is difficult to see when they were
+ -- triggered)
+
+ if Current_Verbosity = High then
+ Write_Line ("ERROR: " & Msg);
+ end if;
+
+ -- If location of error is unknown, use the location of the project
+
+ if Real_Location = No_Location
+ and then Project /= null
+ then
+ Real_Location := Project.Location;
+ end if;
+
+ if Real_Location = No_Location then
+ -- If still null, we are parsing a project that was created in-memory
+ -- so we shouldn't report errors for projects that the user has no
+ -- access to in any case.
+ return;
+ end if;
+
+ -- Report the error through Errutil, so that duplicate errors are
+ -- properly removed, messages are sorted, and correctly interpreted,...
+
+ Errutil.Error_Msg (Msg, Real_Location);
+
+ -- Let the application know there was an error
+
+ if Flags.Report_Error /= null then
+ Flags.Report_Error (Project, Is_Warning => Msg (Msg'First) = '?');
+ end if;
+ end Error_Msg;
+
end Prj.Err;