This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Faulty ignored Ghost code removal


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.

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

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.
--- gcc/ada/frontend.adb
+++ gcc/ada/frontend.adb
@@ -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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]