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 r13-502] [Ada] Fix fallout of change in equality for untagged record types Date: Mon, 16 May 2022 08:45:14 +0000 (GMT) [thread overview] Message-ID: <20220516084514.634923857407@sourceware.org> (raw) https://gcc.gnu.org/g:b90e43dbbb2ba00ef2f8b2468fb09b43a12ae13d commit r13-502-gb90e43dbbb2ba00ef2f8b2468fb09b43a12ae13d Author: Eric Botcazou <ebotcazou@adacore.com> Date: Wed Mar 16 14:50:24 2022 +0100 [Ada] Fix fallout of change in equality for untagged record types The problem is that the resolution of expanded names implicitly assumes that the visible and private homonyms in a given scope are segregated on the homonym chain, and this was no longer the case for equality operators in the specific case at stake. gcc/ada/ * sem_ch7.adb (Inspect_Untagged_Record_Completion): Also move the equality operator on the homonym chain if there is another equality operator in the private part. Diff: --- gcc/ada/sem_ch7.adb | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index 4ba1d32cf7c..0b11176793c 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -1491,6 +1491,7 @@ package body Sem_Ch7 is Prim_List : constant Elist_Id := Collect_Primitive_Operations (Defining_Identifier (Decl)); + E : Entity_Id; Ne_Id : Entity_Id; Op_Decl : Node_Id; Op_Id : Entity_Id; @@ -1517,16 +1518,39 @@ package body Sem_Ch7 is pragma Assert (Ekind (Ne_Id) = E_Function and then Corresponding_Equality (Ne_Id) = Op_Id); + E := First_Private_Entity (Id); + -- Move them from the private part of the entity list -- up to the end of the visible part of the same list. Remove_Entity (Op_Id); Remove_Entity (Ne_Id); - Link_Entities - (Prev_Entity (First_Private_Entity (Id)), Op_Id); + Link_Entities (Prev_Entity (E), Op_Id); Link_Entities (Op_Id, Ne_Id); - Link_Entities (Ne_Id, First_Private_Entity (Id)); + Link_Entities (Ne_Id, E); + + -- And if the private part contains another equality + -- operator, move the equality operator to after it + -- in the homonym chain, so that all its next homonyms + -- in the same scope, if any, also are in the visible + -- part. This is relied upon to resolve expanded names + -- in Collect_Interps for example. + + while Present (E) loop + exit when Ekind (E) = E_Function + and then Chars (E) = Name_Op_Eq; + + Next_Entity (E); + end loop; + + if Present (E) then + Remove_Homonym (Op_Id); + + Set_Homonym (Op_Id, Homonym (E)); + Set_Homonym (E, Op_Id); + end if; + exit; end if;
reply other threads:[~2022-05-16 8:45 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=20220516084514.634923857407@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: linkBe 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).