aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViljar Indus <indus@adacore.com>2024-03-05 11:57:12 +0200
committerMarc Poulhiès <poulhies@adacore.com>2024-05-17 10:20:59 +0200
commit811bfc3f3e4f6f3e7a98e90409a8a6dbaa1509e1 (patch)
tree0fd704751dea395661949ccf57fb7ce008b2a9b9
parent8fc79eac8047edaebc2a4f04cd9c1e11fc2a25c1 (diff)
downloadgcc-811bfc3f3e4f6f3e7a98e90409a8a6dbaa1509e1.zip
gcc-811bfc3f3e4f6f3e7a98e90409a8a6dbaa1509e1.tar.gz
gcc-811bfc3f3e4f6f3e7a98e90409a8a6dbaa1509e1.tar.bz2
ada: Check subtype to avoid a precondition failure
gcc/ada/ * sem_ch3.adb (Analyze_Component_Declaration): Apply range checks only for Scalar_Types to ensure that they have the Scalar_Range attribute.
-rw-r--r--gcc/ada/sem_ch3.adb5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 7ee4ca2..263be60 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -2029,8 +2029,9 @@ package body Sem_Ch3 is
while Present (Target_Index) loop
if Nkind (Subt_Index) in N_Expanded_Name | N_Identifier
- and then Nkind
- (Scalar_Range (Entity (Subt_Index))) = N_Range
+ and then Is_Scalar_Type (Entity (Subt_Index))
+ and then
+ Nkind (Scalar_Range (Entity (Subt_Index))) = N_Range
then
Apply_Range_Check
(Expr => Scalar_Range (Entity (Subt_Index)),