diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2021-03-10 23:40:13 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-06-17 10:32:15 -0400 |
commit | aeafd222d4c132efee8f7b47a48cc1c7b5a0b4c9 (patch) | |
tree | c06f79cbe5be8492a92f808386ea597b2f700687 /gcc | |
parent | fc473ce74c64fa0d5027aa4045579ec39d78a4c4 (diff) | |
download | gcc-aeafd222d4c132efee8f7b47a48cc1c7b5a0b4c9.zip gcc-aeafd222d4c132efee8f7b47a48cc1c7b5a0b4c9.tar.gz gcc-aeafd222d4c132efee8f7b47a48cc1c7b5a0b4c9.tar.bz2 |
[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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_util.adb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 855195d..b71efde 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 |