]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Check subtype to avoid a precondition failure
authorViljar Indus <indus@adacore.com>
Tue, 5 Mar 2024 09:57:12 +0000 (11:57 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 17 May 2024 08:20:59 +0000 (10:20 +0200)
gcc/ada/

* sem_ch3.adb (Analyze_Component_Declaration):
Apply range checks only for Scalar_Types to
ensure that they have the Scalar_Range attribute.

gcc/ada/sem_ch3.adb

index 7ee4ca299d9d70fa8efd28dc8956e3f7bf5e6c39..263be607ec14b514ffe8cbe395edc5f99189fbcc 100644 (file)
@@ -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)),