diff mbox series

[Ada] Fix missing check on slice with a subtype indication

Message ID 20211004084750.GA1536676@adacore.com
State New
Headers show
Series [Ada] Fix missing check on slice with a subtype indication | expand

Commit Message

Pierre-Marie de Rodat Oct. 4, 2021, 8:47 a.m. UTC
A slice range can be specified either by a subtype name, regular range,
or subtype indication with constraints. The compiler missed the last
case.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_res.adb (Resolve_Slice): Handle range given as a subtype
	indication.
diff mbox series

Patch

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -11360,7 +11360,11 @@  package body Sem_Res is
          Set_Parent (Dexpr, Parent (Drange));
          Set_Sloc   (Dexpr, Sloc   (Drange));
 
-      --  The discrete_range is a regular range. Resolve the bounds and remove
+      elsif Nkind (Drange) = N_Subtype_Indication then
+         Dexpr := Range_Expression (Constraint (Drange));
+
+      --  The discrete_range is a regular range (or a range attribute, which
+      --  will be resolved into a regular range). Resolve the bounds and remove
       --  their side effects.
 
       else