public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-399] [Ada] Handle IN iterator for class-wide derived object of iterator type
@ 2022-05-13  8:08 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-13  8:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7b6fa643ef03f898a6e7284167fa6d064ba8b524

commit r13-399-g7b6fa643ef03f898a6e7284167fa6d064ba8b524
Author: Ed Schonberg <schonberg@adacore.com>
Date:   Tue Feb 15 15:38:42 2022 +0100

    [Ada] Handle IN iterator for class-wide derived object of iterator type
    
    The compiler currently rejects iterating on an interface type derived
    from an iterator type.
    
    See Ada RM 5.5.1(6/3) and 5.5.2(3/3).
    
    gcc/ada/
    
            * sem_ch5.adb (Analyze_Iterator_Specification): Fix Typ in the
            case of a class-wide derived iterator.

Diff:
---
 gcc/ada/sem_ch5.adb | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index 0a836089d95..7fd5ab304f1 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -2761,9 +2761,21 @@ package body Sem_Ch5 is
                end;
             end if;
 
-         --  IN iterator, domain is a range, or a call to Iterate function
+         --  IN iterator, domain is a range, a call to Iterate function,
+         --  or an object/actual parameter of an iterator type.
 
          else
+            --  If the type of the name is class-wide and its root type is a
+            --  derived type, the primitive operations (First, Next, etc.) are
+            --  those inherited by its specific type. Calls to these primitives
+            --  will be dispatching.
+
+            if Is_Class_Wide_Type (Typ)
+              and then Is_Derived_Type (Etype (Typ))
+            then
+               Typ := Etype (Typ);
+            end if;
+
             --  For an iteration of the form IN, the name must denote an
             --  iterator, typically the result of a call to Iterate. Give a
             --  useful error message when the name is a container by itself.


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

only message in thread, other threads:[~2022-05-13  8:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13  8:08 [gcc r13-399] [Ada] Handle IN iterator for class-wide derived object of iterator type 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).