From patchwork Mon May 6 09:18:14 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: 1931868 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=JsvNSt4X; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4VXwx92KYlz1yZk for ; Mon, 6 May 2024 19:25:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F166385ED40 for ; Mon, 6 May 2024 09:25:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id 4833F3858C62 for ; Mon, 6 May 2024 09:18:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4833F3858C62 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 4833F3858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714987104; cv=none; b=NCMkRjFnbrSSXnjrYrMeGNYLpJKC8YIWwXYIoiwd2zkTzo9NCgE6IinGWnChocUZaGVIVyv1jkAOprGvhFhjkTQ7zrzEhPAlV54dxqo/XRvkMwzoc4HHbLyO8MmxBogOMqFKDGvuSwYBanDLgyU0zSSECwVZTEHkdSQRNh9Sbvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714987104; c=relaxed/simple; bh=GNcOpMuODsKR5NnoCF6Y/d88cG9gKroum1XtClq0Zqo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sRRKrEh0J/I1RhXhixZp3xZaoCKYdOH5pW+5gRDJdRnpNcKyallGXAUmeMPHkgRQKLUEwehTumxIZ3PNAynazOVcmoJhUxll9qMeqVEUekdkYWZAbmj14ukMpBjy/1ay4lk+owaeDh+TmJMbAgx6Fdw+51DXFHm8qnpiywm8G1U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2df9af57b5eso21720301fa.2 for ; Mon, 06 May 2024 02:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1714987097; x=1715591897; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=L6+KGErYlbwU34Yy6eEUgJCXpIFaUGorymIdTeeA5lo=; b=JsvNSt4XeFlhN/F56+xr90Yn4Q+6i4gE7HeTvowcT7ZtHZV4JSzsQgclTCOba9qCXG 1aJIhGBG6IQiqkY1DSA5/MqV8tV+a7hSEl46JFhRZB1BF8JIIwBlsEO4eyaaXR4LJvm9 8czj4Yk3xAQh0jhCO14EBQZZP8Rg6nL23GxXdTfgwsuiYqKIr+r2ujrdXvTcZlk1DAVL JMpDaee42QuMszyVV1UapEdD4crMAHcSquexQobG4g268xR349X4CWTp3CxLS8ZahfRT ZCxL+QHjIQBh/dQlR0Y73Rlp+gVCIFh32PmMXlD/qz0bo9USJe+0kCF3Af67JR473JmB 29mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714987097; x=1715591897; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=L6+KGErYlbwU34Yy6eEUgJCXpIFaUGorymIdTeeA5lo=; b=osgY7mhmYDS8fo+yRTutxCD7G+TqomZL0zZd2Lh0wmiP8i+2VQuHvb6cM0llBtBUas t/UNpsiaPgI1hXv4t3sv1OPsUjDGAvPoRENu4hC9x1O+TXtBfz9LND1XQDitnCIjiZWh eG7PKDMBc5CWaJZclPe6spM3OVG7vTt7GcGdXDPK6GS3uMYVH5J6zTRrteZIbrW1awhW SYkbK62U3oGKfZzRA3dYpL0CtwA388wuZCZk+1ZvqaixR1JLpjnMR5cXq6DufXOEOkmU 7bci5vqXGe8FVoTYGT/IzLNGEkl8ronZ964kKl/JjrgEX6LUL1o0Cvwnuq5beGE87a/I DujA== X-Gm-Message-State: AOJu0YxlYY/LGwxt3pOSy2tzWNjBgzdhIqePQg5c4mtokJtYzmJttgZO q1CHfcpcaHUnJ90IfYhmIEy+Ajxob/F1Lv7xTR/ORPHCj/B8cMowYEXWzDQl/EpaCign81xFHU4 = X-Google-Smtp-Source: AGHT+IG9GoP0d61bnhlAxxycnjxuo1Hg4TZe+Kd7xWXn9GzR5pLeFUaFY8lariqpI/F1fkisR+EZ6w== X-Received: by 2002:a05:651c:105c:b0:2df:1e3e:3280 with SMTP id x28-20020a05651c105c00b002df1e3e3280mr9446466ljm.28.1714987097262; Mon, 06 May 2024 02:18:17 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:9ea2:39d7:df74:396d]) by smtp.gmail.com with ESMTPSA id j3-20020a05600c1c0300b004186f979543sm19244895wms.33.2024.05.06.02.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 02:18:16 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix wrong Finalization_Size for No_Heap_Finalization objects Date: Mon, 6 May 2024 11:18:14 +0200 Message-ID: <20240506091814.1585588-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 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: Eric Botcazou When an access type is subject to the No_Heap_Finalization pragma, no header is added in front of objects allocated through it, and the value returned by Finalization_Size is defined to be the size of this header. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference) : Return 0 if the prefix is a dereference of an access value subject to the No_Heap_Finalization pragma. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_attr.adb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 614f1fbe14d..a8e06f0005e 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -3563,6 +3563,14 @@ package body Exp_Attr is -- Start of processing for Finalization_Size begin + -- If the prefix is the dereference of an access value subject to + -- pragma No_Heap_Finalization, then no header has been added. + + if Nkind (Pref) = N_Explicit_Dereference + and then No_Heap_Finalization (Etype (Prefix (Pref))) + then + Rewrite (N, Make_Integer_Literal (Loc, 0)); + -- An object of a class-wide type first requires a runtime check to -- determine whether it is actually controlled or not. Depending on -- the outcome of this check, the Finalization_Size of the object @@ -3578,7 +3586,7 @@ package body Exp_Attr is -- -- and the attribute reference is replaced with a reference to Size. - if Is_Class_Wide_Type (Ptyp) then + elsif Is_Class_Wide_Type (Ptyp) then Size := Make_Temporary (Loc, 'S'); Insert_Actions (N, New_List (