From patchwork Tue May 21 07:30: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: 90544 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 4C9CF384AB53 for ; Tue, 21 May 2024 07:38:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 02F4E3858CDB for ; Tue, 21 May 2024 07:31:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 02F4E3858CDB 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 02F4E3858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716276667; cv=none; b=hSA9vqRydsp7jRx7RayD7CeT2qqmQZTu3nCeUmqtg/lDZ3XECD6LALFyMq4NCOakIbnC7F/B4+9De5jb086WjO0dExn0n9/nQTo2KjS7dpEkKyyVg78DIB+HOmnPI6Ksu0iPvXSSRE/DvYlWNY80CHPdXJi+nTCUM2PLL39uiQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716276667; c=relaxed/simple; bh=6cNQWvPndZxn1uEBk6Xf2a0To2aqdSOb81todAntLOM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WWSSQxQH+7dmHkekpRm4BBBKYNBV81VuhMdpVeDOL/DXev0/iGNF5RM3dyvVJM9hhW2DXK0iEWifMivvQHavVyATKGFOhYzsH6zDRBgPtYmyUUvU97igjrIXAzVgWLe8arBrasUixIZ+KCn8Ncsa2YiHK4g0Jh2zJs0t4GqQi/o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4202cea98daso27538305e9.0 for ; Tue, 21 May 2024 00:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1716276662; x=1716881462; 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=i1iuHneDgsuTxmhLXxqu75W7ltdc2T57viUTyPg3N+I=; b=kUgU7V7Z3S/AeVt0M299xiv6nNrtyIMIRnn6cXQ6vts0knpsX9NTadbbKJ23zbSe5L xDc5waEafDwf43hLSYeyFni+63xwsop9Gf9nDVDCyQXJgvNz4GBe3YsV8snylRXqoFVI KXFzSkfpw/rpcKA5lfpAkJMOOwc9IkDIreevfRvgBYjXrWVWpEsGOxFN0G8QmlZaiG2b kZXgSOHy9k1QG86W8TfKWuwzeFLeIXGhZk+X01rywmRODbppjgR61MHilu9ayUN0qXTw LPyXmGw7sn1IVxC28ElkEIEIfMjT6bgm/MBAbD3Dvm8Z9/hze0SCLJpHbkAxbH1IxZi3 sFYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716276662; x=1716881462; 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=i1iuHneDgsuTxmhLXxqu75W7ltdc2T57viUTyPg3N+I=; b=VHMIA3Zkhu4AerVVbV6PByS5MOUi196w070A7Gu+LKOf8i7gBui1F2L3usP2xw56yK fz05VdsrNmGF76Gw32hUw8jvF8DO+8/CIlYlFNQFBUDPW1yJasjPejsVgYGsfo9MpmlY brJ7p1ZtIeSuPtVUMGcTj5mTeGt5uOdReEleoreR1pcRL50Y4CM8BbqWSUt5IAmNqDeT dPOS8jlMNBf3+00dyjdhp0ckptxeA+6LScTryDSFWwH0Y+4yYK0nLD7iLFU3SFOTG0AF ZBI+cCjQQQPjPt3VG9Fg6GUT1H60bBjfYDnKWcDUAJBzAO6/SgaMEJdY769VDxrm04po MvlA== X-Gm-Message-State: AOJu0Yz/fXcCgw0PcfNepdA4bPSh3NaBfHWin9egZXrWvXjAsjBmf8nx MzYFzbBHO1jk25x/8sO44UwEoAjGNSZN932oKHQ13KhigIL7V57X/u7MF5Hx59UZuO1KHoTS1UI = X-Google-Smtp-Source: AGHT+IF8Gwt4dmijvIT2YVrg/aTJ2NHnEiwJZqYzQ6s8vLwncyDwXEAC0u4ArjvKh1ZG7P4rrJ6ubg== X-Received: by 2002:a05:600c:444e:b0:418:9d5a:f680 with SMTP id 5b1f17b1804b1-41feac56006mr244426925e9.25.1716276662559; Tue, 21 May 2024 00:31:02 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:de37:8b1c:1f33:2610]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccee9292sm453333645e9.37.2024.05.21.00.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 00:31:02 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 19/31] ada: Fix crash on aliased constant with packed array type and -g switch Date: Tue, 21 May 2024 09:30:22 +0200 Message-ID: <20240521073035.314024-19-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240521073035.314024-1-poulhies@adacore.com> References: <20240521073035.314024-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 The problem is that we build a template whose array field is not an array in the case of an aliased object with nominal unconstrained array subtype. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : For an array allocated with its bounds, make sure to have an array type to build the template. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/decl.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index ca174bff009..41d5c29a17c 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -939,6 +939,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) && !type_annotate_only) { tree gnu_array = gnat_to_gnu_type (Base_Type (gnat_type)); + /* Make sure to have an array type for the template. */ + if (TYPE_IS_PADDING_P (gnu_type)) + gnu_type = TREE_TYPE (TYPE_FIELDS (gnu_type)); gnu_type = build_unc_object_type_from_ptr (TREE_TYPE (gnu_array), gnu_type,