[COMMITTED,48/51] ada: Skip layout derivation for C-compatible unchecked union types
| Message ID | 20260602084541.3829876-48-poulhies@adacore.com |
|---|---|
| State | Committed |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 02D9E4BA23D3 for <patchwork@sourceware.org>; Tue, 2 Jun 2026 09:06:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02D9E4BA23D3 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=Tgm18YUV X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id AAB874BA2E11 for <gcc-patches@gcc.gnu.org>; Tue, 2 Jun 2026 08:46:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AAB874BA2E11 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 AAB874BA2E11 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780389996; cv=none; b=mKliAtPhb7qp/8Wsfnqx85Iv8MAlwT1OsidBMoWGc0UIS8N5kGa8SzfRXaCllztB4kxgQivPIcQeeOhhSBtYxhYcOKJ4ioTsbn+oUiwBCdoyxmrfhXLaOdbd/d+lNYETr0D9y0RP1l7KMKWA/Am2JFnr+Nm2nDCL01DF1K3JuLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780389996; c=relaxed/simple; bh=F/lR2MkR5S5rWWGyFRYto7z2N5OxXwcTED9D7I36+AE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kCnXbO8i/9w5sbWyM/2sYqg/fvNfQ8kfZBPxesrSHNMGCCgVBywjIozFsnRaxDTqxdLobJainyq1ee8I/Obzbat9IcbKtl4uAgbJ0xS2cbolWPaMIRRDev5iwTc/RsaoUbCJQaPKhC55IT0EIW7vUv8pp4i+j1FBqwfLwbzwUoA= ARC-Authentication-Results: i=1; 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=Tgm18YUV DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAB874BA2E11 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-45ef29c5561so2122692f8f.0 for <gcc-patches@gcc.gnu.org>; Tue, 02 Jun 2026 01:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1780389995; x=1780994795; 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=4xpNjr8lbFfC+FdicYLAaBTKz6Gq8jRsulx/t/qbD7U=; b=Tgm18YUVYaZHGAZ0LHOh4AE+qtzNBwWHULhmhb8QqCFIv5rzb24tEab/FATpbMS2cV 5RZq4TVHhMmKk57YbHD4tnPRNPxcNYWCNxEKZGc1AVH4NeMlntvd6J6ZUsDvznfRQPIu 5/wzXAz2juNPVVzmwLMWD2K7UqiMcmLKBTmgVgTl1fMJDAjh+pSoCrEDr6kPXhTm8xi8 ywtTl3JefId1o/Tm9cg2RlPg74fWoxssTbd4BW6ZpJ9+WJFD+rRwZk0DmoDt+eB524I7 UVWkUH9vwlHynkwOvqf6qKPFkHkjGhmJzhzQnZbAPkgaCqhKa+5SY3l2JNniOAlc8Ae+ AhnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780389995; x=1780994795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4xpNjr8lbFfC+FdicYLAaBTKz6Gq8jRsulx/t/qbD7U=; b=DVlqv0za7oTrRshIakQEwVwp/h67rWVz0RVp7FqUOS1vpMzaeetUZYDLH/yIxR283g 0iIh5ry5PyhB2nhXUVzwEt0Ljx5El6vJW4pUAb0bPG6Zn7i8T8oXzs3AByi+9RvTPUUd Wh7CVxvba5ibqXzr5RWYWUW4VzdK3I/z0g+aoGCt3SoidNhXFrGDaIwplMYzPHTCd7tw phcPTO5rLkmZ80eWCHtk4xoCOMigVUB8tyHbD9JvbuQJlv2eJrD2MuDR6mTmUywAA5LB vZvaQseaZWp9D06qQ9Quq0KpF8Xz8t6K62Mo5pFVUBmvZceklBDmrHtwFk5ixnNSCLSh Bu1A== X-Gm-Message-State: AOJu0YxqalqSU+N8NuSCzkhuNqSYluFXqdlDTUF7I90EyrScs6mixro8 CcqYxq4mnAjum8IMZrrQzcpJrNPFR/PWb82NGa8si/vVZIgTtBoIIUO1HCdeybBMDiyxf5BhfSZ r854= X-Gm-Gg: Acq92OG4OUw1lPcDkuft8m4CaPgkg349Kx3AOudO69j6Q93Ojy0O+RTQ8LUrqt2xpOF EA5lRgOJRReiJIxSBg7PRtXsaH5hFGhFA2kQyz04W077jwSJWTEnJf1BB7PutJDn7odf166INPr btccguRyE717+w3m4JI11iutoyyA1v0/df759WEC9L3xKfpGv5u5okvxI1ntuPC1SMy/xr/BF+3 lWXuXBDalNLlA2DaZrBHXpbi9SBstO4Nh9YeQGoV0/KDVOIQdusNc0onnfu84mzuQ9WPqpwV7hU nvJuKH1F6zZ5uTNItcPtQKQpnDahL0sPsJrnT/zpDIBQe8UCuQKKpSQxtrQurEHveaL0h05HMNe CuxelqfY/wzGoq9/MoCj5few8tTXWBO2VxapbfrYI8wczbOsD6i8Nml7PdsE8d4Hwl+DoEJeCtn 92RaTfsZ//hE/yl3olBHR7S9dSOG7BAvxpPdFxWyLkmPBPxkI1GQKbHPUgDRNEPb+MwOEMx0Dvb Vg9DGdf+2EOrX7lCbwr6SqH34EcjuEhpZwE1Sluhw== X-Received: by 2002:a05:600c:8a0a:20b0:48f:da34:ec4e with SMTP id 5b1f17b1804b1-490a29303aemr193328615e9.19.1780389995617; Tue, 02 Jun 2026 01:46:35 -0700 (PDT) Received: from mecano.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490ab55d39csm33907625e9.35.2026.06.02.01.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 01:46:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= <poulhies@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou <ebotcazou@adacore.com> Subject: [COMMITTED 48/51] ada: Skip layout derivation for C-compatible unchecked union types Date: Tue, 2 Jun 2026 10:45:36 +0200 Message-ID: <20260602084541.3829876-48-poulhies@adacore.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260602084541.3829876-1-poulhies@adacore.com> References: <20260602084541.3829876-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_BLOCKED, RCVD_IN_PBL, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
[COMMITTED,01/51] ada: Rename Private_Component function
|
|
Commit Message
Marc Poulhiès
June 2, 2026, 8:45 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>
The machinery that computes the layout of derived types does not support
C-compatible unchecked union types, but their layout is fixed in any case.
gcc/ada/ChangeLog:
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Type>: Do not
derive the layout of C-compatible unchecked union types.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/gcc-interface/decl.cc | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 9b64544a2f2..cf6c37f1ca2 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -3551,8 +3551,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) } /* If this is a derived type with discriminants and these discriminants - affect the initial shape it has inherited, factor them in. */ - if (has_discr + affect the initial shape it has inherited, factor them in, but this + is not needed for a C-compatible Unchecked_Union since the variants + are at offset 0 in there. */ + if (TREE_CODE (gnu_type) == RECORD_TYPE + && has_discr && !is_extension && !Has_Record_Rep_Clause (gnat_entity) && Stored_Constraint (gnat_entity) != No_Elist