diff options
Diffstat (limited to 'gcc/ada/errout.adb')
-rw-r--r-- | gcc/ada/errout.adb | 89 |
1 files changed, 58 insertions, 31 deletions
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 12cf828a2f2..2c783b2bddf 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -49,7 +49,6 @@ with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with Stylesw; use Stylesw; -with Targparm; use Targparm; with Uname; use Uname; package body Errout is @@ -234,6 +233,15 @@ package body Errout is begin if not Finalize_Called then raise Program_Error; + + -- In formal verification mode, errors issued when generating Why code + -- are not compilation errors, and should not result in exiting with + -- an error status. These errors are handled in the driver of the + -- verification process instead. + + elsif SPARK_Mode and not Frame_Condition_Mode then + return False; + else return Erroutc.Compilation_Errors; end if; @@ -1617,15 +1625,19 @@ package body Errout is Set_Standard_Error; end if; - -- Message giving total number of lines + -- Message giving total number of lines. Don't give this message if + -- the Main_Source line is unknown (this happens in error situations, + -- e.g. when integrated preprocessing fails). - Write_Str (" "); - Write_Int (Num_Source_Lines (Main_Source_File)); + if Main_Source_File /= No_Source_File then + Write_Str (" "); + Write_Int (Num_Source_Lines (Main_Source_File)); - if Num_Source_Lines (Main_Source_File) = 1 then - Write_Str (" line: "); - else - Write_Str (" lines: "); + if Num_Source_Lines (Main_Source_File) = 1 then + Write_Str (" line: "); + else + Write_Str (" lines: "); + end if; end if; if Total_Errors_Detected = 0 then @@ -1823,8 +1835,13 @@ package body Errout is begin Write_Eol; - Write_Header (Sfile); - Write_Eol; + + -- Only write the header if Sfile is known + + if Sfile /= No_Source_File then + Write_Header (Sfile); + Write_Eol; + end if; -- Normally, we don't want an "error messages from file" -- message when listing the entire file, so we set the @@ -1839,28 +1856,33 @@ package body Errout is Current_Error_Source_File := Sfile; end if; - for N in 1 .. Last_Source_Line (Sfile) loop - while E /= No_Error_Msg - and then Errors.Table (E).Deleted - loop - E := Errors.Table (E).Next; - end loop; + -- Only output the listing if Sfile is known, to avoid + -- crashing the compiler. + + if Sfile /= No_Source_File then + for N in 1 .. Last_Source_Line (Sfile) loop + while E /= No_Error_Msg + and then Errors.Table (E).Deleted + loop + E := Errors.Table (E).Next; + end loop; - Err_Flag := - E /= No_Error_Msg - and then Errors.Table (E).Line = N - and then Errors.Table (E).Sfile = Sfile; + Err_Flag := + E /= No_Error_Msg + and then Errors.Table (E).Line = N + and then Errors.Table (E).Sfile = Sfile; - Output_Source_Line (N, Sfile, Err_Flag); + Output_Source_Line (N, Sfile, Err_Flag); - if Err_Flag then - Output_Error_Msgs (E); + if Err_Flag then + Output_Error_Msgs (E); - if not Debug_Flag_2 then - Write_Eol; + if not Debug_Flag_2 then + Write_Eol; + end if; end if; - end if; - end loop; + end loop; + end if; end; end if; end loop; @@ -1909,7 +1931,13 @@ package body Errout is and then (not Full_List or else Full_List_File_Name /= null) then Write_Eol; - Write_Header (Main_Source_File); + + -- Output the header only when Main_Source_File is known + + if Main_Source_File /= No_Source_File then + Write_Header (Main_Source_File); + end if; + E := First_Error_Msg; -- Loop through error lines @@ -2705,7 +2733,7 @@ package body Errout is Warning_Msg_Char := ' '; if P <= Text'Last and then Text (P) = '?' then - if Warning_Doc_Switch and not OpenVMS_On_Target then + if Warning_Doc_Switch then Warning_Msg_Char := '?'; end if; @@ -2717,7 +2745,7 @@ package body Errout is Text (P) in 'A' .. 'Z') and then Text (P + 1) = '?' then - if Warning_Doc_Switch and not OpenVMS_On_Target then + if Warning_Doc_Switch then Warning_Msg_Char := Text (P); end if; @@ -2805,7 +2833,6 @@ package body Errout is if Error_Msg_Warn and Warning_Doc_Switch - and not OpenVMS_On_Target then Warning_Msg_Char := '?'; end if; |