[Ada] Fix deleted Compile_Time warnings causing crashes

Message ID 20211025150850.GA346238@adacore.com
State Committed
Commit ea5f7f3962a0781cfd36016776adf79986929bfa
Headers
Series [Ada] Fix deleted Compile_Time warnings causing crashes |

Commit Message

Pierre-Marie de Rodat Oct. 25, 2021, 3:08 p.m. UTC
  Count_Compile_Time_Pragma_Warnings also counted deleted pragmas. This
caused discrepancies ultimately leading to a crash when Compile_Time
warnings were suppressed by a Warnings(Off, ...) pragma.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* erroutc.adb (Count_Compile_Time_Pragma_Warnings): Don't count
	deleted warnings.
  

Patch

diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -277,7 +277,9 @@  package body Erroutc is
    begin
       for J in 1 .. Errors.Last loop
          begin
-            if Errors.Table (J).Warn and Errors.Table (J).Compile_Time_Pragma
+            if Errors.Table (J).Warn
+               and then Errors.Table (J).Compile_Time_Pragma
+               and then not Errors.Table (J).Deleted
             then
                Result := Result + 1;
             end if;