From 7ffb58afe1ad318ccf289325e802d913bd8e0e15 Mon Sep 17 00:00:00 2001 From: Hristian Kirtchev Date: Tue, 17 Jul 2018 08:11:32 +0000 Subject: [PATCH] [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. 2018-07-17 Hristian Kirtchev 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 | 5 +++++ gcc/ada/frontend.adb | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 9fe7a3b69d7..1b8da215bea 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-07-17 Hristian Kirtchev + + * frontend.adb (Frontend): The removal of ignored Ghost code must be + the last semantic operation performed on the tree. + 2018-07-17 Hristian Kirtchev * frontend.adb (Frontend): Update the call to Register_Config_Switches. diff --git a/gcc/ada/frontend.adb b/gcc/ada/frontend.adb index 1af5587110f..1da6f9aa502 100644 --- a/gcc/ada/frontend.adb +++ b/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; -- 2.30.2