From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Eric Botcazou <ebotcazou@adacore.com>
Subject: [Ada] Fix internal error on untagged record type with equality operator
Date: Wed, 13 Jul 2022 10:02:47 +0000 [thread overview]
Message-ID: <20220713100247.GA994532@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 609 bytes --]
After the binding interpretation issued under AI12-0413, a user-defined
primitive equality operator of an untagged record type hides the predefined
equality operator in an instantiation, but this does not apply if the
instantiation appears in the same declarative region as the type and
before the declaration of this user-defined operator.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_res.adb (Resolve_Equality_Op): Make sure that the user-defined
operator of an untagged record type is declared ahead of an instance
before using it to resolve the equality operator in the instance.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 876 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
@@ -8967,7 +8967,14 @@ package body Sem_Res is
then
Eq := Get_User_Defined_Equality (T);
- if Present (Eq) then
+ -- We need to make sure that the instance is not within the
+ -- same declarative region as the type, or else that it lies
+ -- after the declaration of the user-defined "=" operator.
+
+ if Present (Eq)
+ and then (not In_Same_Extended_Unit (Eq, N)
+ or else Earlier_In_Extended_Unit (Eq, N))
+ then
if Is_Abstract_Subprogram (Eq) then
Nondispatching_Call_To_Abstract_Operation (N, Eq);
else
reply other threads:[~2022-07-13 10:02 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=20220713100247.GA994532@adacore.com \
--to=derodat@adacore.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@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).