From patchwork Mon Sep 15 13:01:19 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: 120267 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 E92B63857C6E for ; Mon, 15 Sep 2025 13:18:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E92B63857C6E 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=T5HZq+j5 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 6E9773856245 for ; Mon, 15 Sep 2025 13:02:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E9773856245 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 6E9773856245 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::434 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757941321; cv=none; b=ib0eyh8HDYisjA75rCTSu1jam/fYvgOIJo1J2qp/E62F0N4dumXg/ZAZ0m2EqqavZvmS+ysZ1nVgl2b9Dz+0E4O1qdg9YDjQLXdfNVLjFREWXBPg+UTFlR49qjxofQIa1AZpK1k+X/3RKXHWrtC7erldDqDg/LGSE9NfWvK0VyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757941321; c=relaxed/simple; bh=kLFG8GWT+oonWJoDVQxRWJt7FVDNCh38deK/Mz5J/aI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rvrbGNfX0cjm0SJM3uRqPN7huaRfs7BGH/w2AG4zj1Ckhtk/AciybdxANgOiEQOXxsw/n/Xh+kOl8YNgijpEtdyn3Bw0gqpi+fUblMWm7kB3swSDD/uInq6Vyc7c6qVYUL44/fNJKpieS/wUHvrENkBmohXHyD5wiVn8C+sYM7E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E9773856245 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3dae49b117bso3234043f8f.1 for ; Mon, 15 Sep 2025 06:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757941320; x=1758546120; 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=x9BWifLXTFlAWooWytR7TCNH6XhV5XeP2urHFOI2wFE=; b=T5HZq+j5LxaVF1rx3BVbnRmAELG2oXKZwBaJOVk2t7CaurSHWRnueXNSaltC55jI3u b1AlYPto1iZ+nuxKlv9ohxMcvkzlPiXR+s1QrD2Xdn5z/pqUdpXSct2K+pw7CmoMiMpy T6MPw2X7R8UxOe5ny7f/vlPn8AvWPnqDjefwPW8DtUHHlc6BQnrzHMP9ZssyZlLs/5VV tgkaDkMKlM4ZQtgQCIcEXXn+JLTl11xkgRC8iNaAHWs22wrIvosNG+fyR27XlhvBl5xl zoejGdrEIL8w27cjku+lwjNLb5rbd9uIUW2eJC9vXxBMx9p32ciqq48jaxN64hQRCxqk VcyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757941320; x=1758546120; 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=x9BWifLXTFlAWooWytR7TCNH6XhV5XeP2urHFOI2wFE=; b=IyEcEDGD4ZflPj+gVDhdj3JV+ohtVq7yZshAhquv2c3NALXSp6PfEuaClfXUD5QhpU 3jDoWpemUIZr/50OCfJ+4dJs9Qb1aYfkZQfUX18oA3RtJM2FtWurapsgtn/hltuEnCcE 8BC7lMx3rkjtUo3MyrkzRGtD8vNci4GwmMJXFFBjzu8olVNMiBhmtDa6wIynD61Pwow5 RNgrKYH/0cvve0ZataNeeKLCBXd4tlIZ1+MZA/8XkIsckCYjGkUmGNj4KxCsjCb14GRG BElo3TBXiVONldehKjpdmcPJpS9ZsTT8hyjzLB9G9IziG3TwZ3P+mRcqqMKOWc1agDJK TTYw== X-Gm-Message-State: AOJu0YxeI/9nDl/YWw7NkZ+lqF79fpt8v8xja5iJeA6iYQh+W0guvkau zZzHVuPL7KWL6+31fBGbda2B3X7p70P/yT5mIa9TRRva3NKpMfmyFDCYgr6gJYymZAm4TXWdm7S EAhU= X-Gm-Gg: ASbGncs56NjltoYzprmUn50JNiEs0YUgZ+SxaD+3Vt78pnweIart3E9oPISIgX9uVHM NmEhoF73K9A7aGhXAtIfjoL4imrY4nMEfet6OtMJ1qAzve/18ZuWM+EJl4+VrC2ndapwtosTO36 hnIXe9en/PDxZZ/h1cJZiH+G70qHA2XrnH8OylthgoQ2E21sSvqcjK1sDCfoLNexeAmEr1kcCpk +e959rwU327wspViIt5jU/3YU5CoJalYdJZavaf7qnJmE1Hj/IJAM38UKTypvG4B7BH43ey1Bce 4xKrITKT308phfZuzMj8kC/i2N+fE1yoEMaldIayjLH9d7aNAhY6qRrI+qifC5s4Uou07GVqIat P6XhVpl/WfBLL5bzDCsB7cfSc/Nk/1Ap3zM4peZTOL406Q9JA3ECp2tFBu102F8yLAtv10XUKpk qhWNw5rRBOFlr5rncBHbBL4M5YU8Gw0UapVgu9CQ== X-Google-Smtp-Source: AGHT+IEc63vkhZvsHh4+Yz0JL63qcd5FvhWLzUVexehCo5vzkbR/Heo3zl+Zhb0Hx+mLDGt78MucNw== X-Received: by 2002:a05:6000:2289:b0:3d8:3eca:a978 with SMTP id ffacd0b85a97d-3e765798616mr11935985f8f.21.1757941319990; Mon, 15 Sep 2025 06:01:59 -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-3ea4b52b7fcsm5428733f8f.33.2025.09.15.06.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Sep 2025 06:01:59 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 13/27] ada: Fix crash on iterator of type with Constant_Indexing aspect Date: Mon, 15 Sep 2025 15:01:19 +0200 Message-ID: <20250915130135.2720894-13-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915130135.2720894-1-poulhies@adacore.com> References: <20250915130135.2720894-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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~patchwork=sourceware.org@gcc.gnu.org From: Eric Botcazou This happens when the type returned by the indexing function is a private type whose completion is derived from another private type, because the Finalize_Address routine cannot correctly fetch the actual root type. gcc/ada/ChangeLog: * exp_util.adb (Finalize_Address): In an untagged derivation, call Root_Type on the full view of the base type if the partial view is itself not a derived type. (Is_Untagged_Derivation): Minor formatting tweak. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_util.adb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 4135e24424d3..78fb3167c82d 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -6206,7 +6206,11 @@ package body Exp_Util is Utyp := Corresponding_Record_Type (Root_Type (Btyp)); elsif Is_Implicit_Full_View (Utyp) then - Utyp := Underlying_Type (Root_Type (Btyp)); + if Is_Derived_Type (Btyp) then + Utyp := Underlying_Type (Root_Type (Btyp)); + else + Utyp := Underlying_Type (Root_Type (Full_View (Btyp))); + end if; if Is_Protected_Type (Utyp) then Utyp := Corresponding_Record_Type (Utyp); @@ -10033,7 +10037,8 @@ package body Exp_Util is begin return (not Is_Tagged_Type (T) and then Is_Derived_Type (T)) or else - (Is_Private_Type (T) and then Present (Full_View (T)) + (Is_Private_Type (T) + and then Present (Full_View (T)) and then not Is_Tagged_Type (Full_View (T)) and then Is_Derived_Type (Full_View (T)) and then Etype (Full_View (T)) /= T);