This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Faulty ignored Ghost code removal
- From: Pierre-Marie de Rodat <derodat at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Hristian Kirtchev <kirtchev at adacore dot com>
- Date: Tue, 17 Jul 2018 04:24:57 -0400
- Subject: [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;