public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1468] [Ada] AI12-0138: Iterators and other nonoverridable aspects
Date: Tue, 15 Jun 2021 10:22:12 +0000 (GMT)	[thread overview]
Message-ID: <20210615102212.F1A1D398B174@sourceware.org> (raw)

https://gcc.gnu.org/g:9e47051a3785f6a55dc63f9a1eaeccd19895c18c

commit r12-1468-g9e47051a3785f6a55dc63f9a1eaeccd19895c18c
Author: Ed Schonberg <schonberg@adacore.com>
Date:   Wed Feb 10 10:52:04 2021 -0500

    [Ada] AI12-0138: Iterators and other nonoverridable aspects
    
    gcc/ada/
    
            * sem_util.adb (Is_Confirming): Separate the handling of
            Implicit_Dereference, for which no pragma is generated but which
            is already checked for legality in Sem_Ch13, including renamed
            discriminants in a derived type.
            (Is_Confirming, Same_Name): For expanded names, only check
            matching of selector, because prefix may correspond to original
            and derived types with different names and/or scopes. Semantic
            checks on aspect expression have already verified its legality.
            Add comments regarding possible gaps in RM description of the
            feature.

Diff:
---
 gcc/ada/sem_util.adb | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 98ca0466e0b..20246823d88 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -15886,18 +15886,32 @@ package body Sem_Util is
                            Aspect_Spec_1, Aspect_Spec_2 : Node_Id)
                           return Boolean is
       function Names_Match (Nm1, Nm2 : Node_Id) return Boolean;
+
+      -----------------
+      -- Names_Match --
+      -----------------
+
       function Names_Match (Nm1, Nm2 : Node_Id) return Boolean is
       begin
          if Nkind (Nm1) /= Nkind (Nm2) then
             return False;
+            --  This may be too restrictive given that visibility
+            --  may allow an identifier in one case and an expanded
+            --  name in the other.
          end if;
          case Nkind (Nm1) is
             when N_Identifier =>
                return Name_Equals (Chars (Nm1), Chars (Nm2));
+
             when N_Expanded_Name =>
-               return Names_Match (Prefix (Nm1), Prefix (Nm2))
-                 and then Names_Match (Selector_Name (Nm1),
-                                       Selector_Name (Nm2));
+               --  An inherited operation has the same name as its
+               --  ancestor, but they may have different scopes.
+               --  This may be too permissive for Iterator_Element, which
+               --  is intended to be identical in parent and derived type.
+
+               return Names_Match (Selector_Name (Nm1),
+                                   Selector_Name (Nm2));
+
             when N_Empty =>
                return True; -- needed for Aggregate aspect checking
 
@@ -15925,8 +15939,7 @@ package body Sem_Util is
          when Aspect_Default_Iterator
             | Aspect_Iterator_Element
             | Aspect_Constant_Indexing
-            | Aspect_Variable_Indexing
-            | Aspect_Implicit_Dereference =>
+            | Aspect_Variable_Indexing =>
             declare
                Item_1 : constant Node_Id := Aspect_Rep_Item (Aspect_Spec_1);
                Item_2 : constant Node_Id := Aspect_Rep_Item (Aspect_Spec_2);
@@ -15942,6 +15955,13 @@ package body Sem_Util is
                                    Expression (Item_2));
             end;
 
+         --  A confirming aspect for Implicit_Derenfence on a derived type
+         --  has already been checked in Analyze_Aspect_Implicit_Dereference,
+         --  including the presence of renamed discriminants.
+
+         when Aspect_Implicit_Dereference =>
+            return True;
+
          --  one of a kind
          when Aspect_Aggregate =>
             declare


                 reply	other threads:[~2021-06-15 10:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210615102212.F1A1D398B174@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).