From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 1A9D53851AB5; Wed, 13 Jul 2022 10:02:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A9D53851AB5 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1657] [Ada] Fix internal error on untagged record type with equality operator X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: 730814edc8b3c1bc872c54a39064ac59e2b8fdbd X-Git-Newrev: 6faa271f09f32b32a6f4e32e3964faadc8372907 Message-Id: <20220713100251.1A9D53851AB5@sourceware.org> Date: Wed, 13 Jul 2022 10:02:51 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 10:02:51 -0000 https://gcc.gnu.org/g:6faa271f09f32b32a6f4e32e3964faadc8372907 commit r13-1657-g6faa271f09f32b32a6f4e32e3964faadc8372907 Author: Eric Botcazou Date: Fri Jul 1 10:47:36 2022 +0200 [Ada] Fix internal error on untagged record type with equality operator 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. 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. Diff: --- gcc/ada/sem_res.adb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 44fc955de74..1412d94198c 100644 --- 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