From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id EF653384F01A; Mon, 4 Jul 2022 07:50:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF653384F01A 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-1431] [Ada] Compiler rejects legal allocator in record component constraint expression X-Act-Checkin: gcc X-Git-Author: Steve Baird X-Git-Refname: refs/heads/master X-Git-Oldrev: f7c05e82037356ac4610e9e5d1365b345a17d0f7 X-Git-Newrev: 063c8f4c01bc1a5e6960c8624077df7137dc5dad Message-Id: <20220704075037.EF653384F01A@sourceware.org> Date: Mon, 4 Jul 2022 07:50:37 +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: Mon, 04 Jul 2022 07:50:38 -0000 https://gcc.gnu.org/g:063c8f4c01bc1a5e6960c8624077df7137dc5dad commit r13-1431-g063c8f4c01bc1a5e6960c8624077df7137dc5dad Author: Steve Baird Date: Tue May 24 16:03:58 2022 -0700 [Ada] Compiler rejects legal allocator in record component constraint expression In some cases when a legal allocator which defines a new subtype for the allocated object occurs as part of a record component constraint expression, the compiler would incorrectly reject the allocator. gcc/ada/ * sem_ch4.adb (Analyze_Allocator): After calling Insert_Action to insert a subtype declaration associated with an allocator, the subtype declaration will usually be analyzed. But not always. Add an explicit call to Preanalyze to cope with the unusual case. The subtype declaration must be at least preanalyzed before the call to Sem_Ch3.Process_Subtype a little while later, during which we analyze an identifier that refers to the subtype. Diff: --- gcc/ada/sem_ch4.adb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 8fe20772a69..4bc3696f673 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -670,10 +670,19 @@ package body Sem_Ch4 is then Def_Id := Make_Temporary (Loc, 'S'); - Insert_Action (E, - Make_Subtype_Declaration (Loc, - Defining_Identifier => Def_Id, - Subtype_Indication => Relocate_Node (E))); + declare + Subtype_Decl : constant Node_Id := + Make_Subtype_Declaration (Loc, + Defining_Identifier => Def_Id, + Subtype_Indication => Relocate_Node (E)); + begin + Insert_Action (E, Subtype_Decl); + + -- Handle unusual case where Insert_Action does not + -- analyze the declaration. Subtype_Decl must be + -- preanalyzed before call to Process_Subtype below. + Preanalyze (Subtype_Decl); + end; if Sav_Errs /= Serious_Errors_Detected and then Nkind (Constraint (E)) =