From: Javier Miranda Date: Wed, 21 Jan 2026 19:36:30 +0000 (+0000) Subject: ada: Boolean flag for Unsigned_Base_Range aspect is ignored X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=63b020fc2be3316db4ff218401993a5f22d61756;p=thirdparty%2Fgcc.git ada: Boolean flag for Unsigned_Base_Range aspect is ignored Unsigned_Base_Range is erroneously enabled when set to False. gcc/ada/ChangeLog: * sem_ch13.adb (Analyze_One_Aspect): For Unsigned_Base_Range aspect, skip generating its corresponding pragma when the aspect is set to False. * sem_ch3.adb (Analyze_Full_Type_Declaration): Fix initialization of local variable Is_Unsigned_Base_Range_Type_Decl to handle Unsigned_Base_Range aspect set to False. --- diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 158bdb1c516..eb4f05b2071 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -3780,7 +3780,7 @@ package body Sem_Ch13 is then Delay_Required := False; - -- For Unsigned_Base_Range aspect, do not delay becase we + -- For Unsigned_Base_Range aspect, do not delay because we -- need to process it before any type or subtype derivation -- is analyzed. @@ -5646,10 +5646,17 @@ package body Sem_Ch13 is goto Continue; -- GNAT Core Extension: Checks for this aspect are performed - -- when the corresponding pragma is analyzed. + -- when the corresponding pragma is analyzed; if aspect has + -- no effect, pragma generation is skipped. elsif A_Id = Aspect_Unsigned_Base_Range then - null; + if Present (Expr) then + Analyze_And_Resolve (Expr, Standard_Boolean); + + if Is_False (Static_Boolean (Expr)) then + goto Continue; + end if; + end if; -- Ada 2022 (AI12-0279) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index e726abad476..6adc627b48a 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -3193,12 +3193,22 @@ package body Sem_Ch3 is begin if Present (Aspect_Specifications (Parent (Def))) then declare - Asp : Node_Id; + Asp : Node_Id; + Expr : Node_Id; + begin Asp := First (Aspect_Specifications (Parent (Def))); while Present (Asp) loop if Chars (Identifier (Asp)) = Name_Unsigned_Base_Range then - Is_Unsigned_Base_Range_Type_Decl := True; + Expr := Expression (Asp); + + if Present (Expr) then + Analyze_And_Resolve (Expr, Standard_Boolean); + end if; + + Is_Unsigned_Base_Range_Type_Decl := + No (Expression (Asp)) + or else Is_True (Static_Boolean (Expr)); exit; end if;