]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Deferred constant considered as not preelaborable
authorYannick Moy <moy@adacore.com>
Thu, 16 Jun 2022 12:14:56 +0000 (14:14 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 6 Jul 2022 13:29:49 +0000 (13:29 +0000)
Fix detection of non-preelaborable constructs for checking SPARK
elaboration rules, which was tagging deferred constant declarations as
not preelaborable.

gcc/ada/

* sem_util.adb (Is_Non_Preelaborable_Construct): Fix for
deferred constants.

gcc/ada/sem_util.adb

index 942a77a34f2e2c5169579d97103a62372c19daa3..7b7566d96c79aed9fe687268ecf549d3a91c7734 100644 (file)
@@ -18952,8 +18952,9 @@ package body Sem_Util is
                if Has_Init_Expression (Nod) then
                   Visit (Expression (Nod));
 
-               elsif not Has_Preelaborable_Initialization
-                           (Etype (Defining_Entity (Nod)))
+               elsif not Constant_Present (Nod)
+                 and then not Has_Preelaborable_Initialization
+                                (Etype (Defining_Entity (Nod)))
                then
                   raise Non_Preelaborable;
                end if;