This patch fixes an error in the compiler whereby an assertion pragma
within a ghost context whose expression causes the freezing of a
non-ghost type causes the compiler to crash during compilation when
ghost mode is disabled.

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

gcc/ada/

        * sem_prag.adb (Analyze_Pragma): Mark relevant pragmas as ghost
        when they are within a ghost region.
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -11437,6 +11437,12 @@ package body Sem_Prag is
          end if;
       end if;
 
+      --  Mark assertion pragmas as Ghost depending on their enclosing context
+
+      if Assertion_Expression_Pragma (Prag_Id) then
+         Mark_Ghost_Pragma (N, Current_Scope);
+      end if;
+
       --  Preset arguments
 
       Arg_Count := 0;


Reply via email to