]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Avoid crash on illegal constrained type declarations
authorPiotr Trojanek <trojanek@adacore.com>
Sun, 21 Jan 2024 22:29:52 +0000 (23:29 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 13 May 2024 08:03:28 +0000 (10:03 +0200)
Fix crash on ACATS test B38003B introduced by a recent cleanup of
per-object constraints.

gcc/ada/

* sem_util.adb (Get_Index_Bounds): Guard against missing Entity,
which happens on illegal constrained type declaration.

gcc/ada/sem_util.adb

index 5f44b4c26fe54bba5eaca8dab5d4ae1814933876..579172515df4f4b4505e94827f303309a3ac1677 100644 (file)
@@ -10542,7 +10542,10 @@ package body Sem_Util is
             H := High_Bound (Range_Expression (Constraint (N)));
          end if;
 
-      elsif Is_Entity_Name (N) and then Is_Type (Entity (N)) then
+      elsif Is_Entity_Name (N)
+        and then Present (Entity (N))
+        and then Is_Type (Entity (N))
+      then
          Rng := Scalar_Range_Of_Type (Entity (N));
 
          if Error_Posted (Rng) then