From patchwork Mon Nov 4 16:11:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 2006316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=P9SFasC3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhxT704bhz1xxW for ; Tue, 5 Nov 2024 03:17:47 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 572D1385B519 for ; Mon, 4 Nov 2024 16:17:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 9CEF6385802C for ; Mon, 4 Nov 2024 16:11:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CEF6385802C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9CEF6385802C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730736745; cv=none; b=HTj4/xOqOGUZxdnJaqmvKbDcRfPCJVdoloRvR8N+OWj3B8dfY0Mf9jspcRkyV7xA2CK+0HN+GpJMb1DWPwt56eYcIslPPDukISTAvZ5areuYJfy44XZD24G84epCHCylS7kcHbhPt/MY4JgeGXoGztFkYgFcbg0GLxmJLVhru6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730736745; c=relaxed/simple; bh=oHbNi1DszMQX86PvX7vaa2/FaSwn9yt8N7eNJcXvZv0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KBQPwUJKnyoDCdk9CD2GOkF+w2R6euc7EidA9lTim3CGB4TR1qyhlgZ57siu5MRK5zErSkv0Xm2GJR6DGGoOPBSfW3PlxvDLM/VmDxIh9PHuC6Jnflq2iuePU/AqKj27AgjHllCdDq5SJiOnVUWagUO1RhId0XwH7oeXYb/Saz0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-43169902057so34634755e9.0 for ; Mon, 04 Nov 2024 08:11:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1730736709; x=1731341509; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qH4CfQyd3uliOLk6JA2UT8J4vhHeUDICfyI86yyqnmQ=; b=P9SFasC3Ye8VzuBdyjZRU/mDqNzJrlxtg4tyBV3DWSpNn+mDMntX211urJGM6X+N9n 2SiJVtzllipJfKANI1phIfHSfHHr8/0pN1+7UHUIUdmrQGjWYNyzwMgMQIh+JzAQypxm 275KyiqW9fVwyOgoZfRmywksuLIinTsREzmU7LjJEK6vyGOh0JJWWEHTm7YJESdnV1ze oXTSTzB+bIHPPxIiTP5tD6jZB2l5kILvlqEOdP9dfATqE+pcgd86OHU7gAuQn/bsyL4k B3tUKbBD68uw+hQEFgHesulttAU8tj/BqDxCGIDZJolPczHkZJMYkWNGzDYu8DMx6kO9 L7/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730736709; x=1731341509; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qH4CfQyd3uliOLk6JA2UT8J4vhHeUDICfyI86yyqnmQ=; b=niMZEapBBOViiOuVYnahYZQ0e5/JeMaDrp6SZtHLfvp7AIE7Ywn/frH7nHAT8MHsKz pmyhZyTVkdYzbMR6H3deUuDX4Evvv7T49Bqgw4DfiIGkwvf9NFt0gNKw4up5O/cly8x/ HPu6biWxVg3+3M28ipm0HXO+wQPZ/bZK/mDqoyFUpaAn+suCYF3Ohba++xD12VCLn8Zn sTSYuna1fpRRP0Z1IEuMjZA8RplSAcdoU8BoW60lbCNwd95nkIFXnFW0plgsoRpGa7j2 MHhQ+4rac8mS9Onld9m4NlklPSDdT4WKrTAaquBivCKEWkLbnqlR5eeCYhJGfMwAZMi+ 3ezA== X-Gm-Message-State: AOJu0YytB8FEBNbOSNBu50YQXUDiM0vDB/d6mAWDfQVQfKZ37+vvPqUw EgyV7yC5KzYwFe2l+kU/67tx9+jc+vOVbNHys0aXbfOidBcLDIvH4I8IRD31KNuEFv+ysjVtueA = X-Google-Smtp-Source: AGHT+IHBbqN1/U+XzZX+4N8bxgeJOk6c1eAIgVSTa8crVPRytmmO517g+Q65o96uK1DPbQ0Q+zB9OA== X-Received: by 2002:a05:600c:548c:b0:430:4db0:3fef with SMTP id 5b1f17b1804b1-431bb98f341mr169266075e9.15.1730736709268; Mon, 04 Nov 2024 08:11:49 -0800 (PST) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10e747csm13574463f8f.64.2024.11.04.08.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 08:11:48 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 29/38] ada: Fix crash on default value with nested iterated component associations Date: Mon, 4 Nov 2024 17:11:04 +0100 Message-ID: <20241104161116.1431659-29-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241104161116.1431659-1-poulhies@adacore.com> References: <20241104161116.1431659-1-poulhies@adacore.com> MIME-Version: 1.0 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Eric Botcazou The problem is that the freeze node for the type of the element ends up in the component list of the record type declared with the default value. gcc/ada/ChangeLog: PR ada/113036 * freeze.adb (Freeze_Expression): Deal with freezing actions coming from within nested internal loops present in spec expressions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 9a862176c30..7502a04d517 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -9055,8 +9055,9 @@ package body Freeze is or else Ekind (Current_Scope) = E_Void then declare - Freeze_Nodes : List_Id := No_List; - Pos : Int := Scope_Stack.Last; + Freeze_Nodes : List_Id := No_List; + Pos : Int := Scope_Stack.Last; + Scop : Entity_Id := Current_Scope; begin if Present (Desig_Typ) then @@ -9083,12 +9084,18 @@ package body Freeze is -- If the expression is within a top-level pragma, as for a pre- -- condition on a library-level subprogram, nothing to do. - if not Is_Compilation_Unit (Current_Scope) - and then (Is_Record_Type (Scope (Current_Scope)) - or else (Ekind (Current_Scope) in E_Block | E_Loop - and then Is_Internal (Current_Scope))) - then - Pos := Pos - 1; + if not Is_Compilation_Unit (Scop) then + if Is_Record_Type (Scope (Scop)) then + Pos := Pos - 1; + + else + while Ekind (Scop) in E_Block | E_Loop + and then Is_Internal (Scop) + loop + Pos := Pos - 1; + Scop := Scope (Scop); + end loop; + end if; end if; if Is_Non_Empty_List (Freeze_Nodes) then