From: Eric Botcazou Date: Sun, 7 Jun 2026 20:30:56 +0000 (+0200) Subject: ada: Fix missing names for 'Image of enumeration type X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d591bae993485db48852c19dd8611441ebecb22;p=thirdparty%2Fgcc.git ada: Fix missing names for 'Image of enumeration type This is a freezing issue introduced by the recent coupling of assertions and Ghost mode, which are supposed to use different paths in the freezing code. In light of this, it appears to be wise to undo the coupling and restore the clear separation between the two different mechanisms. The price to pay is the loss of the "assertion would fail at run time" warning for non-static assertions that are disabled (it is still present for static assertions), which seems to be an acceptable trade-off to avoid nasty freezing issues. gcc/ada/ChangeLog: * expander.adb (Expand): Revert latest change. * ghost.adb (Set_Ghost_Mode): Likewise. * sem_ch3.adb (Analyze_Subtype_Declaration): Also copy the RM size for floating-point types. * sem_prag.adb (Analyze_Pragma) : Do not mark the pragma as Ghost when expander is active and the pragma is ignored. Preanalyze it instead of analyzing it, and rewrite it as a null statement at the end of the processing. --- diff --git a/gcc/ada/expander.adb b/gcc/ada/expander.adb index e2af4f8a009..e5ecd2c7050 100644 --- a/gcc/ada/expander.adb +++ b/gcc/ada/expander.adb @@ -537,8 +537,7 @@ package body Expander is if Scope_Is_Transient and then N = Node_To_Be_Wrapped then case Nkind (N) is - when N_Pragma - | N_Procedure_Call_Statement + when N_Procedure_Call_Statement | N_Statement_Other_Than_Procedure_Call => Wrap_Transient_Statement (N); diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb index dac1442b663..b356bed9d40 100644 --- a/gcc/ada/ghost.adb +++ b/gcc/ada/ghost.adb @@ -2907,8 +2907,6 @@ package body Ghost is else if Is_Checked (N) then Install_Ghost_Region (Check, N, Level); - elsif Is_Ignored (N) then - Install_Ghost_Region (Ignore, N, Level); else Install_Ghost_Region (None, N, Level); end if; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index e909e288b82..f25dc89d5fd 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -5956,6 +5956,7 @@ package body Sem_Ch3 is Set_Is_Constrained (Id, Is_Constrained (T)); Set_Is_IEEE_Extended_Precision (Id, Is_IEEE_Extended_Precision (T)); + Copy_RM_Size (To => Id, From => T); -- If the floating point type has dimensions, these will be -- inherited subsequently when Analyze_Dimensions is called. diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 7762797bba3..29ef2a46a44 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -15982,20 +15982,12 @@ package body Sem_Prag is Preanalyze_And_Resolve (Arg_Message, Standard_String); end if; - if Expander_Active and Is_Ignored_In_Codegen (N) then - - -- Even though technically ignored assertions are not ghost - -- code they should behave the same way. Meaning that they - -- should be analyzed but they should not affect the generated - -- code. Use the ignored ghost mechanism here to ensure that - -- the original pragma and any expanded code is also removed. - -- Ideally these two cases should be separated in the - -- implementation ??? - - Mark_Ghost_Pragma (N, Opt.Ignore); + -- When expansion is active but check is not, only preanalyze the + -- boolean to avoid pulling useless dependencies. + if Expander_Active and Is_Ignored_In_Codegen (N) then In_Assertion_Expr := In_Assertion_Expr + 1; - Analyze_And_Resolve (Arg_Check, Any_Boolean); + Preanalyze_And_Resolve (Arg_Check, Any_Boolean); In_Assertion_Expr := In_Assertion_Expr - 1; -- Suppress any warnings on the condition we might get @@ -16006,6 +15998,11 @@ package body Sem_Prag is Check_Assertion_Failure (Arg_Check); + -- Rewrite the pragma as a null statement + + Rewrite (N, Make_Null_Statement (Loc)); + Analyze (N); + -- Check is active or expansion not active. In these cases we can -- just go ahead and analyze the boolean with no worries.