From: Eric Botcazou Date: Sat, 16 Sep 2023 18:29:20 +0000 (+0200) Subject: ada: Fix deferred constant wrongly rejected X-Git-Tag: basepoints/gcc-15~5864 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6367fc211e52b3f7f8d0f2c481e20cb69839071;p=thirdparty%2Fgcc.git ada: Fix deferred constant wrongly rejected 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. --- diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 92902a7debb5..c79d323395f3 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -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