From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f415a90215so112799085e9.0 for ; Tue, 16 May 2023 01:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1684226496; x=1686818496; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2nqdZDhKXBzqU27LCJvh9eF3B485JGl3PMgV3DMpXt8=; b=apdHIcMor8xwVDlcxUYXKwtck5aldcF0l4ORIrhtGPi+Bfy9IePIR42tsd+sJqNVqQ y/qsxh3QVJ+gbuJsJy+FbqEoqnk44SHwE5edHXttXoICl32+jpojgmu+YhfS8z252JL5 TDyqQPE35hzWrpBaaOoEMXytSRpTNlPzIOYpGE3AgtP29XHeZRG8z7wlUYDzlxfTJGl8 6CwqZhnTsoQouyWOgURaM9hOkh+3JCa+DnUCXUMh5vsSNlGRz0XYBVkMQQurZR9yEbCy ho9w11HgPX13aV5q0i92BBUiE6pimD31E7keE1jkQry5t2vmy2X3ciLa+01gikzmxxK8 mAQw== 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-Google-Smtp-Source: ACHHUZ75LgvlZXqS2PItesOh9/FRyPIAMpZKZqOEMBnubgHMvv+Ni+GjOH7u0gjpeIaROW0bOjO1AQ== 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) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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; -- 2.40.0