diff options
author | Steve Baird <baird@adacore.com> | 2024-05-10 15:03:37 -0700 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-06-20 10:50:49 +0200 |
commit | cba9a6c978da6c5ef559fba9509b89551ed82812 (patch) | |
tree | 3d9217dfe86edf76dc00d934fe1eb8abe141c0a5 | |
parent | 21b54dad4789396f6877e08024c3d40eec2861d6 (diff) | |
download | gcc-cba9a6c978da6c5ef559fba9509b89551ed82812.zip gcc-cba9a6c978da6c5ef559fba9509b89551ed82812.tar.gz gcc-cba9a6c978da6c5ef559fba9509b89551ed82812.tar.bz2 |
ada: Improve preprocessor error handling.
In some cases, gnatprep would correctly emit an error message and then
incorrectly exit with a return code of zero, indicating success.
In some cases, a correct message about an error detected by the integrated
preprocessor would be accompanied by an incorrect message indicating that
a source file could not be found.
gcc/ada/
* gprep.adb (Process_Files.Process_One_File): When calling OS_Exit in an error
path, pass in a Status parameter of 1 instead of 0 (because 0
indicates success).
* lib-load.adb (Load_Main_Source): Do not emit a message about a missing source file
if other error messages were generated by calling Load_Source_File;
the file isn't missing - it failed preprocessing.
-rw-r--r-- | gcc/ada/gprep.adb | 2 | ||||
-rw-r--r-- | gcc/ada/lib-load.adb | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/gcc/ada/gprep.adb b/gcc/ada/gprep.adb index a95cd63..3cb8026 100644 --- a/gcc/ada/gprep.adb +++ b/gcc/ada/gprep.adb @@ -552,7 +552,7 @@ package body GPrep is Errutil.Finalize (Source_Type => "input"); - OS_Exit (0); + OS_Exit (1); -- Otherwise, close the output file, and we are done diff --git a/gcc/ada/lib-load.adb b/gcc/ada/lib-load.adb index 59adabc..d5ea087 100644 --- a/gcc/ada/lib-load.adb +++ b/gcc/ada/lib-load.adb @@ -313,6 +313,7 @@ package body Lib.Load is Is_Predefined_Renaming_File_Name (Fname); GNAT_Name : constant Boolean := Is_GNAT_File_Name (Fname); + Saved_Error_Count : constant Nat := Total_Errors_Detected; Version : Word := 0; begin @@ -336,7 +337,14 @@ package body Lib.Load is if Main_Source_File > No_Source_File then Version := Source_Checksum (Main_Source_File); - else + -- If we get here and Saved_Error_Count /= Total_Errors_Detected, + -- then an error occurred during preprocessing. In this case + -- we have already generated an error message during preprocessing + -- and we do not want to emit an incorrect "file foo.adb not found" + -- message here. + + elsif Saved_Error_Count = Total_Errors_Detected then + -- To avoid emitting a source location (since there is no file), -- we write a custom error message instead of using the machinery -- in errout.adb. |