From patchwork Thu Sep 11 09:18:45 2025 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: 120048 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 32A923858C42 for ; Thu, 11 Sep 2025 09:38:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32A923858C42 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Z/I/Os39 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 313683858C39 for ; Thu, 11 Sep 2025 09:19:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 313683858C39 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 313683858C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582367; cv=none; b=RCN+iO9wnDIkOvxNMdwn0BDW9n6PKuReEJ9ioIhV6OUgT55bohr/O7r4D4Dq9kTX16AocCKJCiz8DAkDguSeHxAx/PjIIMFBnlElXE12NH/AZ/GHQ3BPZtkUrW1SbDtR9ODxdItRf0LD5ZY7VmuVVkCa64klRinOFZEjaHQQhUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582367; c=relaxed/simple; bh=sW7dXfwd8azsHC7btYkgCtUeC3JvkV+jjeNAZvDc42Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jXzsKdmvXR1saDXe2655reGMypPGlmfJTaIPJykRUCUVsIQcZL01PGKwXC15mztRaTDlwlWlq4kxn02n+FnAOYqPTtiDspKXR0AW40fA8PMEujINfGYFHIGRoz5cAVSM8NZyf4458sjKDMBLFmPi9EsiCRkM1P43M/sePJREbXo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 313683858C39 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3d19699240dso910541f8f.1 for ; Thu, 11 Sep 2025 02:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582366; x=1758187166; 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=bUiLTgKyxFtES8mG5Uz5FEtgHH+eWTE/pPsSKuUs6O8=; b=Z/I/Os39QVnzbh6XjJahH5LImOe1EgO/QEqdZIrt1P9FAiPA8A+mnceB5c5eCJZu3g ZP4B5OqkOLKuZ57cvBb/wGnoSgJghUy2Bjmf3v6Uj8Y2hPMafHG+J0xSzpU47uOQg0T6 eVCPbqqabNzfQkEQYnUen+EJOUkt+Ip/cO31O6mFxc/4HdY7LDw/PO0vG8wBR+vdhpHn O8k2hWZLLp7lpnAPZbsht6sYEQlVngYwQQmj/7KGIt9EeckZI5zvnl2w7BjacPDlTX8y TnJ3BTXNutnKZOcENwUl4/0soUFwT+48Q4c3MX9lnIdYsagAJYuPaKCrwK4igQFtTEk9 Atqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582366; x=1758187166; 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; b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1imtgxIHROKuBLxKuJ/Tdu4BwOL+BzxZHX3e3Q7+fA== X-Received: by 2002:a5d:5885:0:b0:3e1:ca94:3199 with SMTP id ffacd0b85a97d-3e75e0eda07mr2434698f8f.14.1757582365710; Thu, 11 Sep 2025 02:19:25 -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-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:25 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 13/31] ada: Crash on b3a1004 with assertions enabled Date: Thu, 11 Sep 2025 11:18:45 +0200 Message-ID: <20250911091904.1505690-13-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 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, URI_HEX 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~patchwork=sourceware.org@gcc.gnu.org From: Javier Miranda The compilation of files b3a10041.ads and b3a10042.adb crash when the compiler is built with assertions enabled. gcc/ada/ChangeLog: * freeze.adb (Freeze_Entity): Protect call to Associated_Storage_Pool since it cannot be used when the Etype is not set. * sem_ch3.adb (Access_Type_Declaration): Ditto. * sem_aux.adb (Is_Derived_Type): Protect call to Root_Type since it cannot be used when the Etype is not set. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 9 ++++++++- gcc/ada/sem_aux.adb | 1 + gcc/ada/sem_ch3.adb | 10 ++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 1bbc24f62fe2..31a583b769e8 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7750,7 +7750,14 @@ package body Freeze is -- Check restriction for standard storage pool - if No (Associated_Storage_Pool (E)) then + -- Skip this check when Etype (T) is unknown, since attribute + -- Associated_Storage_Pool is only available in the root type + -- of E, and in such case it cannot not be computed (thus + -- causing spurious errors). + + if Present (Etype (E)) + and then No (Associated_Storage_Pool (E)) + then Check_Restriction (No_Standard_Storage_Pools, E); end if; diff --git a/gcc/ada/sem_aux.adb b/gcc/ada/sem_aux.adb index 0aa74e39050a..58a4beb221db 100644 --- a/gcc/ada/sem_aux.adb +++ b/gcc/ada/sem_aux.adb @@ -959,6 +959,7 @@ package body Sem_Aux is begin if Is_Type (Ent) + and then Present (Etype (Ent)) and then Base_Type (Ent) /= Root_Type (Ent) and then not Is_Class_Wide_Type (Ent) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index b31587b4bcb1..3317fd209816 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -1476,9 +1476,15 @@ package body Sem_Ch3 is -- This reset is performed in most cases except where the access type -- has been created for the purposes of allocating or deallocating a -- build-in-place object. Such access types have explicitly set pools - -- and finalization collections. + -- and finalization collections. It is also skipped when Etype (T) is + -- unknown, since attribute Associated_Storage_Pool is only available + -- in the root type of T, and in such case it cannot not be computed + -- (thus causing spurious errors). Etype (T) is unknown when errors + -- have been previously reported on T. - if No (Associated_Storage_Pool (T)) then + if Present (Etype (T)) + and then No (Associated_Storage_Pool (T)) + then Set_Finalization_Collection (T, Empty); end if;