]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Spurious error on deferred constant with predicate
authorYannick Moy <moy@adacore.com>
Tue, 27 Jul 2021 10:20:41 +0000 (12:20 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 22 Sep 2021 15:01:50 +0000 (15:01 +0000)
gcc/ada/

* sem_ch3.adb (Analyze_Object_Declaration): Do not insert a
predicate check after a deferred constant declaration.

gcc/ada/sem_ch3.adb

index 0e36cc228373d02c99aba10adbd35137572a1129..7ba6f7b3bf9a05fe6a35233043a5647f6447424d 100644 (file)
@@ -4505,7 +4505,7 @@ package body Sem_Ch3 is
       --  default initial value (including via a Default_Value or
       --  Default_Component_Value aspect, see AI12-0301) and then this is not
       --  an internal declaration whose initialization comes later (as for an
-      --  aggregate expansion).
+      --  aggregate expansion) or a deferred constant.
       --  If expression is an aggregate it may be expanded into assignments
       --  and the declaration itself is marked with No_Initialization, but
       --  the predicate still applies.
@@ -4519,6 +4519,7 @@ package body Sem_Ch3 is
           (Present (E)
             or else
               Is_Partially_Initialized_Type (T, Include_Implicit => False))
+        and then not (Constant_Present (N) and then No (E))
       then
          --  If the type has a static predicate and the expression is known at
          --  compile time, see if the expression satisfies the predicate.