public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix missing check on slice with a subtype indication
@ 2021-10-04  8:47 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-04  8:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 285 bytes --]

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.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 655 bytes --]

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-04  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04  8:47 [Ada] Fix missing check on slice with a subtype indication Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).