From patchwork Thu Aug 1 15:17:22 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: 1967892 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=QItZoLfp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZYMp5Z6nz1ybV for ; Fri, 2 Aug 2024 01:50:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01AC1384AB4C for ; Thu, 1 Aug 2024 15:50:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 86E48385DDDB for ; Thu, 1 Aug 2024 15:18:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86E48385DDDB 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 86E48385DDDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; cv=none; b=MI2N8I4lkmjk/HBxlQGOCnFXSiwsE5Hbo0LYThfVL6UhzkjmsskqvHoa/3aJc1fbNPhqxekfiBZ9HwGDkIs4FKzrDQrFKr+8QXn9PEhshw+HlMU8mUh767V4bvrUO53UnS2UZRyU8YwaEY6WDtZn5F5VRU6cdHqv1rqRbZWH8IY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; c=relaxed/simple; bh=QfPOAS+MH8PxmBARE1w2XwrT8RmARderG5HOsxdytBw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=i0pkevj9OfeoPxhwseDp6aZjfFsYWxwy8ZDzaN251NU8m1JhbOPSDF1TrQ9ph0M0vAa1rUcCNiyNBndX9o0BgViyjv548UbPdGx571RtCcS11v0u+nI+f8490ahOzqGeetRJ196c38kV8zY0M33CJxGWx4vZfuJkl4W70NHyLFA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4280b3a7efaso47678005e9.0 for ; Thu, 01 Aug 2024 08:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525501; x=1723130301; 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=wdIi3eJH4MCcM7/HcLdAuFJXDsGxvx4HCTidl4bCGFg=; b=QItZoLfpmBj/VYJWE198HZ0nFUeuiMaEVVvvx/+f9vyS2LLKAUCdaN+JMj6Utvv/2I JKXutffGjNxbjSr7aeKmokp23dCGcpL7iUm2IAMI/4qkZUvXZtr2S3myiuGhfzIQZF0w KFDMSjzx4O47RjU2/C/xL5qaY4+U2eUCoK/08Mfz56cW6HPeCuXqj/Gn5YrpOJpydIp3 z1hL4IwJLpznPVQUBwuZWaNnmnM/atf2i2QV5XvojIDlLGDfuKY8lOD4V5kO7srv8Cvt /uiZPqK9AVBo/gq2fWhXnZekUsowEoG8/miTu35bcYGVnqDvpb11KKcGD6CIRJsa/vXH xTxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525501; x=1723130301; 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=wdIi3eJH4MCcM7/HcLdAuFJXDsGxvx4HCTidl4bCGFg=; b=WnIa+/hqiw3A3i9J0BFtOJdT9jVqOv8Hj6bTihr1gew6sKii5weQKYIKmWPK92AGBc QorEbPgSrFV3DQxNO0AUkxwhXQCg1O+Guo4IeHREvA82RUw+Sy/puYJmwVCQ0rNEUy5Q +QQ9YIjhVhdyD7K+HGyg/Uw4qKQrr012HtM0jxpHy6n/VYCd9x4aitg1/HKVsRouZCJW A1ehhsGGDExOt3mZdgA0+pAYFSd7j6aiNjsyJ8xWncZHmhOM9t6BleTVsJ4yQTPc/8N4 cqhryZivlMX1eat8PycybVYzILIb+/WSNxbW8zHRhriLVZ5Bv9EOaTDWbLtwcStNP0Wv uiKA== X-Gm-Message-State: AOJu0YyVNbcM6tq6mmVHsI2jIiofJFt4Iw7QTqzJdGhI0sryu49Fq/oZ KpKCZ+ZyClM4zntGEIDJeGrSfMax6JscDolAXX/+h+s/WYslyRRYxMQhwMwWWz4Vpt8uv2gIJUx 04Q== X-Google-Smtp-Source: AGHT+IGIWus+GZN6pujDT1QVOll63z8OgB3O5lIo8Tovf7s97TqbBMlrWwwUXdhuNZYK/SVD/byEcw== X-Received: by 2002:a05:600c:4711:b0:428:1fa1:7b92 with SMTP id 5b1f17b1804b1-428e6b0fa47mr1492335e9.19.1722525501088; Thu, 01 Aug 2024 08:18:21 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:20 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 14/30] ada: Fix freezing of Default_Value expressions Date: Thu, 1 Aug 2024 17:17:22 +0200 Message-ID: <20240801151738.400796-14-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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 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.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: Piotr Trojanek This patch fixes an infinite loop in freezing that occurred when expression of the Default_Value aspect includes a declare expression with an object of the annotated type. gcc/ada/ * sem_ch13.adb (Check_Aspect_Too_Late): Prevent freezing during preanalysis. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index c8fe7d367c1..3784f831410 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1049,17 +1049,21 @@ package body Sem_Ch13 is Parent_Type : Entity_Id; Save_In_Spec_Expression : constant Boolean := In_Spec_Expression; + Save_Must_Not_Freeze : constant Boolean := Must_Not_Freeze (Expr); begin -- Ensure Expr is analyzed so that e.g. all types are properly -- resolved for Find_Type_Reference. We preanalyze this expression - -- as a spec expression (to avoid recursive freezing), while skipping - -- resolution (to not fold type self-references, e.g. T'Last). + -- (to avoid expansion), handle it as a spec expression (like default + -- expression), disable freezing and skip resolution (to not fold + -- type self-references, e.g. T'Last). In_Spec_Expression := True; + Set_Must_Not_Freeze (Expr); Preanalyze (Expr); + Set_Must_Not_Freeze (Expr, Save_Must_Not_Freeze); In_Spec_Expression := Save_In_Spec_Expression; -- A self-referential aspect is illegal if it forces freezing the