[Ada] Fix failed assertion on a slice indexed by a subtype_indication
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 16 Apr 2020 11:59:53 +0000 (13:59 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 18 Jun 2020 09:08:22 +0000 (05:08 -0400)
2020-06-18  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* checks.adb (Generate_Index_Checks): Handle
N_Subtype_Indication returned from Scalar_Range.

gcc/ada/checks.adb

index 51b73f992a6d71c11bcfb991095107773cf0c8dd..7b8ca979a7e2342ed8b322f3a38a4350c040c9ae 100644 (file)
@@ -6842,6 +6842,10 @@ package body Checks is
                   elsif Nkind_In (A_Idx, N_Identifier, N_Expanded_Name) then
                      A_Range := Scalar_Range (Entity (A_Idx));
 
+                     if Nkind (A_Range) = N_Subtype_Indication then
+                        A_Range := Range_Expression (Constraint (A_Range));
+                     end if;
+
                   else pragma Assert (Nkind (A_Idx) = N_Subtype_Indication);
                      A_Range := Range_Expression (Constraint (A_Idx));
                   end if;