From: Piotr Trojanek Date: Wed, 10 Mar 2021 22:40:13 +0000 (+0100) Subject: [Ada] Fix detection of valid renamings for overlapping checks X-Git-Tag: basepoints/gcc-13~6722 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aeafd222d4c132efee8f7b47a48cc1c7b5a0b4c9;p=thirdparty%2Fgcc.git [Ada] Fix detection of valid renamings for overlapping checks gcc/ada/ * sem_util.adb (Is_Valid_Renaming): Check not only indexed components, but slices too. --- diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 855195dd2201..b71efde85676 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -7301,6 +7301,9 @@ package body Sem_Util is return False; end if; + -- Check if any expression within the renamed object_name contains no + -- references to variables nor calls on nonstatic functions. + if Nkind (N) = N_Indexed_Component then declare Indx : Node_Id; @@ -7315,6 +7318,33 @@ package body Sem_Util is Next_Index (Indx); end loop; end; + + elsif Nkind (N) = N_Slice then + declare + Rng : constant Node_Id := Discrete_Range (N); + begin + -- Bounds specified as a range + + if Nkind (Rng) = N_Range then + if not Is_OK_Static_Range (Rng) then + return False; + end if; + + -- Bounds specified as a constrained subtype indication + + elsif Nkind (Rng) = N_Subtype_Indication then + if not Is_OK_Static_Range + (Range_Expression (Constraint (Rng))) + then + return False; + end if; + + -- Bounds specified as a subtype name + + elsif not Is_OK_Static_Expression (Rng) then + return False; + end if; + end; end if; if Has_Prefix (N) then