From patchwork Tue May 16 08:41:33 2023 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: 94545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp277056vqo; Tue, 16 May 2023 01:59:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43cH4V0/vjLL7E2lW1LhqVcT5qCORZTT9LZg75nI57fQXWCuGt7aOczM9CoPqj0ByRZa6E X-Received: by 2002:a05:6402:3456:b0:504:894b:1bc9 with SMTP id l22-20020a056402345600b00504894b1bc9mr26846678edc.26.1684227567042; Tue, 16 May 2023 01:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684227567; cv=none; d=google.com; s=arc-20160816; b=FNHgNLDMqCICkNvSXblRLdReOc0i641MT1LA0tj6IqIJ5PW51rDUvYRoDXPBTfU6oR x8WII9ved3wTGHHrEONPdsOmdeX3wL3YCcan/jCiYvhMqNTXppNSpxpkna0CjBc0SEeq s8MtJkzOq9ssMswsQrWvBrmEqZqNpac1BAEINIcNdEJIipMWnhW6X14WWprRXW6iKPnv gVz5INqxuBwrxp/q8kr13LSRTs9Lvp5swkZWPY0pYVrn0GY+uY+0x0Q4PRSPj0WZv718 HM1lzBlDD/jFrV+QqK1TppMBK3m6y2wyBc9APAyAFdMRvHVsU+zfr52AuKmw75zJhaqL 8/pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=2nqdZDhKXBzqU27LCJvh9eF3B485JGl3PMgV3DMpXt8=; b=cF8Yg0fioYuHCv2Lj5ewziuTB1Bmat/jYRWDV5uEZnSQZoebKicw9QSEZDbRUGgLOI ze+9pK6kyES9lYRJgAngMGO56Clsw0dm/wTG8+4p6qz4iMjLqnAtMGl1OYhXLI18UgFD EsE51e8zHt+c62vGrQockzhDkg4Mlwf5J7njQEZyVQvEqJjwrJ5Kmg60htdGw6IGkF7v wmAUAGOTrXHO/1JP78EorRJZwD0VAWxSLy5rVewYPDocxlHsk+U4Jdi7HnASbPFwl20u ijc+ACjncxc5FPNj6YmkLyQPzRQm9dG0DHaIkJek5vkbx9O2uZ4hT7ahNnyrGohuPywW 76iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wEwCiWEi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n11-20020a05640206cb00b00506b37e7d30si12619590edy.417.2023.05.16.01.59.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:59:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wEwCiWEi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97EB23882AD2 for ; Tue, 16 May 2023 08:52:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97EB23882AD2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684227124; bh=2nqdZDhKXBzqU27LCJvh9eF3B485JGl3PMgV3DMpXt8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=wEwCiWEivwIXbP+v5tmlz2xsE+hMpPyH9njJmnEhWlMoE0GfoqEZJgW1qs6lMoMhz 9T1tqzZ82fNr68TLEdIMEFatVqWaVSHh8oneGuebEZNfDgylWDpyRI+34kDu2LZiQS TQNeN4R7ZF83QWXoG1PBvZE6oTBIQWuQHWrTEfcc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 0589738555BA for ; Tue, 16 May 2023 08:41:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0589738555BA Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f415a90215so112799085e9.0 for ; Tue, 16 May 2023 01:41:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684226496; x=1686818496; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2nqdZDhKXBzqU27LCJvh9eF3B485JGl3PMgV3DMpXt8=; b=gvRbACXLzH3GXG0DG/+ueHI5nB//u2QMWan+CEELo2Dj6iAvzylw8uTE+mfzsBN3bL Slm6GIQ1Pp85mKThVDHNEp70Te0wjGgjU+mdwKHXrOQvuhO+W416sXcR3w7gkcro6Rtp TIpv1o4ZH3c/8xJWuE2JHai6SWbkcJCwsxwjAsraaoC8nItgtgzAHX3RauLnTMctL1ka yCpR7knIW2uJd4GShTpWYr1KGvjE4TdZhMFaVC+bl2BmJBRLzlL87nc1uJCWvFL+2R9O xkiTMa5BHoACG+83K2pvbtF47r6JTCylCSV4H+qws8pKQzXBdj0JsAmejAOlihaXxead Ppiw== X-Gm-Message-State: AC+VfDyRzkM1wD8eBRRsO3BchcDnGyLKe29N2/wOO95gkjQEg0QYWcxP FzEaLiRog5HnkOhKXwx1WQZ6XIwk8j0TW+bEzW7VnA== X-Received: by 2002:a05:600c:b4d:b0:3f4:253f:c3d9 with SMTP id k13-20020a05600c0b4d00b003f4253fc3d9mr18627892wmr.25.1684226495850; Tue, 16 May 2023 01:41:35 -0700 (PDT) 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 v9-20020a05600c214900b003f42158288dsm1539418wml.20.2023.05.16.01.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:41:35 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix crash on iterated component in expression function Date: Tue, 16 May 2023 10:41:33 +0200 Message-Id: <20230516084133.1502396-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766040605151672168?= X-GMAIL-MSGID: =?utf-8?q?1766040605151672168?= From: Eric Botcazou The problem is that the freeze node generated for the type of a static subexpression present in the expression function is incorrectly placed inside instead of outside the function. gcc/ada/ * freeze.adb (Freeze_Expression): When the freezing is to be done outside the current scope, skip any scope that is an internal loop. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 86622003b97..f54ae0503a1 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -8712,17 +8712,19 @@ package body Freeze is -- The current scope may be that of a constrained component of -- an enclosing record declaration, or of a loop of an enclosing - -- quantified expression, which is above the current scope in the - -- scope stack. Indeed in the context of a quantified expression, - -- a scope is created and pushed above the current scope in order - -- to emulate the loop-like behavior of the quantified expression. + -- quantified expression or aggregate with an iterated component + -- in Ada 2022, which is above the current scope in the scope + -- stack. Indeed in the context of a quantified expression or + -- an aggregate with an iterated component, an internal scope is + -- created and pushed above the current scope in order to emulate + -- the loop-like behavior of the construct. -- 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 Nkind (Parent (Current_Scope)) = - N_Quantified_Expression) + or else (Ekind (Current_Scope) = E_Loop + and then Is_Internal (Current_Scope))) then Pos := Pos - 1; end if;