]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix missing names for 'Image of enumeration type
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 7 Jun 2026 20:30:56 +0000 (22:30 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 19 Jun 2026 13:05:28 +0000 (15:05 +0200)
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) <Pragma_Check>: 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.

gcc/ada/expander.adb
gcc/ada/ghost.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_prag.adb

index e2af4f8a00928e3ee55a0e46f82d904aa47a4721..e5ecd2c7050c665dc0e50660be05040358482c84 100644 (file)
@@ -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);
index dac1442b663eba58d1f3670eb968bff181c0d61c..b356bed9d40f6077450fcfca0f71a4118443fc40 100644 (file)
@@ -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;
index e909e288b82006d35268b85853fd22c2fe00c33d..f25dc89d5fd901fc7d939d4881b2e63b63b1423f 100644 (file)
@@ -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.
index 7762797bba3edad85fb4f640d4c2aa4027f95c42..29ef2a46a44fd1510069535b30657547785d3c67 100644 (file)
@@ -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.