]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix deferred constant wrongly rejected
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 16 Sep 2023 18:29:20 +0000 (20:29 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 26 Sep 2023 11:43:18 +0000 (13:43 +0200)
This recent regression occurs when the nominal subtype of the constant is a
discriminated record type with default discriminants.

gcc/ada/
PR ada/110488
* sem_ch3.adb (Analyze_Object_Declaration): Do not build a default
subtype for a deferred constant in the definite case too.

gcc/ada/sem_ch3.adb

index 92902a7debb53f6242363a2c2c90f1db548c6a4b..c79d323395f3303eb1dd3319e740146ac80d1901 100644 (file)
@@ -5048,9 +5048,11 @@ package body Sem_Ch3 is
             Apply_Length_Check (E, T);
          end if;
 
-      --  When possible, build the default subtype
+      --  When possible, and not a deferred constant, build the default subtype
 
-      elsif Build_Default_Subtype_OK (T) then
+      elsif Build_Default_Subtype_OK (T)
+        and then (not Constant_Present (N) or else Present (E))
+      then
          if No (E) then
             Act_T := Build_Default_Subtype (T, N);
          else