[Ada] Faulty ignored Ghost code removal
authorHristian Kirtchev <kirtchev@adacore.com>
Tue, 17 Jul 2018 08:11:32 +0000 (08:11 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 17 Jul 2018 08:11:32 +0000 (08:11 +0000)
This patch ensures that removal of ignored Ghost code is the absolute last
operation performed on the tree. Previously the removal was performed prior to
issuing delayed warnings, however the warning mechanism may see a heavily
modified tree and fail.

No small reproducer available.

2018-07-17  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

* frontend.adb (Frontend): The removal of ignored Ghost code must be
the last semantic operation performed on the tree.

From-SVN: r262795

gcc/ada/ChangeLog
gcc/ada/frontend.adb

index 9fe7a3b..1b8da21 100644 (file)
@@ -1,5 +1,10 @@
 2018-07-17  Hristian Kirtchev  <kirtchev@adacore.com>
 
+       * frontend.adb (Frontend): The removal of ignored Ghost code must be
+       the last semantic operation performed on the tree.
+
+2018-07-17  Hristian Kirtchev  <kirtchev@adacore.com>
+
        * frontend.adb (Frontend): Update the call to Register_Config_Switches.
        * inline.ads: Add new component Config_Switches to record
        Pending_Body_Info which captures the configuration state of the pending
index 1af5587..1da6f9a 100644 (file)
@@ -451,11 +451,6 @@ begin
 
                Check_Elaboration_Scenarios;
 
-               --  Remove any ignored Ghost code as it must not appear in the
-               --  executable.
-
-               Remove_Ignored_Ghost_Code;
-
             --  Examine all top level scenarios collected during analysis and
             --  resolution in order to diagnose conditional ABEs, even in the
             --  presence of serious errors.
@@ -483,6 +478,14 @@ begin
             Sem_Warn.Output_Unreferenced_Messages;
             Sem_Warn.Check_Unused_Withs;
             Sem_Warn.Output_Unused_Warnings_Off_Warnings;
+
+            --  Remove any ignored Ghost code as it must not appear in the
+            --  executable. This action must be performed last because it
+            --  heavily alters the tree.
+
+            if Operating_Mode = Generate_Code or else GNATprove_Mode then
+               Remove_Ignored_Ghost_Code;
+            end if;
          end if;
       end if;
    end;