From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id A9B5F388A40D for ; Thu, 20 Jun 2024 08:53:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A9B5F388A40D 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 A9B5F388A40D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718873639; cv=none; b=LR4Dtx2WzkqOhpNpYSvlktRDCDFS5tdHwS7iZwLMHGFD5XcNSIjD4/E7H048AdkmxAQuVbAJB4QkPeGR0FR8wFbdehm2gFhgPbvQfHPZOFZRyyM+rtb2Si5Vjve5afqT54knCDxzHV5BZtf8KD0qrkThj7byRpdW7JC1v+PCv+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718873639; c=relaxed/simple; bh=wq0XDazx0inZwEwGdRQnUjm0GTMkOTdqBuMVpaCaMfs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qGLPhYSwLB0LUhUrn2ClA0G0wHFbPDQrWNhm6tjY8gXSvHtuwu1LLJ7LrBjfyW1EEvI7n+fBTc9EP561lf7BSWL17O8fk/+g2N99ipAPM03eqwb/e8HAKTVZ6CVJ1q+EFfPKWoO8rW05cPOsKtSYvukmmL/wbq22ep3ZQOc9LWQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52cc9b887f1so775251e87.3 for ; Thu, 20 Jun 2024 01:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718873628; x=1719478428; 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=/3JpYcsiHaE8rBFMlAjqJ993iHUqwK4JxkXpAPViq8M=; b=JShVEDXZK/6WAoeLGbTV+LMr2M8oGkm0O9uWsS3HLEEJUWP5V8caq77zP8qjQUBtDt 9qRdm2nQT5yfK3twxhxOhRz6+JiUJMLdGsuWeAlutFC7C6DSiY8fnTg9NIVL1o+ENZmV gGtS3JHn84SEZH/LHxJjGd4ou5yY4/A8F2Ar0T+YIqCjY4nSmCR91+0IS+9wagZTkV9b a3Uxz9ZE/9fv8FCJEwYlHehCF8Obwy0wmKSuamc7YJrIq+rGXxMUWznxlRKzE2OudRsD Mo44aueAj6LmG6eqCcJaHcZTDNZdQP+DntfNuOuetjwBw84nc/In+Xv2vyshdYrHmK/k qT4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718873628; x=1719478428; 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=/3JpYcsiHaE8rBFMlAjqJ993iHUqwK4JxkXpAPViq8M=; b=POsFvhbEyMm/T+U9a0Qz7B7ryvyaqlC47GLxdo3l+SuDXL0D3RUlMMRrV3hEhfOBWW VMWARveXcKtAFwJWeSF0qAU6y4BSKTe2b9FD/nJ7HwT5JgxwPJEGCGu3JtLbWhgvaR2h iM01Ly7v3HqlohLNEHfiPf6SEGK9nxAMzcZCkrciFT/yK6SGTQkN1CEc0BFOlrN3B93C z9rgEyKcmvdEuoKRxz+SLaZUjAkvsd2qP+FABmZ3QB03/D1YCtoaOwL2M2xvmUBYwKm4 Dfj6i141JTqH7p16ZbebcXOuyvbdVE9j26iBOM2ExU+sPlWYCZlTx0H71NTyB3eSaU1y S80Q== X-Gm-Message-State: AOJu0YwKVFq5E1SDF3ap3F3kmrK0/8XcdgzO9CKrUuspWDVjk+BMRezz bXxZBe93TA68sUnPZgHqXzulRB0Hz+7ArcjHJj+bpOz7C/B0w9h/HwNviq0isnOXPLH/UCONGpU = X-Google-Smtp-Source: AGHT+IEAMXJNcg2SMN1ngGOE6Ooe7XnLeZL2Wk0zYrNefBznPje5aR4WrB9CGFw5/TjTGscCS7mzYQ== X-Received: by 2002:ac2:52b2:0:b0:52b:796e:66a5 with SMTP id 2adb3069b0e04-52ccaaa2607mr2514503e87.66.1718873627935; Thu, 20 Jun 2024 01:53:47 -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 ffacd0b85a97d-363c795febfsm3305522f8f.104.2024.06.20.01.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 01:53:47 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 20/30] ada: Fix crash on real literal in declare expression of expression function Date: Thu, 20 Jun 2024 10:53:10 +0200 Message-ID: <20240620085321.2412421-20-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240620085321.2412421-1-poulhies@adacore.com> References: <20240620085321.2412421-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 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 of the type to which the real literal is resolved is placed inside the expression function instead of outside. gcc/ada/ * freeze.adb (Freeze_Expression): Also attach pending freeze nodes to the parent in the case of an internal block in a spec expression. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 3c3d038c392..1867880b314 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -8872,7 +8872,8 @@ package body Freeze is end if; -- The current scope may be that of a constrained component of - -- an enclosing record declaration, or of a loop of an enclosing + -- an enclosing record declaration, or a block of an enclosing + -- declare expression in Ada 2022, or of a loop of an enclosing -- 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 @@ -8884,7 +8885,7 @@ package body Freeze is if not Is_Compilation_Unit (Current_Scope) and then (Is_Record_Type (Scope (Current_Scope)) - or else (Ekind (Current_Scope) = E_Loop + or else (Ekind (Current_Scope) in E_Block | E_Loop and then Is_Internal (Current_Scope))) then Pos := Pos - 1; -- 2.45.1