From patchwork Thu Aug 1 15:17:09 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: 1967842 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=c4Kw+Wav; 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 4WZY336VfXz1ybX for ; Fri, 2 Aug 2024 01:36:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1BFB93865C21 for ; Thu, 1 Aug 2024 15:36:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id DBA11386481C for ; Thu, 1 Aug 2024 15:17:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBA11386481C 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 DBA11386481C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525483; cv=none; b=Tpgo5fF9no8pZ0rjpyW6orua0vaEDZ/10og/kVVE1KZq9KcFQNkAnnpSIKJoeCdeaBW7geLtu1dYmZ7VdUY28E3Hu/gSdx0VUf2RkkSmDPBqa1Yq9FG2H7AE9q1TnF9BEQmSV3iBIpnaux8nDu1EE6cLjAnfhnwnihI4ONFbERw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525483; c=relaxed/simple; bh=mEAZ1Wn/acTABHA0M3Xclmwm4fZB2Vf4c01rC8iBhsE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=huG4qP9TZa6NfmwWjlchVu6tpdt395BhbKXxYqKNz1WSZESDU4YvoVlCJaFJ0N9Z4/o4pHAAHDRn2sVAyY1fKRLQi/+C7RXQH8sXLoNaumdxgoYDMzP0pK95JLA64S6QTGMPSVDZ6nEtwmI60uqXNiLD/0ZSPC/lBIb7obrTZHc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4281c164408so39763325e9.1 for ; Thu, 01 Aug 2024 08:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525470; x=1723130270; 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=qn1uVeD5sQ1JK5RC4mIXRXXJ0iDWab/DwtUqHq7mCQY=; b=c4Kw+Wav4AIDG1pDNkbKuUR58n8lUOzQkS1YFpnMohhlkSVNTS+CUbshSDxVjBrrK8 eh/8Lf+0U3Zo3u++3hhUl1n10Zx/dmgDIQhOifixOZINoTyLVOn8f4JgRdLQNI6A/QtV 0BMWq+fIh+waARcyyhhJ/LKe/HJzFYWffAugUApB3Kb4ZupPRRTJnmkoyB1C1q6OznLI q9Sbz2BLZ18u7fxMa8u91bGbBnpUb8bjVx9ELskVLV/S/g7th47l561VHhWs8g+YhV2B 9CEx75vpnHn4OYa/USGnGWOAZ43v2xeKDoE6qw2MfbAPcAWBj9W0oAqYNw07EAAKzbQg K3Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525470; x=1723130270; 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=qn1uVeD5sQ1JK5RC4mIXRXXJ0iDWab/DwtUqHq7mCQY=; b=CbJ4SZzxwx4SZnR9STqTLeJvpC/uh8NzDaAcvW+Gz72Qm8PMJZv99CHH04RUsILXSg mCqshf980pHoZbkV36IIPY6jVm5my8/PX4lyhmIpJZiqOwpsND/g/8CFJToDEfHUWDUk OKFCkK05+JQ9I6CKW+iZh9sOcLpCM457va8SP8lf0xrTArSkAL+L94SQDY+pnVLzGcLF PlZ+eb0cdLTt6QbzH8DOMD3nOGlkmpwmjwXXsVQOLJJUuFVRVZMin7njgmNSVWi21k2d zEDQ7a9OBhVSWFREVHimtRRSdK6zsi8R0bFtqc1jCH8eEeyXHrpkQgpaSY3KiqX/I76i afLg== X-Gm-Message-State: AOJu0YzO3iF87xNSD5KRPsGAKKufvPVaCccJ+KTqA34P220tDZ2boVnh easFZeT7Ci+HDmryPVuapAZzI9wr4KZoeZGveFMWh8q6AdJDS8zPGC8fYY3qJZHevaILC7jRcfD E9Q== X-Google-Smtp-Source: AGHT+IHgEXWDj3ynhn+UVEjPjTlbPQby1z4YczqlpIMtCYtkKNm3145MIV00aWdYhr6R0RyqockR7Q== X-Received: by 2002:adf:e644:0:b0:365:980c:d281 with SMTP id ffacd0b85a97d-36bbc1bcce8mr104272f8f.45.1722525469834; Thu, 01 Aug 2024 08:17:49 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:49 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 01/30] ada: Remove obsolete workaround Date: Thu, 1 Aug 2024 17:17:09 +0200 Message-ID: <20240801151738.400796-1-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_FILL_THIS_FORM_SHORT 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 It is possible to call the "+" operator of System.Storage_Elements directly as done for example in Expand_Interface_Thunk. gcc/ada/ * exp_ch7.adb (Make_Address_For_Finalize): Generate a direct call to the "+" operator of System.Storage_Elements. (Make_Finalize_Address_Stmts): Likewise. * rtsfind.ads (RE_Id): Remove RE_Add_Offset_To_Address. (RE_Unit_Table): Remove entry for RE_Add_Offset_To_Address. * libgnat/s-finpri.ads (Add_Offset_To_Address): Delete. * libgnat/s-finpri.adb (Add_Offset_To_Address): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch7.adb | 37 ++++++++++++++++++++---------------- gcc/ada/libgnat/s-finpri.adb | 12 ------------ gcc/ada/libgnat/s-finpri.ads | 7 ------- gcc/ada/rtsfind.ads | 2 -- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index f4a707034c1..454f74507f4 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -5351,23 +5351,25 @@ package body Exp_Ch7 is -- V - (Obj_Typ'Descriptor_Size / Storage_Unit) - -- Note that this is done through a wrapper routine as RTSfind - -- cannot retrieve operations with string name of the form "+". - Obj_Addr := Make_Function_Call (Loc, Name => - New_Occurrence_Of (RTE (RE_Add_Offset_To_Address), Loc), + Make_Expanded_Name (Loc, + Chars => Name_Op_Subtract, + Prefix => + New_Occurrence_Of + (RTU_Entity (System_Storage_Elements), Loc), + Selector_Name => + Make_Identifier (Loc, Name_Op_Subtract)), Parameter_Associations => New_List ( Obj_Addr, - Make_Op_Minus (Loc, - Make_Op_Divide (Loc, - Left_Opnd => - Make_Attribute_Reference (Loc, - Prefix => New_Occurrence_Of (Obj_Typ, Loc), - Attribute_Name => Name_Descriptor_Size), - Right_Opnd => - Make_Integer_Literal (Loc, System_Storage_Unit))))); + Make_Op_Divide (Loc, + Left_Opnd => + Make_Attribute_Reference (Loc, + Prefix => New_Occurrence_Of (Obj_Typ, Loc), + Attribute_Name => Name_Descriptor_Size), + Right_Opnd => + Make_Integer_Literal (Loc, System_Storage_Unit)))); end if; return Obj_Addr; @@ -8105,14 +8107,17 @@ package body Exp_Ch7 is -- start of the elements: -- -- V + Dnn - -- - -- Note that this is done through a wrapper routine since RTSfind - -- cannot retrieve operations with string names of the form "+". Obj_Expr := Make_Function_Call (Loc, Name => - New_Occurrence_Of (RTE (RE_Add_Offset_To_Address), Loc), + Make_Expanded_Name (Loc, + Chars => Name_Op_Add, + Prefix => + New_Occurrence_Of + (RTU_Entity (System_Storage_Elements), Loc), + Selector_Name => + Make_Identifier (Loc, Name_Op_Add)), Parameter_Associations => New_List ( Obj_Expr, New_Occurrence_Of (Dope_Id, Loc))); diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb index bc90fe23ac9..9767090cb4a 100644 --- a/gcc/ada/libgnat/s-finpri.adb +++ b/gcc/ada/libgnat/s-finpri.adb @@ -60,18 +60,6 @@ package body System.Finalization_Primitives is -- Unlock the finalization collection, i.e. relinquish ownership of the -- lock to the collection. - --------------------------- - -- Add_Offset_To_Address -- - --------------------------- - - function Add_Offset_To_Address - (Addr : System.Address; - Offset : System.Storage_Elements.Storage_Offset) return System.Address - is - begin - return System.Storage_Elements."+" (Addr, Offset); - end Add_Offset_To_Address; - --------------------------------- -- Attach_Object_To_Collection -- --------------------------------- diff --git a/gcc/ada/libgnat/s-finpri.ads b/gcc/ada/libgnat/s-finpri.ads index a821f1db657..851917b5924 100644 --- a/gcc/ada/libgnat/s-finpri.ads +++ b/gcc/ada/libgnat/s-finpri.ads @@ -171,13 +171,6 @@ package System.Finalization_Primitives with Preelaborate is private - -- Since RTSfind cannot contain names of the form RE_"+", the following - -- routine serves as a wrapper around System.Storage_Elements."+". - - function Add_Offset_To_Address - (Addr : System.Address; - Offset : System.Storage_Elements.Storage_Offset) return System.Address; - -- Finalization masters: -- Master node type structure. Finalize_Address comes first because it is diff --git a/gcc/ada/rtsfind.ads b/gcc/ada/rtsfind.ads index f4566b4846f..8c0c9045360 100644 --- a/gcc/ada/rtsfind.ads +++ b/gcc/ada/rtsfind.ads @@ -919,7 +919,6 @@ package Rtsfind is RE_Attr_Long_Long_Float, -- System.Fat_LLF - RE_Add_Offset_To_Address, -- System.Finalization_Primitives RE_Attach_Object_To_Collection, -- System.Finalization_Primitives RE_Attach_Object_To_Master, -- System.Finalization_Primitives RE_Attach_Object_To_Node, -- System.Finalization_Primitives @@ -2571,7 +2570,6 @@ package Rtsfind is RE_Attr_Long_Long_Float => System_Fat_LLF, - RE_Add_Offset_To_Address => System_Finalization_Primitives, RE_Attach_Object_To_Collection => System_Finalization_Primitives, RE_Attach_Object_To_Master => System_Finalization_Primitives, RE_Attach_Object_To_Node => System_Finalization_Primitives, From patchwork Thu Aug 1 15:17:10 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: 1967829 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=jnjm7/Wf; 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 4WZY0V63Lzz1yZv for ; Fri, 2 Aug 2024 01:34:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2038A386183A for ; Thu, 1 Aug 2024 15:34:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 8A0E9385DDFA for ; Thu, 1 Aug 2024 15:17:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A0E9385DDFA 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 8A0E9385DDFA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525476; cv=none; b=c4doKxT0RAR42JnJfe9Ikx+7OPoQdBKWWhgxK7r6DXvTuTGUYqZcGiekhSwWGBOIBybPakryjfs7J8lzTbRIRNFeCsOEkY82NyQ6SRG2zn6M03IPJFlwUwZyZQbG/rvHkPDBfH9+NaNtFgQiii9smJIV3UvaWL1zsFPLsHj8bJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525476; c=relaxed/simple; bh=Hsi5AY1AY7Iz/opGauyVotsTrXUZqO+3ITsEXCIz1R8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Img/XS7VC8gRgP3Mtv/tuBaO7rEbc7C3NGRaFVFBCPwGHaht9HeNwpDK00wKF9XiGBplIxU6UQPSgB80pvV/tYk+R6FoMjFkygYG61rLuVctjWkR3VQpZoCjmwdX7VPynLbKAPKNy4A5kyStlqDdpgqBSqwtjD8t0gSVCgOYzlg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3683178b226so3385001f8f.1 for ; Thu, 01 Aug 2024 08:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525471; x=1723130271; 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=Mtp81k08D4cH3zhfhqUy/RAtXicITr8GXzHW9tLT5us=; b=jnjm7/Wfauxj9bSV5cq/SXDaiH42BPu5mfs1RhhIQopA5bYTcCxoPaA49KmJBjIhDU Bk+zDeIValHPpfGMJ3SD+LVmiVD/EWcDIIjn/C7VUa244qyW2KM3xNunxjb0xH9jzn3w qPx0bUsNrOGCI2J5Ap7/LiduSS5UBiO3CgI6bLYWybTgQ/l8Xg5fEHKTkvATOufuto3M t4xWH9L3dxhtw+VuTvBeeg4cdEagNdnuJQ58VvN965PfJakjFYnD7eoeymNn93raVEFf JpmaVsEhLgLeD79CerHSXpGMoqMfkIH5E0x9X2zh8TuNLb9p6p8WO8D9ReS3ccYPT/6j zx6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525471; x=1723130271; 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=Mtp81k08D4cH3zhfhqUy/RAtXicITr8GXzHW9tLT5us=; b=ja4Xi5ayXNQo076oXRSph2AgwkYiuOD/bnKDl/tfwgbRdmrrO9W9QnLTKmkzGCqoF4 mFLvD69yLa6714Y9D8FUYhh4s6BDe4fXQFZYqGTBpUFwNzzJ7NsiNwWq7wezsZogvEM/ nW9rLoDZw9bEojoeVtzYaS4WFow9J2Z9Ed5G4VRaFCVQuFwvaXXmMRbo/+lIKzpHP7P/ iPVAMATLdO6VJTfZGtjRMuuLDWKi/K6hga8CuaMAtTgjX+IGl2q6y6pZofSvQJkB8UD/ UoQLVdbu2DKVTVKDk/owacws+99MH56z08toEtT1pPOpFGAWu39SkVcaksN8hM6O/mKs FYxA== X-Gm-Message-State: AOJu0YxHAs1JQpaHKfztUu3YrPxx2M6z9NUKyV0+A9jSvbGjMHLx/Jaz glXGeVu9yRPMi+wzed51ONFPczkX2hAaaXia0kJfMriSUzkBHH7RgL4JymkxVc2eQm8QQOGm1XD xYA== X-Google-Smtp-Source: AGHT+IHweGd8ur0iYhEay/98HRFyrq5wiUNsjbBypbYHmNa2mRkCRsADgJYy+vQmLmxVQm/P50L49Q== X-Received: by 2002:a05:6000:1e97:b0:368:74e0:2068 with SMTP id ffacd0b85a97d-36bbc0fcb38mr138763f8f.33.1722525470999; Thu, 01 Aug 2024 08:17:50 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:50 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 02/30] ada: Couple of cleanups in finalization machinery Date: Thu, 1 Aug 2024 17:17:10 +0200 Message-ID: <20240801151738.400796-2-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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 This removes a parameter and a variable that are entirely determined by another parameter and another variable respectively. gcc/ada/ * exp_ch7.ads (Build_Finalizer): Remove Top_Decls parameter. * exp_ch7.adb (Build_Finalizer): Likewise. Rename Counter_Val into Count, replace Has_Ctrl_Objs local variable by expression function, remove Spec_Decls local variable and do not reset Finalizer_Decls. (Expand_Cleanup_Actions): Adjust call to Build_Finalizer. (Expand_N_Package_Body): Likewise. (Expand_N_Package_Declaration): Likewise. * inline.adb (Cleanup_Scopes): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch7.adb | 56 ++++++++++++++++++--------------------------- gcc/ada/exp_ch7.ads | 9 +++----- gcc/ada/inline.adb | 1 - 3 files changed, 25 insertions(+), 41 deletions(-) diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 454f74507f4..16d53853646 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -1696,7 +1696,6 @@ package body Exp_Ch7 is (N : Node_Id; Clean_Stmts : List_Id; Mark_Id : Entity_Id; - Top_Decls : List_Id; Defer_Abort : Boolean; Fin_Id : out Entity_Id) is @@ -1716,7 +1715,7 @@ package body Exp_Ch7 is -- structures right from the start. Entities and lists are created once -- it has been established that N has at least one controlled object. - Counter_Val : Nat := 0; + Count : Nat := 0; -- Holds the number of controlled objects encountered so far Decls : List_Id := No_List; @@ -1735,10 +1734,6 @@ package body Exp_Ch7 is Finalizer_Stmts : List_Id := No_List; -- The statement list of the finalizer body - Has_Ctrl_Objs : Boolean := False; - -- A general flag which denotes whether N has at least one controlled - -- object. - Has_Tagged_Types : Boolean := False; -- A general flag which indicates whether N has at least one library- -- level tagged type declaration. @@ -1753,7 +1748,6 @@ package body Exp_Ch7 is -- The private declarations of N if N is a package declaration Spec_Id : Entity_Id := Empty; - Spec_Decls : List_Id := Top_Decls; Stmts : List_Id := No_List; Tagged_Type_Stmts : List_Id := No_List; @@ -1772,6 +1766,9 @@ package body Exp_Ch7 is -- Create the spec and body of the finalizer and insert them in the -- proper place in the tree depending on the context. + function Has_Ctrl_Objs return Boolean is (Count > 0); + -- Return true if N contains a least one controlled object + function New_Finalizer_Name (Spec_Id : Node_Id; For_Spec : Boolean) return Name_Id; -- Create a fully qualified name of a package spec or body finalizer. @@ -1783,7 +1780,7 @@ package body Exp_Ch7 is -- Inspect a list of declarations or statements which may contain -- objects that need finalization. When flag Preprocess is set, the -- routine will simply count the total number of controlled objects in - -- Decls and set Counter_Val accordingly. + -- Decls and set Count accordingly. procedure Process_Object_Declaration (Decl : Node_Id; @@ -1813,7 +1810,7 @@ package body Exp_Ch7 is -- this common case, we'll directly finalize the object. if Has_Ctrl_Objs then - if Counter_Val > 1 then + if Count > 1 then if For_Package_Spec then Master_Name := New_External_Name (Name_uMaster, Suffix => "_spec"); @@ -1856,12 +1853,8 @@ package body Exp_Ch7 is if Exceptions_OK then Finalizer_Decls := New_List; - Build_Object_Declarations (Finalizer_Data, Finalizer_Decls, Loc, For_Package); - - else - Finalizer_Decls := No_List; end if; end if; @@ -1995,9 +1988,10 @@ package body Exp_Ch7 is -- -- -- Added if Mark_Id exists -- Abort_Undefer; -- Added if abort is allowed + -- -- end Fin_Id; - if Has_Ctrl_Objs and then Counter_Val > 1 then + if Has_Ctrl_Objs and then Count > 1 then Fin_Call := Make_Procedure_Call_Statement (Loc, Name => @@ -2155,10 +2149,10 @@ package body Exp_Ch7 is -- Non-package case else - pragma Assert (Present (Spec_Decls)); + pragma Assert (Present (Decls)); - Append_To (Spec_Decls, Fin_Spec); - Append_To (Spec_Decls, Fin_Body); + Append_To (Decls, Fin_Spec); + Append_To (Decls, Fin_Body); end if; Analyze (Fin_Spec, Suppress => All_Checks); @@ -2235,10 +2229,9 @@ package body Exp_Ch7 is (Decl : Node_Id; Is_Protected : Boolean := False); -- Depending on the mode of operation of Process_Declarations, either - -- increment the controlled object counter, set the controlled object - -- flag and store the last top level construct or process the current - -- declaration. Flag Is_Protected is set when the current declaration - -- denotes a simple protected object. + -- increment the controlled object count or process the declaration. + -- The Flag Is_Protected is set when the declaration denotes a simple + -- protected object. -------------------------- -- Process_Package_Body -- @@ -2283,8 +2276,7 @@ package body Exp_Ch7 is else if Preprocess then - Counter_Val := Counter_Val + 1; - Has_Ctrl_Objs := True; + Count := Count + 1; else Process_Object_Declaration (Decl, Is_Protected); @@ -2572,7 +2564,7 @@ package body Exp_Ch7 is if Is_RTE (Obj_Typ, RE_Master_Node) then Master_Node_Id := Obj_Id; - if Counter_Val = 1 then + if Count = 1 then if Nkind (Next (Decl)) = N_Call_Marker then Prepend_To (Decls, Remove_Next (Next (Decl))); end if; @@ -2591,7 +2583,7 @@ package body Exp_Ch7 is else pragma Assert (No (Finalization_Master_Node (Obj_Id))); -- For one object, use the Sloc the master would have had - if Counter_Val = 1 then + if Count = 1 then Master_Node_Loc := Sloc (N); else Master_Node_Loc := Loc; @@ -2605,7 +2597,7 @@ package body Exp_Ch7 is Master_Node_Id, Obj_Id); Push_Scope (Scope (Obj_Id)); - if Counter_Val = 1 then + if Count = 1 then Prepend_To (Decls, Master_Node_Decl); else Insert_Before (Decl, Master_Node_Decl); @@ -2849,7 +2841,7 @@ package body Exp_Ch7 is -- procedure and then attach the Master_Node to the master, unless -- there is a single controlled object. - if Counter_Val = 1 then + if Count = 1 then -- Finalize_Address is not generated in CodePeer mode because the -- body contains address arithmetic. So we don't want to generate -- the attach in this case. Ditto if the object is a Master_Node. @@ -3090,8 +3082,7 @@ package body Exp_Ch7 is if Has_Ctrl_Objs and then No (Decls) then Set_Declarations (N, New_List); - Decls := Declarations (N); - Spec_Decls := Decls; + Decls := Declarations (N); end if; -- The current context may lack controlled objects, but require some @@ -4650,9 +4641,9 @@ package body Exp_Ch7 is end if; declare - Decls : constant List_Id := Declarations (N); Fin_Id : Entity_Id; Mark : Entity_Id := Empty; + begin -- If we are generating expanded code for debugging purposes, use the -- Sloc of the point of insertion for the cleanup code. The Sloc will @@ -4690,7 +4681,7 @@ package body Exp_Ch7 is declare Mark_Call : constant Node_Id := Build_SS_Mark_Call (Loc, Mark); begin - Prepend_To (Decls, Mark_Call); + Prepend_To (Declarations (N), Mark_Call); Analyze (Mark_Call); end; end if; @@ -4703,7 +4694,6 @@ package body Exp_Ch7 is (N => N, Clean_Stmts => Build_Cleanup_Statements (N, Cln), Mark_Id => Mark, - Top_Decls => Decls, Defer_Abort => Nkind (Original_Node (N)) = N_Task_Body or else Is_Master, Fin_Id => Fin_Id); @@ -4789,7 +4779,6 @@ package body Exp_Ch7 is (N => N, Clean_Stmts => No_List, Mark_Id => Empty, - Top_Decls => No_List, Defer_Abort => False, Fin_Id => Fin_Id); @@ -4918,7 +4907,6 @@ package body Exp_Ch7 is (N => N, Clean_Stmts => No_List, Mark_Id => Empty, - Top_Decls => No_List, Defer_Abort => False, Fin_Id => Fin_Id); diff --git a/gcc/ada/exp_ch7.ads b/gcc/ada/exp_ch7.ads index 712671a427e..70b0a06af4b 100644 --- a/gcc/ada/exp_ch7.ads +++ b/gcc/ada/exp_ch7.ads @@ -129,7 +129,6 @@ package Exp_Ch7 is (N : Node_Id; Clean_Stmts : List_Id; Mark_Id : Entity_Id; - Top_Decls : List_Id; Defer_Abort : Boolean; Fin_Id : out Entity_Id); -- N may denote an accept statement, block, entry body, package body, @@ -142,11 +141,9 @@ package Exp_Ch7 is -- Clean_Stmts may contain additional context-dependent code used to abort -- asynchronous calls or complete tasks (see Build_Cleanup_Statements). -- Mark_Id is the secondary stack used in the current context or Empty if - -- missing. Top_Decls is the list on which the declaration of the finalizer - -- is attached in the non-package case. Defer_Abort indicates that the - -- statements passed in perform actions that require abort to be deferred, - -- such as for task termination. Fin_Id is the finalizer declaration - -- entity. + -- missing. Defer_Abort indicates that the statements passed in perform + -- actions that require abort to be deferred, such as for task termination. + -- Fin_Id is the finalizer declaration entity. procedure Build_Late_Proc (Typ : Entity_Id; Nam : Name_Id); -- Build one controlling procedure when a late body overrides one of the diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 850145eb887..785ad147755 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -3022,7 +3022,6 @@ package body Inline is (N => Decl, Clean_Stmts => No_List, Mark_Id => Empty, - Top_Decls => No_List, Defer_Abort => False, Fin_Id => Fin); From patchwork Thu Aug 1 15:17:11 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: 1967888 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=AcofIdKz; 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 4WZYHT6PT7z1yZv for ; Fri, 2 Aug 2024 01:47:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 224BE384A496 for ; Thu, 1 Aug 2024 15:47:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 06A0F3864811 for ; Thu, 1 Aug 2024 15:17:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 06A0F3864811 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 06A0F3864811 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525476; cv=none; b=OLnCqTx9BU64LYCufizkRE4DN/jxjJdmCSNWHMs8d44OkGmGq2zWHOzuVpy/s7Zr3JFUQi0kbTWGvrBKJOwv3gbaIvAmtZdDUj1vsO+JPJEef5nD0JXSuMQrLbzP/GGFudqJQFwu0jR5ZDnxUVtExM/mxZ/FdA2Zpw83Flm8vpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525476; c=relaxed/simple; bh=sEgqoYqn6T/5v8HC+XmZCcAizk0ShLVYuL7jz+9H1tI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=apq6TNIxf1tIEmoYNL2myC4pw6mRmmTm8LgZVPcUtPyHbd4NhhqUA05t0p3zxT5oW9rwbj6o5h/hwvQ9FW4KYJ9/5mnHxcm6PTJcEnYFR5oE1FssgCILQPuHTu4OSblWpCDiPa1nI6F4nTNGqzn/aHDLPDRECrFb60caIw+fPoY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ef1c12ae23so81620131fa.0 for ; Thu, 01 Aug 2024 08:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525472; x=1723130272; 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=9OL58YYS4kSXwMY+Kn0wzgiE4pg/JSWvVrwK/YkgvGI=; b=AcofIdKz8NykkwarSzBQMwrK2NgluVngMdjon+dcbG3XSnErZ8mRD9Z3hnnxlfDums hvWVZvQBVaENZFzuSePkXKbbyDvff5GGHlcIYjiZ5nWQIhpzaV51R0d/PknrQdkj+fyL +kRzQJOjNIP7ieNAF/1kxtwO41O2+GEdz+NwDtbuUOorbsRYjKqdAdQXGXm40Xu5OZDU FWwgcwXd3Gu9ccE7+HwQuzjtUMSKYAoo+erDxfq5+egh+NtK2r0xakWN5PbzmymQgev4 oxqtFmBC8y7ycHYEpUfN3Glk4DuaI/JixjVI4z9DXdcDkqhRyY/FcwvHvxWlGB8iropj SbqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525472; x=1723130272; 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=9OL58YYS4kSXwMY+Kn0wzgiE4pg/JSWvVrwK/YkgvGI=; b=YnHMJySFU1t0PKgQLJHssqFc6DTrwFCuvsZ0QMrjrYycY5zoTmsjf9+kA6hoYioW05 miGXtoiy3bJpG/4bb9jhQACLrG95Z4inx5NrvFInjbVZJgKcx7GtB4TH/Ie/DmwkWuT+ uCDoNIrSHul8bbXIJ0m7zsRkvyvXXUFNzww6pthrxia1shEqOoEH5FuhmWA1Gq5cy9Uk I5Z1uKhZ3kNGWvgFWg/Wej9m8Q4KMZk4ekUXUCmfwopZW+m2tR+4ad61Lo9hg3ElkmV/ okt0FZ87HbEqbkpC9XZyrSBiV/3K+elKlZVi/AyJR9Zw8w8KwsGCVaj364Z+0Ljp7OvW L+jQ== X-Gm-Message-State: AOJu0YzAMnC6mXbzMwOcQO5bd5HBR6O8k3wCoz8ub1CiMiRf/3qXJW8Y DJHC+15rMB+BAVanXXyjRsvsXFzfA2Ryk20kAPHB1F2uuxlxDcju2CiB1EAVpm+XFEI9n8CWple 07A== X-Google-Smtp-Source: AGHT+IHeMXslIfQF8r1Up2s3xtjY7CfI/ZoVICp+8GBoQppomzg6fZupG1JA2P9VXR4aOu8PdjsB3Q== X-Received: by 2002:a2e:9798:0:b0:2ef:3130:6362 with SMTP id 38308e7fff4ca-2f15aaf63e3mr4425671fa.39.1722525471919; Thu, 01 Aug 2024 08:17:51 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:51 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED 03/30] ada: Allow making empty aggregates positional Date: Thu, 1 Aug 2024 17:17:11 +0200 Message-ID: <20240801151738.400796-3-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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: Ronan Desplanques This patch makes Exp_Aggr.Convert_To_Positional accepts appropriate empty aggregates. The end goal is to remove violations of the No_Elaboration_Code restriction in some cases of library-level array objects. gcc/ada/ * exp_aggr.adb (Flatten): Do not reject empty aggregates. Adjust criterion for emitting warning about ineffective others clause. * sem_aggr.adb (Array_Aggr_Subtype): Fix typo. Add handling of aggregates that were converted to positional form. (Resolve_Aggregate): Tweak criterion for transforming into a string literal. (Resolve_Array_Aggregate): Tweak criterion for reusing existing bounds of aggregate. (Retrieve_Aggregate_Bounds): New procedure. * sem_util.adb (Has_Static_Empty_Array_Bounds): New function. * sem_util.ads (Has_Static_Empty_Array_Bounds): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 6 +++-- gcc/ada/sem_aggr.adb | 53 ++++++++++++++++++++++++++++++-------------- gcc/ada/sem_util.adb | 14 ++++++++++++ gcc/ada/sem_util.ads | 3 +++ 4 files changed, 57 insertions(+), 19 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index df228713a28..419a98c681a 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -4657,8 +4657,7 @@ package body Exp_Aggr is -- present we can proceed since the bounds can be obtained from the -- aggregate. - if Hiv < Lov - or else (not Compile_Time_Known_Value (Blo) and then Others_Present) + if not Compile_Time_Known_Value (Blo) and then Others_Present then return False; end if; @@ -4801,6 +4800,9 @@ package body Exp_Aggr is if Rep_Count = 0 and then Warn_On_Redundant_Constructs + -- We don't emit warnings on null arrays initialized + -- with an aggregate of the form "(others => ...)". + and then Vals'Length > 0 then Error_Msg_N ("there are no others?r?", Elmt); end if; diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index bc53ea904a3..bddfbecf46d 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -468,6 +468,12 @@ package body Sem_Aggr is -- corresponding to the same dimension are static and found to differ, -- then emit a warning, and mark N as raising Constraint_Error. + procedure Retrieve_Aggregate_Bounds (This_Range : Node_Id); + -- In some cases, an appropriate list of aggregate bounds has been + -- created during resolution. Populate Aggr_Range with that list, and + -- remove the elements from the list so they can be added to another + -- list later. + ------------------------- -- Collect_Aggr_Bounds -- ------------------------- @@ -631,6 +637,24 @@ package body Sem_Aggr is end if; end Collect_Aggr_Bounds; + ------------------------------- + -- Retrieve_Aggregate_Bounds -- + ------------------------------- + + procedure Retrieve_Aggregate_Bounds (This_Range : Node_Id) is + R : Node_Id := This_Range; + begin + for J in 1 .. Aggr_Dimension loop + Aggr_Range (J) := R; + Next_Index (R); + + -- Remove bounds from the list, so they can be reattached as + -- the First_Index/Next_Index again. + + Remove (Aggr_Range (J)); + end loop; + end Retrieve_Aggregate_Bounds; + -- Array_Aggr_Subtype variables Itype : Entity_Id; @@ -655,25 +679,17 @@ package body Sem_Aggr is Set_Parent (Index_Constraints, N); + if Is_Rewrite_Substitution (N) + and then Present (Component_Associations (Original_Node (N))) + then + Retrieve_Aggregate_Bounds (First_Index (Etype (Original_Node (N)))); + -- When resolving a null aggregate we created a list of aggregate bounds -- for the consecutive dimensions. The bounds for the first dimension -- are attached as the Aggregate_Bounds of the aggregate node. - if Is_Null_Aggregate (N) then - declare - This_Range : Node_Id := Aggregate_Bounds (N); - begin - for J in 1 .. Aggr_Dimension loop - Aggr_Range (J) := This_Range; - Next_Index (This_Range); - - -- Remove bounds from the list, so they can be reattached as - -- the First_Index/Next_Index again by the code that also - -- handles non-null aggregates. - - Remove (Aggr_Range (J)); - end loop; - end; + elsif Is_Null_Aggregate (N) then + Retrieve_Aggregate_Bounds (Aggregate_Bounds (N)); else Collect_Aggr_Bounds (N, 1); end if; @@ -1378,6 +1394,7 @@ package body Sem_Aggr is and then Is_OK_Static_Subtype (Component_Type (Typ)) and then Base_Type (Etype (First_Index (Typ))) = Base_Type (Standard_Integer) + and then not Has_Static_Empty_Array_Bounds (Typ) then declare Expr : Node_Id; @@ -3595,10 +3612,12 @@ package body Sem_Aggr is -- If the aggregate already has bounds attached to it, it means this is -- a positional aggregate created as an optimization by -- Exp_Aggr.Convert_To_Positional, so we don't want to change those - -- bounds. + -- bounds, unless they depend on discriminants. If they do, we have to + -- perform analysis in the current context. if Present (Aggregate_Bounds (N)) - and then not Others_Allowed + and then No (Others_N) + and then not Depends_On_Discriminant (Aggregate_Bounds (N)) and then not Comes_From_Source (N) then Aggr_Low := Low_Bound (Aggregate_Bounds (N)); diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 9d4fd74b98f..19941ae3060 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -13250,6 +13250,20 @@ package body Sem_Util is return All_Static; end Has_Static_Array_Bounds; + ----------------------------------- + -- Has_Static_Empty_Array_Bounds -- + ----------------------------------- + + function Has_Static_Empty_Array_Bounds (Typ : Node_Id) return Boolean is + All_Static : Boolean; + Has_Empty : Boolean; + + begin + Examine_Array_Bounds (Typ, All_Static, Has_Empty); + + return Has_Empty; + end Has_Static_Empty_Array_Bounds; + --------------------------------------- -- Has_Static_Non_Empty_Array_Bounds -- --------------------------------------- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 21e90dcf53b..eccbd4351d0 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1531,6 +1531,9 @@ package Sem_Util is function Has_Static_Array_Bounds (Typ : Node_Id) return Boolean; -- Return whether an array type has static bounds + function Has_Static_Empty_Array_Bounds (Typ : Node_Id) return Boolean; + -- Return whether array type Typ has static empty bounds + function Has_Static_Non_Empty_Array_Bounds (Typ : Node_Id) return Boolean; -- Determine whether array type Typ has static non-empty bounds From patchwork Thu Aug 1 15:17:12 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: 1967848 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=JqLIc8hp; 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 4WZY4k3NYnz1ybX for ; Fri, 2 Aug 2024 01:37:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84F333864C5F for ; Thu, 1 Aug 2024 15:37:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id D312D386484B for ; Thu, 1 Aug 2024 15:17:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D312D386484B 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 D312D386484B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525484; cv=none; b=QqCdFj8DuaPBUQ5R0RJIxqROXkc4CC0K3EIyI6QnWWTKYMsAljqxV+gSGCpHJnw6hWQV03eDbqPl5Va69702anoAzTJaPJ/S0hiOxFdoDaSFkVrmSdRJws63/mc8jWsh2aHzLI9Nj78Zbd/gz5EtYrL7r3qRC973p7t7/m8/ogA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525484; c=relaxed/simple; bh=DxU7yNFrKyrXFBruoMOe/4kdoUqLJ6XTWCzUPiih/W8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=v88int4MyJ427wllE8GUvPi/EW9CtDBn6dmtjM2Iir07MG2ZvpU6J5bTqgiD3duQi4gsUXn6UXDbGGw2TPWzTyOVmwksFpoB6e9S/PTR8gnLHmADKVoTepdAZKjn3VWiU300+MUR0jfR33rXBOYDY/BlRFHMGx2Jli9CKyj+IOk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3686b285969so3549285f8f.0 for ; Thu, 01 Aug 2024 08:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525474; x=1723130274; 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=vTwgJqPahUDfAJwwFmCZQahxX55KoeW/25x8UlZGA/g=; b=JqLIc8hpmj8bTUitOq0anwP5HXuNR4ZF3N2Y/8MY5PviWU7kIDzNSNjFlaaRxAMF0q V/IN/sZmsWCFN9D4MzURlqlZkRb0wbCH62ISXMfrRwtDbnEfiYUIu8TMnisrD9+N1irq Fpf2tCCLNGCZAezDvGJ7ae4m2Ox+4hhJlS4B5QPSO1/UvOtP7Mu4vzgBvdoJzMwPh/5v VBlwiUyZuOM8iiDTABZAa5z7r1/eg2l5F/AnWzIOUlBSMmnzupfplkeJLQermt8K3/iI fRPO9e91ORj3XQC0VMVYpP8GF0TjNBQHluqrP6n26VqtupHguev3UKN4gQhEhci9Rfb+ aTVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525474; x=1723130274; 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=vTwgJqPahUDfAJwwFmCZQahxX55KoeW/25x8UlZGA/g=; b=MybeKSTPqIGLk27Cj7KIP002/PPKVwG9NuzJItkTC0RDJUx/qwm0ezqVaUe9X1NufD uXxVWHtk46SFAMBm5IzQsekrOyne6jpAzAtQ7uU4Xsxy1LfjVXtaYfCQnCpcgtCbEmAb YLMnl7E5KoHTWUA6gubsVVxAXUrOAs7Q5diewpNQMBElK9xEsJx+WRQ/ZJjX8m3U9a6W Mf5ASZNOIrS9OHSLvAwk5/NxyYu3Vv1OCYN04YHZ9FLT8S9BZK9ZRR2SLTXnVFGuRDZm alobrSwsGh7maxhGnu53htjoaLZTqwLHJWThiELBaBToSA+PYL1b8iszQf+mtlyDmL/Y 6PnQ== X-Gm-Message-State: AOJu0Yyd5hreo/rstZ/ySUZE9TcnLWpDakjU8BoQj0dh9oZqkU2WwTSt drsb3mZrpFa4KdVNiVj/u3QBBauW4tamUSQPng1WtOUKYQqzzV3OMkoR16nx+hdz6cV8gHsCeI0 ITg== X-Google-Smtp-Source: AGHT+IEQ0kdlFktmLcmkM6cqx4SmSkvgCzc88ZK+JbZgnHvIv6xk2URCqFUmeN/1IOW4u8ttvymREw== X-Received: by 2002:a5d:5f44:0:b0:367:96d6:4c2d with SMTP id ffacd0b85a97d-36bbc0cd517mr233575f8f.25.1722525473357; Thu, 01 Aug 2024 08:17:53 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:52 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Arnaud Charlet Subject: [COMMITTED 04/30] ada: Remove support for bodies in -gnatceg Date: Thu, 1 Aug 2024 17:17:12 +0200 Message-ID: <20240801151738.400796-4-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPAM_BODY, 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: Arnaud Charlet The support for generating C for Ada code is moved to GNAT LLVM. Keep support for generating header files from Ada spec files which is the remaining usage of -gnatceg. gcc/ada/ * bindgen.adb, bindusg.adb, debug.adb, einfo.ads, exp_aggr.adb, exp_attr.adb, exp_ch11.adb, exp_ch3.adb, exp_ch4.adb, exp_ch6.adb, exp_ch7.adb, exp_ch8.adb, exp_dbug.adb, exp_dbug.ads, exp_intr.adb, exp_unst.adb, exp_util.adb, exp_util.ads, freeze.adb, gen_il-fields.ads, gen_il-gen-gen_entities.adb, gnat1drv.adb, inline.adb, opt.ads, osint-c.adb, osint-c.ads, sem_attr.adb, sem_ch12.adb, sem_ch3.adb, sem_ch4.adb, sem_ch6.adb, sem_elab.adb, sem_res.adb, sinfo.ads, snames.ads-tmpl, switch-b.adb, switch-c.adb: Major clean up to remove C code generation for bodies. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/bindgen.adb | 1 - gcc/ada/bindusg.adb | 5 - gcc/ada/debug.adb | 11 +- gcc/ada/einfo.ads | 20 - gcc/ada/exp_aggr.adb | 203 +----- gcc/ada/exp_attr.adb | 162 ++--- gcc/ada/exp_ch11.adb | 6 - gcc/ada/exp_ch3.adb | 14 +- gcc/ada/exp_ch4.adb | 934 ++++------------------------ gcc/ada/exp_ch6.adb | 225 ------- gcc/ada/exp_ch7.adb | 8 +- gcc/ada/exp_ch8.adb | 7 +- gcc/ada/exp_dbug.adb | 40 -- gcc/ada/exp_dbug.ads | 15 - gcc/ada/exp_intr.adb | 5 - gcc/ada/exp_unst.adb | 37 +- gcc/ada/exp_util.adb | 206 +----- gcc/ada/exp_util.ads | 4 - gcc/ada/freeze.adb | 12 - gcc/ada/gen_il-fields.ads | 3 - gcc/ada/gen_il-gen-gen_entities.adb | 3 - gcc/ada/gnat1drv.adb | 88 +-- gcc/ada/inline.adb | 117 ---- gcc/ada/opt.ads | 25 +- gcc/ada/osint-c.adb | 40 -- gcc/ada/osint-c.ads | 22 +- gcc/ada/sem_attr.adb | 77 +-- gcc/ada/sem_ch12.adb | 4 +- gcc/ada/sem_ch3.adb | 6 +- gcc/ada/sem_ch4.adb | 7 - gcc/ada/sem_ch6.adb | 82 --- gcc/ada/sem_elab.adb | 15 +- gcc/ada/sem_res.adb | 23 +- gcc/ada/sinfo.ads | 57 -- gcc/ada/snames.ads-tmpl | 3 +- gcc/ada/switch-b.adb | 6 - gcc/ada/switch-c.adb | 4 +- 37 files changed, 267 insertions(+), 2230 deletions(-) diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb index 89b2b88395b..cdfaa08d8a6 100644 --- a/gcc/ada/bindgen.adb +++ b/gcc/ada/bindgen.adb @@ -2113,7 +2113,6 @@ package body Bindgen is if Bind_Main_Program and then not Minimal_Binder and then not CodePeer_Mode - and then not Generate_C_Code then WBI (" Ensure_Reference : aliased System.Address := " & "Ada_Main_Program_Name'Address;"); diff --git a/gcc/ada/bindusg.adb b/gcc/ada/bindusg.adb index 855fd16c930..e870c5f0e22 100644 --- a/gcc/ada/bindusg.adb +++ b/gcc/ada/bindusg.adb @@ -133,11 +133,6 @@ package body Bindusg is Write_Line (" -F Force checking of elaboration Flags"); - -- Line for -G switch - - Write_Line - (" -G Generate binder file suitable for CCG"); - -- Line for -h switch Write_Line diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 3313c4a408f..d2546bec1b5 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -105,7 +105,7 @@ package body Debug is -- d.r Disable reordering of components in record types -- d.s Strict secondary stack management -- d.t Disable static allocation of library level dispatch tables - -- d.u Enable Modify_Tree_For_C (update tree for c) + -- d.u -- d.v Enforce SPARK elaboration rules in SPARK code -- d.w Do not check for infinite loops -- d.x No exception handlers @@ -207,7 +207,7 @@ package body Debug is -- d.3 Output debugging information from Exp_Unst -- d.4 Do not delete generated C file in case of errors -- d.5 Do not generate imported subprogram definitions in C code - -- d.6 Do not avoid declaring unreferenced types in C code + -- d.6 -- d.7 Disable unsound heuristics in gnat2scil (for CP as SPARK prover) -- d.8 Disable unconditional inlining of expression functions -- d.9 @@ -797,8 +797,7 @@ package body Debug is -- previous dynamic construction of tables. It is there as a possible -- work around if we run into trouble with the new implementation. - -- d.u Sets Modify_Tree_For_C mode in which tree is modified to make it - -- easier to generate code using a C compiler. + -- d.u -- d.v This flag enforces the elaboration rules defined in the SPARK -- Reference Manual, chapter 7.7, to all SPARK code within a unit. As @@ -1118,10 +1117,6 @@ package body Debug is -- This debug flag disables this generation when generating C code, -- assuming a proper #include will be used instead. - -- d.6 By default the C back-end avoids declaring types that are not - -- referenced by the generated C code. This debug flag restores the - -- output of all the types. - -- d.7 Indicates (to gnat2scil) that CodePeer is being invoked as a -- prover by the SPARK tools and that therefore gnat2scil should -- avoid SCIL generation strategies which can introduce soundness diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index fbe6c8566ec..0d839b9b691 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -748,17 +748,6 @@ package Einfo is -- other function entities, only in implicit inequality routines, -- where Comes_From_Source is always False. --- Corresponding_Function --- Defined on procedures internally built with an extra out parameter --- to return a constrained array type, when Modify_Tree_For_C is set. --- Denotes the function that returns the constrained array type for --- which this procedure was built. - --- Corresponding_Procedure --- Defined on functions that return a constrained array type, when --- Modify_Tree_For_C is set. Denotes the internally built procedure --- with an extra out parameter created for it. - -- Corresponding_Record_Component -- Defined in components of a derived untagged record type, including -- discriminants. For a regular component or a stored discriminant, @@ -4285,12 +4274,6 @@ package Einfo is -- the Bit_Order aspect must be set to the same value (either explicitly -- or as the target default value). --- Rewritten_For_C --- Defined on functions that return a constrained array type, when --- Modify_Tree_For_C is set. Indicates that a procedure with an extra --- out parameter has been created for it, and calls must be rewritten as --- calls to the new procedure. - -- RM_Size -- Defined in all type and subtype entities. Contains the value of -- type'Size as defined in the RM. See also the Esize field and @@ -5522,7 +5505,6 @@ package Einfo is -- Anonymous_Collections (non-generic case only) -- Corresponding_Equality (implicit /= only) -- Thunk_Entity (thunk case only) - -- Corresponding_Procedure (generate C code only) -- Linker_Section_Pragma -- Contract -- Import_Pragma (non-generic case only) @@ -5586,7 +5568,6 @@ package Einfo is -- Requires_Overriding (non-generic case only) -- Return_Present -- Returns_By_Ref - -- Rewritten_For_C (generate C code only) -- Sec_Stack_Needed_For_Return -- SPARK_Pragma_Inherited -- Uses_Sec_Stack @@ -5883,7 +5864,6 @@ package Einfo is -- Anonymous_Collections (non-generic case only) -- Static_Initialization (init_proc only) -- Thunk_Entity (thunk case only) - -- Corresponding_Function (generate C code only) -- Linker_Section_Pragma -- Contract -- Import_Pragma (non-generic case only) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 419a98c681a..c7730ca754a 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -117,10 +117,6 @@ package body Exp_Aggr is -- Comp_Typ of aggregate N. Init_Expr denotes the initialization -- expression of the component. All generated code is added to Stmts. - function Is_CCG_Supported_Aggregate (N : Node_Id) return Boolean; - -- Return True if aggregate N is located in a context supported by the - -- CCG backend; False otherwise. - function Is_Static_Dispatch_Table_Aggregate (N : Node_Id) return Boolean; -- Returns true if N is an aggregate used to initialize the components -- of a statically allocated dispatch table. @@ -814,10 +810,6 @@ package body Exp_Aggr is -- 10. No controlled actions need to be generated for components - -- 11. When generating C code, N must be part of a N_Object_Declaration - - -- 12. When generating C code, N must not include function calls - function Backend_Processing_Possible (N : Node_Id) return Boolean is Typ : constant Entity_Id := Etype (N); -- Typ is the correct constrained array subtype of the aggregate @@ -833,33 +825,7 @@ package body Exp_Aggr is --------------------- function Component_Check (N : Node_Id; Index : Node_Id) return Boolean is - function Ultimate_Original_Expression (N : Node_Id) return Node_Id; - -- Given a type conversion or an unchecked type conversion N, return - -- its innermost original expression. - - ---------------------------------- - -- Ultimate_Original_Expression -- - ---------------------------------- - - function Ultimate_Original_Expression (N : Node_Id) return Node_Id is - Expr : Node_Id := Original_Node (N); - - begin - while Nkind (Expr) in - N_Type_Conversion | N_Unchecked_Type_Conversion - loop - Expr := Original_Node (Expression (Expr)); - end loop; - - return Expr; - end Ultimate_Original_Expression; - - -- Local variables - Expr : Node_Id; - - -- Start of processing for Component_Check - begin -- Checks 1: (no component associations) @@ -867,13 +833,6 @@ package body Exp_Aggr is return False; end if; - -- Checks 11: The C code generator cannot handle aggregates that are - -- not part of an object declaration. - - if Modify_Tree_For_C and then not Is_CCG_Supported_Aggregate (N) then - return False; - end if; - -- Checks on components -- Recurse to check subaggregates, which may appear in qualified @@ -905,15 +864,6 @@ package body Exp_Aggr is return False; end if; - -- Checks 12: (no function call) - - if Modify_Tree_For_C - and then - Nkind (Ultimate_Original_Expression (Expr)) = N_Function_Call - then - return False; - end if; - -- Recursion to following indexes for multiple dimension case if Present (Next_Index (Index)) @@ -3389,32 +3339,12 @@ package body Exp_Aggr is end if; end if; - if Modify_Tree_For_C - and then Nkind (Expr_Q) = N_Aggregate - and then Is_Array_Type (Etype (Expr_Q)) - and then Present (First_Index (Etype (Expr_Q))) - then - declare - Expr_Q_Type : constant Entity_Id := Etype (Expr_Q); - begin - Append_List_To (L, - Build_Array_Aggr_Code - (N => Expr_Q, - Ctype => Component_Type (Expr_Q_Type), - Index => First_Index (Expr_Q_Type), - Into => Comp_Expr, - Scalar_Comp => - Is_Scalar_Type (Component_Type (Expr_Q_Type)))); - end; - - else - Initialize_Component - (N => N, - Comp => Comp_Expr, - Comp_Typ => Etype (Selector), - Init_Expr => Expr_Q, - Stmts => L); - end if; + Initialize_Component + (N => N, + Comp => Comp_Expr, + Comp_Typ => Etype (Selector), + Init_Expr => Expr_Q, + Stmts => L); end if; -- comment would be good here ??? @@ -3800,7 +3730,6 @@ package body Exp_Aggr is -- reset Set_Expansion_Delayed and do not expand further. if not CodePeer_Mode - and then not Modify_Tree_For_C and then Aggr_Assignment_OK_For_Backend (Aggr) then New_Aggr := New_Copy_Tree (Aggr); @@ -4957,14 +4886,6 @@ package body Exp_Aggr is -- Start of processing for Convert_To_Positional begin - -- Only convert to positional when generating C in case of an - -- object declaration, this is the only case where aggregates are - -- supported in C. - - if Modify_Tree_For_C and then not Is_CCG_Supported_Aggregate (N) then - return; - end if; - -- Ada 2005 (AI-287): Do not convert in case of default initialized -- components because in this case will need to call the corresponding -- IP procedure. @@ -6472,7 +6393,6 @@ package body Exp_Aggr is if (In_Place_Assign_OK_For_Declaration or else Maybe_In_Place_OK) and then not CodePeer_Mode - and then not Modify_Tree_For_C and then not Possible_Bit_Aligned_Component (Target) and then not Is_Possibly_Unaligned_Slice (Target) and then Aggr_Assignment_OK_For_Backend (N) @@ -7955,10 +7875,6 @@ package body Exp_Aggr is (Typ : Entity_Id) return Boolean; -- Determine if some component of Typ is mutably tagged - function Has_Per_Object_Constraint (L : List_Id) return Boolean; - -- Return True if any element of L has Has_Per_Object_Constraint set. - -- L should be the Choices component of an N_Component_Association. - function Has_Visible_Private_Ancestor (Id : E) return Boolean; -- If any ancestor of the current type is private, the aggregate -- cannot be built in place. We cannot rely on Has_Private_Ancestor, @@ -8413,27 +8329,6 @@ package body Exp_Aggr is elsif Possible_Bit_Aligned_Component (Expr_Q) then Static_Components := False; return False; - - elsif Modify_Tree_For_C - and then Nkind (C) = N_Component_Association - and then Has_Per_Object_Constraint (Choices (C)) - then - Static_Components := False; - return False; - - elsif Modify_Tree_For_C - and then Nkind (Expr_Q) = N_Identifier - and then Is_Array_Type (Etype (Expr_Q)) - then - Static_Components := False; - return False; - - elsif Modify_Tree_For_C - and then Nkind (Expr_Q) = N_Type_Conversion - and then Is_Array_Type (Etype (Expr_Q)) - then - Static_Components := False; - return False; end if; if Is_Elementary_Type (Etype (Expr_Q)) then @@ -8481,27 +8376,6 @@ package body Exp_Aggr is return False; end Contains_Mutably_Tagged_Component; - ------------------------------- - -- Has_Per_Object_Constraint -- - ------------------------------- - - function Has_Per_Object_Constraint (L : List_Id) return Boolean is - N : Node_Id := First (L); - begin - while Present (N) loop - if Is_Entity_Name (N) - and then Present (Entity (N)) - and then Has_Per_Object_Constraint (Entity (N)) - then - return True; - end if; - - Next (N); - end loop; - - return False; - end Has_Per_Object_Constraint; - ----------------------------------- -- Has_Visible_Private_Ancestor -- ----------------------------------- @@ -8674,12 +8548,6 @@ package body Exp_Aggr is elsif Type_May_Have_Bit_Aligned_Components (Typ) then Convert_To_Assignments (N, Typ); - -- When generating C, only generate an aggregate when declaring objects - -- since C does not support aggregates in e.g. assignment statements. - - elsif Modify_Tree_For_C and then not Is_CCG_Supported_Aggregate (N) then - Convert_To_Assignments (N, Typ); - -- In all other cases, build a proper aggregate to be handled by gigi else @@ -8948,64 +8816,6 @@ package body Exp_Aggr is and then Expansion_Delayed (Unqual_N); end Is_Delayed_Conditional_Expression; - -------------------------------- - -- Is_CCG_Supported_Aggregate -- - -------------------------------- - - function Is_CCG_Supported_Aggregate - (N : Node_Id) return Boolean - is - P : Node_Id := Parent (N); - - begin - -- Aggregates are not supported for nonstandard rep clauses, since they - -- may lead to extra padding fields in CCG. - - if Is_Record_Type (Etype (N)) - and then Has_Non_Standard_Rep (Etype (N)) - then - return False; - end if; - - while Present (P) and then Nkind (P) = N_Aggregate loop - P := Parent (P); - end loop; - - -- Check cases where aggregates are supported by the CCG backend - - if Nkind (P) = N_Object_Declaration then - declare - P_Typ : constant Entity_Id := Etype (Defining_Identifier (P)); - - begin - if Is_Record_Type (P_Typ) then - return True; - else - return Compile_Time_Known_Bounds (P_Typ); - end if; - end; - - elsif Nkind (P) = N_Qualified_Expression then - if Nkind (Parent (P)) = N_Object_Declaration then - declare - P_Typ : constant Entity_Id := - Etype (Defining_Identifier (Parent (P))); - begin - if Is_Record_Type (P_Typ) then - return True; - else - return Compile_Time_Known_Bounds (P_Typ); - end if; - end; - - elsif Nkind (Parent (P)) = N_Allocator then - return True; - end if; - end if; - - return False; - end Is_CCG_Supported_Aggregate; - ---------------------------------------- -- Is_Static_Dispatch_Table_Aggregate -- ---------------------------------------- @@ -9069,7 +8879,6 @@ package body Exp_Aggr is -- reset Set_Expansion_Delayed and do not expand further. if not CodePeer_Mode - and then not Modify_Tree_For_C and then not Possible_Bit_Aligned_Component (Target) and then not Is_Possibly_Unaligned_Slice (Target) and then Aggr_Assignment_OK_For_Backend (N) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 627cd7f3392..13c7444ca87 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -224,8 +224,7 @@ package body Exp_Attr is -- loop may be converted into a conditional block. See body for details. procedure Expand_Min_Max_Attribute (N : Node_Id); - -- Handle the expansion of attributes 'Max and 'Min, including expanding - -- then out if we are in Modify_Tree_For_C mode. + -- Handle the expansion of attributes 'Max and 'Min procedure Expand_Pred_Succ_Attribute (N : Node_Id); -- Handles expansion of Pred or Succ attributes for case of non-real @@ -5144,19 +5143,6 @@ package body Exp_Attr is use Old_Attr_Util.Conditional_Evaluation; use Old_Attr_Util.Indirect_Temps; begin - -- Generating C code we don't need to expand this attribute when - -- we are analyzing the internally built nested _Wrapped_Statements - -- procedure since it will be expanded inline (and later it will - -- be removed by Expand_N_Subprogram_Body). It this expansion is - -- performed in such case then the compiler generates unreferenced - -- extra temporaries. - - if Modify_Tree_For_C - and then Chars (Current_Scope) = Name_uWrapped_Statements - then - return; - end if; - -- 'Old can only appear in the case where local contract-related -- wrapper has been generated with the purpose of wrapping the -- original declarations and statements. @@ -7546,93 +7532,84 @@ package body Exp_Attr is -- Start of processing for Float_Valid begin - -- The C back end handles Valid for floating-point types - - if Modify_Tree_For_C then - Analyze_And_Resolve (Pref, Ptyp); - Set_Etype (N, Standard_Boolean); - Set_Analyzed (N); - - else - Find_Fat_Info (Ptyp, Ftp, Pkg); - - -- If the prefix is a reverse SSO component, or is possibly - -- unaligned, first create a temporary copy that is in - -- native SSO, and properly aligned. Make it Volatile to - -- prevent folding in the back-end. Note that we use an - -- intermediate constrained string type to initialize the - -- temporary, as the value at hand might be invalid, and in - -- that case it cannot be copied using a floating point - -- register. - - if In_Reverse_Storage_Order_Object (Pref) - or else Is_Possibly_Unaligned_Object (Pref) - then - declare - Temp : constant Entity_Id := - Make_Temporary (Loc, 'F'); + Find_Fat_Info (Ptyp, Ftp, Pkg); + + -- If the prefix is a reverse SSO component, or is possibly + -- unaligned, first create a temporary copy that is in + -- native SSO, and properly aligned. Make it Volatile to + -- prevent folding in the back-end. Note that we use an + -- intermediate constrained string type to initialize the + -- temporary, as the value at hand might be invalid, and in + -- that case it cannot be copied using a floating point + -- register. + + if In_Reverse_Storage_Order_Object (Pref) + or else Is_Possibly_Unaligned_Object (Pref) + then + declare + Temp : constant Entity_Id := + Make_Temporary (Loc, 'F'); - Fat_S : constant Entity_Id := - Get_Fat_Entity (Name_S); - -- Constrained string subtype of appropriate size + Fat_S : constant Entity_Id := + Get_Fat_Entity (Name_S); + -- Constrained string subtype of appropriate size - Fat_P : constant Entity_Id := - Get_Fat_Entity (Name_P); - -- Access to Fat_S + Fat_P : constant Entity_Id := + Get_Fat_Entity (Name_P); + -- Access to Fat_S - Decl : constant Node_Id := - Make_Object_Declaration (Loc, + Decl : constant Node_Id := + Make_Object_Declaration (Loc, Defining_Identifier => Temp, Aliased_Present => True, - Object_Definition => - New_Occurrence_Of (Ptyp, Loc)); + Object_Definition => + New_Occurrence_Of (Ptyp, Loc)); - begin - Set_Aspect_Specifications (Decl, New_List ( - Make_Aspect_Specification (Loc, - Identifier => - Make_Identifier (Loc, Name_Volatile)))); + begin + Set_Aspect_Specifications (Decl, New_List ( + Make_Aspect_Specification (Loc, + Identifier => + Make_Identifier (Loc, Name_Volatile)))); - Insert_Actions (N, - New_List ( - Decl, - - Make_Assignment_Statement (Loc, - Name => - Make_Explicit_Dereference (Loc, - Prefix => - Unchecked_Convert_To (Fat_P, - Make_Attribute_Reference (Loc, - Prefix => - New_Occurrence_Of (Temp, Loc), - Attribute_Name => - Name_Unrestricted_Access))), - Expression => - Unchecked_Convert_To (Fat_S, - Relocate_Node (Pref)))), - - Suppress => All_Checks); - - Rewrite (Pref, New_Occurrence_Of (Temp, Loc)); - end; - end if; + Insert_Actions (N, + New_List ( + Decl, + + Make_Assignment_Statement (Loc, + Name => + Make_Explicit_Dereference (Loc, + Prefix => + Unchecked_Convert_To (Fat_P, + Make_Attribute_Reference (Loc, + Prefix => + New_Occurrence_Of (Temp, Loc), + Attribute_Name => + Name_Unrestricted_Access))), + Expression => + Unchecked_Convert_To (Fat_S, + Relocate_Node (Pref)))), + + Suppress => All_Checks); + + Rewrite (Pref, New_Occurrence_Of (Temp, Loc)); + end; + end if; - -- We now have an object of the proper endianness and - -- alignment, and can construct a Valid attribute. + -- We now have an object of the proper endianness and + -- alignment, and can construct a Valid attribute. - -- We make sure the prefix of this valid attribute is - -- marked as not coming from source, to avoid losing - -- warnings from 'Valid looking like a possible update. + -- We make sure the prefix of this valid attribute is + -- marked as not coming from source, to avoid losing + -- warnings from 'Valid looking like a possible update. - Set_Comes_From_Source (Pref, False); + Set_Comes_From_Source (Pref, False); - Expand_Fpt_Attribute - (N, Pkg, Name_Valid, - New_List ( - Make_Attribute_Reference (Loc, - Prefix => Unchecked_Convert_To (Ftp, Pref), - Attribute_Name => Name_Unrestricted_Access))); - end if; + Expand_Fpt_Attribute + (N, Pkg, Name_Valid, + New_List ( + Make_Attribute_Reference (Loc, + Prefix => Unchecked_Convert_To (Ftp, Pref), + Attribute_Name => Name_Unrestricted_Access))); -- One more task, we still need a range check. Required -- only if we have a constraint, since the Valid routine @@ -9336,8 +9313,7 @@ package body Exp_Attr is function Is_GCC_Target return Boolean is begin - return not CodePeer_Mode - and then not Modify_Tree_For_C; + return not CodePeer_Mode; end Is_GCC_Target; -- Start of processing for Is_Inline_Floating_Point_Attribute diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb index 678d76cf3eb..925b164cb2f 100644 --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp_ch11.adb @@ -1103,12 +1103,6 @@ package body Exp_Ch11 is -- Start of processing for Expand_N_Exception_Declaration begin - -- Nothing to do when generating C code - - if Modify_Tree_For_C then - return; - end if; - -- Definition of the external name: nam : constant String := "A.B.NAME"; Ex_Id := diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 70048e68331..1eea062210a 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -4650,14 +4650,6 @@ package body Exp_Ch3 is Set_Is_Inlined (Proc_Id, Inline_Init_Proc (Rec_Type)); - -- Do not build an aggregate if Modify_Tree_For_C, this isn't - -- needed and may generate early references to non frozen types - -- since we expand aggregate much more systematically. - - if Modify_Tree_For_C then - return; - end if; - declare Agg : constant Node_Id := Build_Equivalent_Record_Aggregate (Rec_Type); @@ -7690,13 +7682,11 @@ package body Exp_Ch3 is -- An aggregate that must be built in place is not resolved and -- expanded until the enclosing construct is expanded. This will -- happen when the aggregate is limited and the declared object - -- has a following address clause; it happens also when generating - -- C code for an aggregate that has an alignment or address clause - -- (see Analyze_Object_Declaration). Resolution is done without + -- has a following address clause. Resolution is done without -- expansion because it will take place when the declaration -- itself is expanded. - if (Is_Limited_Type (Typ) or else Modify_Tree_For_C) + if Is_Limited_Type (Typ) and then not Analyzed (Expr) then Expander_Mode_Save_And_Set (False); diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index abe76c8767e..f952005ed75 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -1051,21 +1051,13 @@ package body Exp_Ch4 is Displace_Allocator_Pointer (N); end if; - -- Always force the generation of a temporary for aggregates when - -- generating C code, to simplify the work in the code generator. - - elsif Aggr_In_Place - or else (Modify_Tree_For_C and then Nkind (Exp) = N_Aggregate) - then + elsif Aggr_In_Place then Temp := Make_Temporary (Loc, 'P', N); Build_Aggregate_In_Place (Temp, PtrT); Build_Allocate_Deallocate_Proc (Declaration_Node (Temp), Mark => N); Rewrite (N, New_Occurrence_Of (Temp, Loc)); Analyze_And_Resolve (N, PtrT); - - if Aggr_In_Place then - Apply_Predicate_Check (N, T, Deref => True); - end if; + Apply_Predicate_Check (N, T, Deref => True); -- If the initialization expression is a conditional expression whose -- expansion has been delayed, assign it explicitly to the allocator, @@ -1996,52 +1988,14 @@ package body Exp_Ch4 is Func_Body := Make_Boolean_Array_Op (Etype (L), N); Func_Name := Defining_Unit_Name (Specification (Func_Body)); Insert_Action (N, Func_Body); - - -- Now rewrite the expression with a call - - if Transform_Function_Array then - declare - Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'T'); - Call : Node_Id; - Decl : Node_Id; - - begin - -- Generate: - -- Temp : ...; - - Decl := - Make_Object_Declaration (Loc, - Defining_Identifier => Temp_Id, - Object_Definition => - New_Occurrence_Of (Etype (L), Loc)); - - -- Generate: - -- Proc_Call (L, R, Temp); - - Call := - Make_Procedure_Call_Statement (Loc, - Name => New_Occurrence_Of (Func_Name, Loc), - Parameter_Associations => - New_List ( - L, - Make_Type_Conversion - (Loc, New_Occurrence_Of (Etype (L), Loc), R), - New_Occurrence_Of (Temp_Id, Loc))); - - Insert_Actions (Parent (N), New_List (Decl, Call)); - Rewrite (N, New_Occurrence_Of (Temp_Id, Loc)); - end; - else - Rewrite (N, - Make_Function_Call (Loc, - Name => New_Occurrence_Of (Func_Name, Loc), - Parameter_Associations => - New_List ( - L, - Make_Type_Conversion - (Loc, New_Occurrence_Of (Etype (L), Loc), R)))); - end if; - + Rewrite (N, + Make_Function_Call (Loc, + Name => New_Occurrence_Of (Func_Name, Loc), + Parameter_Associations => + New_List ( + L, + Make_Type_Conversion + (Loc, New_Occurrence_Of (Etype (L), Loc), R)))); Analyze_And_Resolve (N, Typ); end if; end; @@ -4676,29 +4630,13 @@ package body Exp_Ch4 is if Is_Constrained (Siz_Typ) and then Ekind (Siz_Typ) /= E_String_Literal_Subtype then - -- For CCG targets, the largest array may have up to 2**31-1 - -- components (i.e. 2 gigabytes if each array component is - -- one byte). This ensures that fat pointer fields do not - -- overflow, since they are 32-bit integer types, and also - -- ensures that 'Length can be computed at run time. - - if Modify_Tree_For_C then - Cond := - Make_Op_Gt (Loc, - Left_Opnd => Size_In_Storage_Elements (Siz_Typ), - Right_Opnd => Make_Integer_Literal (Loc, - Uint_2 ** 31 - Uint_1)); - - -- For native targets the largest object is 3.5 gigabytes - - else - Cond := - Make_Op_Gt (Loc, - Left_Opnd => Size_In_Storage_Elements (Siz_Typ), - Right_Opnd => Make_Integer_Literal (Loc, - Uint_7 * (Uint_2 ** 29))); - end if; + -- The largest object is 3.5 gigabytes + Cond := + Make_Op_Gt (Loc, + Left_Opnd => Size_In_Storage_Elements (Siz_Typ), + Right_Opnd => Make_Integer_Literal (Loc, + Uint_7 * (Uint_2 ** 29))); Insert_Action (Ins_Nod, Make_Raise_Storage_Error (Loc, Condition => Cond, @@ -5060,15 +4998,7 @@ package body Exp_Ch4 is function Is_Copy_Type (Typ : Entity_Id) return Boolean is begin - -- If Minimize_Expression_With_Actions is True, we can afford to copy - -- large objects, as long as they are constrained and not limited. - - return - Is_Elementary_Type (Underlying_Type (Typ)) - or else - (Minimize_Expression_With_Actions - and then Is_Constrained (Underlying_Type (Typ)) - and then not Is_Limited_Type (Underlying_Type (Typ))); + return Is_Elementary_Type (Underlying_Type (Typ)); end Is_Copy_Type; -- Local variables @@ -5193,17 +5123,6 @@ package body Exp_Ch4 is -- type Ptr_Typ is access all Typ; else - if Generate_C_Code then - - -- We cannot ensure that correct C code will be generated if any - -- temporary is created down the line (to e.g. handle checks or - -- capture values) since we might end up with dangling references - -- to local variables, so better be safe and reject the construct. - - Error_Msg_N - ("case expression too complex, use case statement instead", N); - end if; - Target_Typ := Make_Temporary (Loc, 'P'); Append_To (Acts, @@ -5653,14 +5572,6 @@ package body Exp_Ch4 is Remove (Expr); if Present (Actions) then - - -- To minimize the use of Expression_With_Actions, just skip - -- the optimization as it is not critical for correctness. - - if Minimize_Expression_With_Actions then - return False; - end if; - Rewrite (N, Make_Expression_With_Actions (Loc, Expression => Relocate_Node (Expr), @@ -5886,7 +5797,6 @@ package body Exp_Ch4 is and then Compile_Time_Known_Bounds (Etype (Prefix (Elsex))) and then OK_For_Single_Subtype (Etype (Thenx), Etype (Prefix (Elsex))))) - and then not Generate_C_Code and then not Unnest_Subprogram_Mode then -- When the "then" or "else" expressions involve controlled function @@ -6133,45 +6043,62 @@ package body Exp_Ch4 is then -- We now wrap the actions into the appropriate expression - if Minimize_Expression_With_Actions - and then (Is_Elementary_Type (Underlying_Type (Typ)) - or else Is_Constrained (Underlying_Type (Typ))) - then - -- When the "then" or "else" expressions involve controlled - -- function calls, generated temporaries are chained on the - -- corresponding list of actions. These temporaries need to - -- be finalized after the if expression is evaluated. + -- We do not need to call Process_Transients_In_Expression on + -- the list of actions in this case, because the expansion of + -- Expression_With_Actions will do it. - Process_Transients_In_Expression (N, Then_Actions (N)); - Process_Transients_In_Expression (N, Else_Actions (N)); + if Present (Then_Actions (N)) then + Rewrite (Thenx, + Make_Expression_With_Actions (Sloc (Thenx), + Actions => Then_Actions (N), + Expression => Relocate_Node (Thenx))); - -- If we can't use N_Expression_With_Actions nodes, then we insert - -- the following sequence of actions (using Insert_Actions): + Set_Then_Actions (N, No_List); + Analyze_And_Resolve (Thenx, Typ); + end if; - -- Cnn : typ; - -- if cond then - -- <> - -- Cnn := then-expr; - -- else - -- <> - -- Cnn := else-expr - -- end if; + if Present (Else_Actions (N)) then + Rewrite (Elsex, + Make_Expression_With_Actions (Sloc (Elsex), + Actions => Else_Actions (N), + Expression => Relocate_Node (Elsex))); - -- and replace the if expression by a reference to Cnn + Set_Else_Actions (N, No_List); + Analyze_And_Resolve (Elsex, Typ); + end if; - declare - Cnn : constant Node_Id := Make_Temporary (Loc, 'C', N); + -- We must force expansion into an expression with actions when + -- an if expression gets used directly as an actual for an + -- anonymous access type. + if Force_Expand then + declare + Cnn : constant Entity_Id := Make_Temporary (Loc, 'C'); + Acts : List_Id; begin + Acts := New_List; + + -- Generate: + -- Cnn : Ann; + Decl := Make_Object_Declaration (Loc, Defining_Identifier => Cnn, Object_Definition => New_Occurrence_Of (Typ, Loc)); + Append_To (Acts, Decl); + + Set_No_Initialization (Decl); + + -- Generate: + -- if Cond then + -- Cnn := ; + -- else + -- Cnn := ; + -- end if; New_If := Make_Implicit_If_Statement (N, Condition => Relocate_Node (Cond), - Then_Statements => New_List ( Make_Assignment_Statement (Sloc (Thenx), Name => New_Occurrence_Of (Cnn, Sloc (Thenx)), @@ -6181,99 +6108,23 @@ package body Exp_Ch4 is Make_Assignment_Statement (Sloc (Elsex), Name => New_Occurrence_Of (Cnn, Sloc (Elsex)), Expression => Relocate_Node (Elsex)))); + Append_To (Acts, New_If); - Set_Assignment_OK (Name (First (Then_Statements (New_If)))); - Set_Assignment_OK (Name (First (Else_Statements (New_If)))); + -- Generate: + -- do + -- ... + -- in Cnn end; - New_N := New_Occurrence_Of (Cnn, Loc); + Rewrite (N, + Make_Expression_With_Actions (Loc, + Expression => New_Occurrence_Of (Cnn, Loc), + Actions => Acts)); + Analyze_And_Resolve (N, Typ); end; - - -- Regular path using Expression_With_Actions - - else - -- We do not need to call Process_Transients_In_Expression on - -- the list of actions in this case, because the expansion of - -- Expression_With_Actions will do it. - - if Present (Then_Actions (N)) then - Rewrite (Thenx, - Make_Expression_With_Actions (Sloc (Thenx), - Actions => Then_Actions (N), - Expression => Relocate_Node (Thenx))); - - Set_Then_Actions (N, No_List); - Analyze_And_Resolve (Thenx, Typ); - end if; - - if Present (Else_Actions (N)) then - Rewrite (Elsex, - Make_Expression_With_Actions (Sloc (Elsex), - Actions => Else_Actions (N), - Expression => Relocate_Node (Elsex))); - - Set_Else_Actions (N, No_List); - Analyze_And_Resolve (Elsex, Typ); - end if; - - -- We must force expansion into an expression with actions when - -- an if expression gets used directly as an actual for an - -- anonymous access type. - - if Force_Expand then - declare - Cnn : constant Entity_Id := Make_Temporary (Loc, 'C'); - Acts : List_Id; - begin - Acts := New_List; - - -- Generate: - -- Cnn : Ann; - - Decl := - Make_Object_Declaration (Loc, - Defining_Identifier => Cnn, - Object_Definition => New_Occurrence_Of (Typ, Loc)); - Append_To (Acts, Decl); - - Set_No_Initialization (Decl); - - -- Generate: - -- if Cond then - -- Cnn := ; - -- else - -- Cnn := ; - -- end if; - - New_If := - Make_Implicit_If_Statement (N, - Condition => Relocate_Node (Cond), - Then_Statements => New_List ( - Make_Assignment_Statement (Sloc (Thenx), - Name => New_Occurrence_Of (Cnn, Sloc (Thenx)), - Expression => Relocate_Node (Thenx))), - - Else_Statements => New_List ( - Make_Assignment_Statement (Sloc (Elsex), - Name => New_Occurrence_Of (Cnn, Sloc (Elsex)), - Expression => Relocate_Node (Elsex)))); - Append_To (Acts, New_If); - - -- Generate: - -- do - -- ... - -- in Cnn end; - - Rewrite (N, - Make_Expression_With_Actions (Loc, - Expression => New_Occurrence_Of (Cnn, Loc), - Actions => Acts)); - Analyze_And_Resolve (N, Typ); - end; - end if; - - return; end if; + return; + -- For the sake of GNATcoverage, generate an intermediate temporary in -- the case where the if expression is a condition in an outer decision, -- in order to make sure that no branch is shared between the decisions. @@ -9254,8 +9105,7 @@ package body Exp_Ch4 is -- mod are the same, see (RM 4.5.5(28-30)). We do this since it is quite -- likely that this will improve the quality of code, (the operation now -- corresponds to the hardware remainder), and it does not seem likely - -- that it could be harmful. It also avoids some cases of the elaborate - -- expansion in Modify_Tree_For_C mode below (since Ada rem = C %). + -- that it could be harmful. if (LOK and ROK) and then ((Llo >= 0 and then Rlo >= 0) @@ -9319,104 +9169,6 @@ package body Exp_Ch4 is return; end if; - -- If we still have a mod operator and we are in Modify_Tree_For_C - -- mode, and we have a signed integer type, then here is where we do - -- the rewrite in terms of Rem. Note this rewrite bypasses the need - -- for the special handling of the annoying case of largest negative - -- number mod minus one. - - if Nkind (N) = N_Op_Mod - and then Is_Signed_Integer_Type (Typ) - and then Modify_Tree_For_C - then - -- In the general case, we expand A mod B as - - -- Tnn : constant typ := A rem B; - -- .. - -- (if (A >= 0) = (B >= 0) then Tnn - -- elsif Tnn = 0 then 0 - -- else Tnn + B) - - -- The comparison can be written simply as A >= 0 if we know that - -- B >= 0 which is a very common case. - - -- An important optimization is when B is known at compile time - -- to be 2**K for some constant. In this case we can simply AND - -- the left operand with the bit string 2**K-1 (i.e. K 1-bits) - -- and that works for both the positive and negative cases. - - declare - P2 : constant Nat := Power_Of_Two (Right); - - begin - if P2 /= 0 then - Rewrite (N, - Unchecked_Convert_To (Typ, - Make_Op_And (Loc, - Left_Opnd => - Unchecked_Convert_To - (Corresponding_Unsigned_Type (Typ), Left), - Right_Opnd => - Make_Integer_Literal (Loc, 2 ** P2 - 1)))); - Analyze_And_Resolve (N, Typ); - return; - end if; - end; - - -- Here for the full rewrite - - declare - Tnn : constant Entity_Id := Make_Temporary (Sloc (N), 'T', N); - Cmp : Node_Id; - - begin - Cmp := - Make_Op_Ge (Loc, - Left_Opnd => Duplicate_Subexpr_No_Checks (Left), - Right_Opnd => Make_Integer_Literal (Loc, 0)); - - if not LOK or else Rlo < 0 then - Cmp := - Make_Op_Eq (Loc, - Left_Opnd => Cmp, - Right_Opnd => - Make_Op_Ge (Loc, - Left_Opnd => Duplicate_Subexpr_No_Checks (Right), - Right_Opnd => Make_Integer_Literal (Loc, 0))); - end if; - - Insert_Action (N, - Make_Object_Declaration (Loc, - Defining_Identifier => Tnn, - Constant_Present => True, - Object_Definition => New_Occurrence_Of (Typ, Loc), - Expression => - Make_Op_Rem (Loc, - Left_Opnd => Left, - Right_Opnd => Right))); - - Rewrite (N, - Make_If_Expression (Loc, - Expressions => New_List ( - Cmp, - New_Occurrence_Of (Tnn, Loc), - Make_If_Expression (Loc, - Is_Elsif => True, - Expressions => New_List ( - Make_Op_Eq (Loc, - Left_Opnd => New_Occurrence_Of (Tnn, Loc), - Right_Opnd => Make_Integer_Literal (Loc, 0)), - Make_Integer_Literal (Loc, 0), - Make_Op_Add (Loc, - Left_Opnd => New_Occurrence_Of (Tnn, Loc), - Right_Opnd => - Duplicate_Subexpr_No_Checks (Right))))))); - - Analyze_And_Resolve (N, Typ); - return; - end; - end if; - -- Deal with annoying case of largest negative number mod minus one. -- Gigi may not handle this case correctly, because on some targets, -- the mod value is computed using a divide instruction which gives @@ -9825,15 +9577,6 @@ package body Exp_Ch4 is -- return B; -- end Nnnn; - -- or in the case of Transform_Function_Array: - - -- procedure Nnnn (A : arr; RESULT : out arr) is - -- begin - -- for J in a'range loop - -- RESULT (J) := not A (J); - -- end loop; - -- end Nnnn; - -- Here arr is the actual subtype of the parameter (and hence always -- constrained). Then we replace the not with a call to this subprogram. @@ -9935,13 +9678,7 @@ package body Exp_Ch4 is end if; A := Make_Defining_Identifier (Loc, Name_uA); - - if Transform_Function_Array then - B := Make_Defining_Identifier (Loc, Name_UP_RESULT); - else - B := Make_Defining_Identifier (Loc, Name_uB); - end if; - + B := Make_Defining_Identifier (Loc, Name_uB); J := Make_Defining_Identifier (Loc, Name_uJ); A_J := @@ -9976,82 +9713,33 @@ package body Exp_Ch4 is Func_Name := Make_Temporary (Loc, 'N'); Set_Is_Inlined (Func_Name); - if Transform_Function_Array then - Insert_Action (N, - Make_Subprogram_Body (Loc, - Specification => - Make_Procedure_Specification (Loc, - Defining_Unit_Name => Func_Name, - Parameter_Specifications => New_List ( - Make_Parameter_Specification (Loc, - Defining_Identifier => A, - Parameter_Type => New_Occurrence_Of (Typ, Loc)), - Make_Parameter_Specification (Loc, - Defining_Identifier => B, - Out_Present => True, - Parameter_Type => New_Occurrence_Of (Typ, Loc)))), - - Declarations => New_List, - - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => New_List (Loop_Statement)))); - - declare - Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'T'); - Call : Node_Id; - Decl : Node_Id; - - begin - -- Generate: - -- Temp : ...; - - Decl := - Make_Object_Declaration (Loc, - Defining_Identifier => Temp_Id, - Object_Definition => New_Occurrence_Of (Typ, Loc)); - - -- Generate: - -- Proc_Call (Opnd, Temp); + Insert_Action (N, + Make_Subprogram_Body (Loc, + Specification => + Make_Function_Specification (Loc, + Defining_Unit_Name => Func_Name, + Parameter_Specifications => New_List ( + Make_Parameter_Specification (Loc, + Defining_Identifier => A, + Parameter_Type => New_Occurrence_Of (Typ, Loc))), + Result_Definition => New_Occurrence_Of (Typ, Loc)), - Call := - Make_Procedure_Call_Statement (Loc, - Name => New_Occurrence_Of (Func_Name, Loc), - Parameter_Associations => - New_List (Opnd, New_Occurrence_Of (Temp_Id, Loc))); + Declarations => New_List ( + Make_Object_Declaration (Loc, + Defining_Identifier => B, + Object_Definition => New_Occurrence_Of (Arr, Loc))), - Insert_Actions (Parent (N), New_List (Decl, Call)); - Rewrite (N, New_Occurrence_Of (Temp_Id, Loc)); - end; - else - Insert_Action (N, - Make_Subprogram_Body (Loc, - Specification => - Make_Function_Specification (Loc, - Defining_Unit_Name => Func_Name, - Parameter_Specifications => New_List ( - Make_Parameter_Specification (Loc, - Defining_Identifier => A, - Parameter_Type => New_Occurrence_Of (Typ, Loc))), - Result_Definition => New_Occurrence_Of (Typ, Loc)), - - Declarations => New_List ( - Make_Object_Declaration (Loc, - Defining_Identifier => B, - Object_Definition => New_Occurrence_Of (Arr, Loc))), - - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => New_List ( - Loop_Statement, - Make_Simple_Return_Statement (Loc, - Expression => Make_Identifier (Loc, Chars (B))))))); + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => New_List ( + Loop_Statement, + Make_Simple_Return_Statement (Loc, + Expression => Make_Identifier (Loc, Chars (B))))))); - Rewrite (N, - Make_Function_Call (Loc, - Name => New_Occurrence_Of (Func_Name, Loc), - Parameter_Associations => New_List (Opnd))); - end if; + Rewrite (N, + Make_Function_Call (Loc, + Name => New_Occurrence_Of (Func_Name, Loc), + Parameter_Associations => New_List (Opnd))); Analyze_And_Resolve (N, Typ); end Expand_N_Op_Not; @@ -10233,52 +9921,6 @@ package body Exp_Ch4 is procedure Expand_N_Op_Rotate_Left (N : Node_Id) is begin Binary_Op_Validity_Checks (N); - - -- If we are in Modify_Tree_For_C mode, there is no rotate left in C, - -- so we rewrite in terms of logical shifts - - -- Shift_Left (Num, Bits) or Shift_Right (num, Esize - Bits) - - -- where Bits is the shift count mod Esize (the mod operation here - -- deals with ludicrous large shift counts, which are apparently OK). - - if Modify_Tree_For_C then - declare - Loc : constant Source_Ptr := Sloc (N); - Rtp : constant Entity_Id := Etype (Right_Opnd (N)); - Typ : constant Entity_Id := Etype (N); - - begin - -- Sem_Intr should prevent getting there with a non binary modulus - - pragma Assert (not Non_Binary_Modulus (Typ)); - - Rewrite (Right_Opnd (N), - Make_Op_Rem (Loc, - Left_Opnd => Relocate_Node (Right_Opnd (N)), - Right_Opnd => Make_Integer_Literal (Loc, Esize (Typ)))); - - Analyze_And_Resolve (Right_Opnd (N), Rtp); - - Rewrite (N, - Make_Op_Or (Loc, - Left_Opnd => - Make_Op_Shift_Left (Loc, - Left_Opnd => Left_Opnd (N), - Right_Opnd => Right_Opnd (N)), - - Right_Opnd => - Make_Op_Shift_Right (Loc, - Left_Opnd => Duplicate_Subexpr_No_Checks (Left_Opnd (N)), - Right_Opnd => - Make_Op_Subtract (Loc, - Left_Opnd => Make_Integer_Literal (Loc, Esize (Typ)), - Right_Opnd => - Duplicate_Subexpr_No_Checks (Right_Opnd (N)))))); - - Analyze_And_Resolve (N, Typ); - end; - end if; end Expand_N_Op_Rotate_Left; ------------------------------ @@ -10288,52 +9930,6 @@ package body Exp_Ch4 is procedure Expand_N_Op_Rotate_Right (N : Node_Id) is begin Binary_Op_Validity_Checks (N); - - -- If we are in Modify_Tree_For_C mode, there is no rotate right in C, - -- so we rewrite in terms of logical shifts - - -- Shift_Right (Num, Bits) or Shift_Left (num, Esize - Bits) - - -- where Bits is the shift count mod Esize (the mod operation here - -- deals with ludicrous large shift counts, which are apparently OK). - - if Modify_Tree_For_C then - declare - Loc : constant Source_Ptr := Sloc (N); - Rtp : constant Entity_Id := Etype (Right_Opnd (N)); - Typ : constant Entity_Id := Etype (N); - - begin - -- Sem_Intr should prevent getting there with a non binary modulus - - pragma Assert (not Non_Binary_Modulus (Typ)); - - Rewrite (Right_Opnd (N), - Make_Op_Rem (Loc, - Left_Opnd => Relocate_Node (Right_Opnd (N)), - Right_Opnd => Make_Integer_Literal (Loc, Esize (Typ)))); - - Analyze_And_Resolve (Right_Opnd (N), Rtp); - - Rewrite (N, - Make_Op_Or (Loc, - Left_Opnd => - Make_Op_Shift_Right (Loc, - Left_Opnd => Left_Opnd (N), - Right_Opnd => Right_Opnd (N)), - - Right_Opnd => - Make_Op_Shift_Left (Loc, - Left_Opnd => Duplicate_Subexpr_No_Checks (Left_Opnd (N)), - Right_Opnd => - Make_Op_Subtract (Loc, - Left_Opnd => Make_Integer_Literal (Loc, Esize (Typ)), - Right_Opnd => - Duplicate_Subexpr_No_Checks (Right_Opnd (N)))))); - - Analyze_And_Resolve (N, Typ); - end; - end if; end Expand_N_Op_Rotate_Right; ---------------------------- @@ -10346,62 +9942,6 @@ package body Exp_Ch4 is procedure Expand_N_Op_Shift_Left (N : Node_Id) is begin Binary_Op_Validity_Checks (N); - - -- If we are in Modify_Tree_For_C mode, then ensure that the right - -- operand is not greater than the word size (since that would not - -- be defined properly by the corresponding C shift operator). - - if Modify_Tree_For_C then - declare - Right : constant Node_Id := Right_Opnd (N); - Loc : constant Source_Ptr := Sloc (Right); - Typ : constant Entity_Id := Etype (N); - Siz : constant Uint := Esize (Typ); - Orig : Node_Id; - OK : Boolean; - Lo : Uint; - Hi : Uint; - - begin - -- Sem_Intr should prevent getting there with a non binary modulus - - pragma Assert (not Non_Binary_Modulus (Typ)); - - if Compile_Time_Known_Value (Right) then - if Expr_Value (Right) >= Siz then - Rewrite (N, Make_Integer_Literal (Loc, 0)); - Analyze_And_Resolve (N, Typ); - end if; - - -- Not compile time known, find range - - else - Determine_Range (Right, OK, Lo, Hi, Assume_Valid => True); - - -- Nothing to do if known to be OK range, otherwise expand - - if not OK or else Hi >= Siz then - - -- Prevent recursion on copy of shift node - - Orig := Relocate_Node (N); - Set_Analyzed (Orig); - - -- Now do the rewrite - - Rewrite (N, - Make_If_Expression (Loc, - Expressions => New_List ( - Make_Op_Ge (Loc, - Left_Opnd => Duplicate_Subexpr_Move_Checks (Right), - Right_Opnd => Make_Integer_Literal (Loc, Siz)), - Make_Integer_Literal (Loc, 0), - Orig))); - Analyze_And_Resolve (N, Typ); - end if; - end if; - end; - end if; end Expand_N_Op_Shift_Left; ----------------------------- @@ -10422,89 +9962,6 @@ package body Exp_Ch4 is procedure Expand_N_Op_Shift_Right_Arithmetic (N : Node_Id) is begin Binary_Op_Validity_Checks (N); - - -- If we are in Modify_Tree_For_C mode, there is no shift right - -- arithmetic in C, so we rewrite in terms of logical shifts for - -- modular integers, and keep the Shift_Right intrinsic for signed - -- integers: even though doing a shift on a signed integer is not - -- fully guaranteed by the C standard, this is what C compilers - -- implement in practice. - -- Consider also taking advantage of this for modular integers by first - -- performing an unchecked conversion of the modular integer to a signed - -- integer of the same sign, and then convert back. - - -- Shift_Right (Num, Bits) or - -- (if Num >= Sign - -- then not (Shift_Right (Mask, bits)) - -- else 0) - - -- Here Mask is all 1 bits (2**size - 1), and Sign is 2**(size - 1) - - -- Note: the above works fine for shift counts greater than or equal - -- to the word size, since in this case (not (Shift_Right (Mask, bits))) - -- generates all 1'bits. - - if Modify_Tree_For_C and then Is_Modular_Integer_Type (Etype (N)) then - declare - Loc : constant Source_Ptr := Sloc (N); - Typ : constant Entity_Id := Etype (N); - Sign : constant Uint := 2 ** (Esize (Typ) - 1); - Mask : constant Uint := (2 ** Esize (Typ)) - 1; - Left : constant Node_Id := Left_Opnd (N); - Right : constant Node_Id := Right_Opnd (N); - Maskx : Node_Id; - - begin - -- Sem_Intr should prevent getting there with a non binary modulus - - pragma Assert (not Non_Binary_Modulus (Typ)); - - -- Here if not (Shift_Right (Mask, bits)) can be computed at - -- compile time as a single constant. - - if Compile_Time_Known_Value (Right) then - declare - Val : constant Uint := Expr_Value (Right); - - begin - if Val >= Esize (Typ) then - Maskx := Make_Integer_Literal (Loc, Mask); - - else - Maskx := - Make_Integer_Literal (Loc, - Intval => Mask - (Mask / (2 ** Expr_Value (Right)))); - end if; - end; - - else - Maskx := - Make_Op_Not (Loc, - Right_Opnd => - Make_Op_Shift_Right (Loc, - Left_Opnd => Make_Integer_Literal (Loc, Mask), - Right_Opnd => Duplicate_Subexpr_No_Checks (Right))); - end if; - - -- Now do the rewrite - - Rewrite (N, - Make_Op_Or (Loc, - Left_Opnd => - Make_Op_Shift_Right (Loc, - Left_Opnd => Left, - Right_Opnd => Right), - Right_Opnd => - Make_If_Expression (Loc, - Expressions => New_List ( - Make_Op_Ge (Loc, - Left_Opnd => Duplicate_Subexpr_No_Checks (Left), - Right_Opnd => Make_Integer_Literal (Loc, Sign)), - Maskx, - Make_Integer_Literal (Loc, 0))))); - Analyze_And_Resolve (N, Typ); - end; - end if; end Expand_N_Op_Shift_Right_Arithmetic; -------------------------- @@ -11408,14 +10865,6 @@ package body Exp_Ch4 is if Is_Fixed_Point_Type (Etype (Expr)) then Ityp := Small_Integer_Type_For (Esize (Base_Type (Etype (Expr))), Uns => False); - - -- Generate a temporary with the integer type to facilitate in the - -- C backend the code generation for the unchecked conversion. - - if Modify_Tree_For_C then - Generate_Temporary; - end if; - Rewrite (Expr, Unchecked_Convert_To (Ityp, Expr)); end if; @@ -12660,27 +12109,6 @@ package body Exp_Ch4 is return; end if; - -- Generate an extra temporary for cases unsupported by the C backend - - if Modify_Tree_For_C then - declare - Source : constant Node_Id := Unqual_Conv (Expression (N)); - Source_Typ : Entity_Id := Get_Full_View (Etype (Source)); - - begin - if Is_Packed_Array (Source_Typ) then - Source_Typ := Packed_Array_Impl_Type (Source_Typ); - end if; - - if Nkind (Source) = N_Function_Call - and then (Is_Composite_Type (Etype (Source)) - or else Is_Composite_Type (Target_Type)) - then - Force_Evaluation (Source); - end if; - end; - end if; - -- Nothing to do if conversion is safe if Safe_Unchecked_Type_Conversion (N) then @@ -12936,26 +12364,9 @@ package body Exp_Ch4 is Shortcut_Ent : constant Entity_Id := Boolean_Literals (Shortcut_Value); -- If Left = Shortcut_Value then Right need not be evaluated - function Make_Test_Expr (Opnd : Node_Id) return Node_Id; - -- For Opnd a boolean expression, return a Boolean expression equivalent - -- to Opnd /= Shortcut_Value. - function Useful (Actions : List_Id) return Boolean; -- Return True if Actions contains useful nodes to process - -------------------- - -- Make_Test_Expr -- - -------------------- - - function Make_Test_Expr (Opnd : Node_Id) return Node_Id is - begin - if Shortcut_Value then - return Make_Op_Not (Sloc (Opnd), Opnd); - else - return Opnd; - end if; - end Make_Test_Expr; - ------------ -- Useful -- ------------ @@ -12979,12 +12390,6 @@ package body Exp_Ch4 is return False; end Useful; - -- Local variables - - Op_Var : Entity_Id; - -- Entity for a temporary variable holding the value of the operator, - -- used for expansion in the case where actions are present. - -- Start of processing for Expand_Short_Circuit_Operator begin @@ -13041,73 +12446,17 @@ package body Exp_Ch4 is if Useful (Actions (N)) then Actlist := Actions (N); - -- The old approach is to expand: - - -- left AND THEN right + -- Use an Expression_With_Actions node for the right operand of the + -- short-circuit form. Note that this solves traceability problems + -- for coverage analysis at the object level. - -- into - - -- C : Boolean := False; - -- IF left THEN - -- Actions; - -- IF right THEN - -- C := True; - -- END IF; - -- END IF; - - -- and finally rewrite the operator into a reference to C. Similarly - -- for left OR ELSE right, with negated values. Note that this - -- rewrite causes some difficulties for coverage analysis because - -- of the introduction of the new variable C, which obscures the - -- structure of the test. - - -- We use this "old approach" if Minimize_Expression_With_Actions - -- is True. - - if Minimize_Expression_With_Actions then - Op_Var := Make_Temporary (Loc, 'C', Related_Node => N); - - Insert_Action (N, - Make_Object_Declaration (Loc, - Defining_Identifier => Op_Var, - Object_Definition => - New_Occurrence_Of (Standard_Boolean, Loc), - Expression => - New_Occurrence_Of (Shortcut_Ent, Loc))); - - Append_To (Actlist, - Make_Implicit_If_Statement (Right, - Condition => Make_Test_Expr (Right), - Then_Statements => New_List ( - Make_Assignment_Statement (LocR, - Name => New_Occurrence_Of (Op_Var, LocR), - Expression => - New_Occurrence_Of - (Boolean_Literals (not Shortcut_Value), LocR))))); - - Insert_Action (N, - Make_Implicit_If_Statement (Left, - Condition => Make_Test_Expr (Left), - Then_Statements => Actlist)); - - Rewrite (N, New_Occurrence_Of (Op_Var, Loc)); - Analyze_And_Resolve (N, Standard_Boolean); - - -- The new approach (the default) is to use an - -- Expression_With_Actions node for the right operand of the - -- short-circuit form. Note that this solves the traceability - -- problems for coverage analysis. - - else - Rewrite (Right, - Make_Expression_With_Actions (LocR, - Expression => Relocate_Node (Right), - Actions => Actlist)); - - Set_Actions (N, No_List); - Analyze_And_Resolve (Right, Standard_Boolean); - end if; + Rewrite (Right, + Make_Expression_With_Actions (LocR, + Expression => Relocate_Node (Right), + Actions => Actlist)); + Set_Actions (N, No_List); + Analyze_And_Resolve (Right, Standard_Boolean); Adjust_Result_Type (N, Typ); return; end if; @@ -14036,15 +13385,6 @@ package body Exp_Ch4 is -- return C; -- end Annn; - -- or in the case of Transform_Function_Array: - - -- procedure Annn (A : typ; B: typ; RESULT: out typ) is - -- begin - -- for J in A'range loop - -- RESULT (J) := A (J) op B (J); - -- end loop; - -- end Annn; - -- Here typ is the boolean array type function Make_Boolean_Array_Op @@ -14070,11 +13410,7 @@ package body Exp_Ch4 is Loop_Statement : Node_Id; begin - if Transform_Function_Array then - C := Make_Defining_Identifier (Loc, Name_UP_RESULT); - else - C := Make_Defining_Identifier (Loc, Name_uC); - end if; + C := Make_Defining_Identifier (Loc, Name_uC); A_J := Make_Indexed_Component (Loc, @@ -14138,52 +13474,28 @@ package body Exp_Ch4 is Defining_Identifier => B, Parameter_Type => New_Occurrence_Of (Typ, Loc))); - if Transform_Function_Array then - Append_To (Formals, - Make_Parameter_Specification (Loc, - Defining_Identifier => C, - Out_Present => True, - Parameter_Type => New_Occurrence_Of (Typ, Loc))); - end if; - Func_Name := Make_Temporary (Loc, 'A'); Set_Is_Inlined (Func_Name); - if Transform_Function_Array then - Func_Body := - Make_Subprogram_Body (Loc, - Specification => - Make_Procedure_Specification (Loc, - Defining_Unit_Name => Func_Name, - Parameter_Specifications => Formals), - - Declarations => New_List, + Func_Body := + Make_Subprogram_Body (Loc, + Specification => + Make_Function_Specification (Loc, + Defining_Unit_Name => Func_Name, + Parameter_Specifications => Formals, + Result_Definition => New_Occurrence_Of (Typ, Loc)), - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => New_List (Loop_Statement))); + Declarations => New_List ( + Make_Object_Declaration (Loc, + Defining_Identifier => C, + Object_Definition => New_Occurrence_Of (Typ, Loc))), - else - Func_Body := - Make_Subprogram_Body (Loc, - Specification => - Make_Function_Specification (Loc, - Defining_Unit_Name => Func_Name, - Parameter_Specifications => Formals, - Result_Definition => New_Occurrence_Of (Typ, Loc)), - - Declarations => New_List ( - Make_Object_Declaration (Loc, - Defining_Identifier => C, - Object_Definition => New_Occurrence_Of (Typ, Loc))), - - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => New_List ( - Loop_Statement, - Make_Simple_Return_Statement (Loc, - Expression => New_Occurrence_Of (C, Loc))))); - end if; + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => New_List ( + Loop_Statement, + Make_Simple_Return_Statement (Loc, + Expression => New_Occurrence_Of (C, Loc))))); return Func_Body; end Make_Boolean_Array_Op; diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 5d808a3402d..548589284e2 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -346,10 +346,6 @@ package body Exp_Ch6 is -- of the return scope's entity list and the list structure would otherwise -- be corrupted. The homonym chain is preserved as well. - procedure Rewrite_Function_Call_For_C (N : Node_Id); - -- When generating C code, replace a call to a function that returns an - -- array into the generated procedure with an additional out parameter. - procedure Set_Enclosing_Sec_Stack_Return (N : Node_Id); -- N is a return statement for a function that returns its result on the -- secondary stack. This sets the Sec_Stack_Needed_For_Return flag on the @@ -4078,73 +4074,6 @@ package body Exp_Ch6 is return; end if; - if Transform_Function_Array - and then Nkind (Call_Node) = N_Function_Call - and then Is_Entity_Name (Name (Call_Node)) - then - declare - Func_Id : constant Entity_Id := - Ultimate_Alias (Entity (Name (Call_Node))); - begin - -- When generating C code, transform a function call that returns - -- a constrained array type into procedure form. - - if Rewritten_For_C (Func_Id) then - - -- For internally generated calls ensure that they reference - -- the entity of the spec of the called function (needed since - -- the expander may generate calls using the entity of their - -- body). - - if not Comes_From_Source (Call_Node) - and then Nkind (Unit_Declaration_Node (Func_Id)) = - N_Subprogram_Body - then - Set_Entity (Name (Call_Node), - Corresponding_Function - (Corresponding_Procedure (Func_Id))); - end if; - - Rewrite_Function_Call_For_C (Call_Node); - return; - - -- Also introduce a temporary for functions that return a record - -- called within another procedure or function call, since records - -- are passed by pointer in the generated C code, and we cannot - -- take a pointer from a subprogram call. - - elsif Modify_Tree_For_C - and then Nkind (Parent (Call_Node)) in N_Subprogram_Call - and then Is_Record_Type (Etype (Func_Id)) - then - declare - Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'T'); - Decl : Node_Id; - - begin - -- Generate: - -- Temp : ... := Func_Call (...); - - Decl := - Make_Object_Declaration (Loc, - Defining_Identifier => Temp_Id, - Object_Definition => - New_Occurrence_Of (Etype (Func_Id), Loc), - Expression => - Make_Function_Call (Loc, - Name => - New_Occurrence_Of (Func_Id, Loc), - Parameter_Associations => - Parameter_Associations (Call_Node))); - - Insert_Action (Parent (Call_Node), Decl); - Rewrite (Call_Node, New_Occurrence_Of (Temp_Id, Loc)); - return; - end; - end if; - end; - end if; - -- First step, compute extra actuals, corresponding to any Extra_Formals -- present. Note that we do not access Extra_Formals directly, instead -- we simply note the presence of the extra formals as we process the @@ -4577,17 +4506,6 @@ package body Exp_Ch6 is Add_View_Conversion_Invariants (Formal, Actual); end if; - -- Generating C the initialization of an allocator is performed by - -- means of individual statements, and hence it must be done before - -- the call. - - if Modify_Tree_For_C - and then Nkind (Actual) = N_Allocator - and then Nkind (Expression (Actual)) = N_Qualified_Expression - then - Remove_Side_Effects (Actual); - end if; - -- This label is required when skipping extra actual generation for -- Unchecked_Union parameters. @@ -5262,15 +5180,6 @@ package body Exp_Ch6 is and then In_Package_Body then Must_Inline := not In_Extended_Main_Source_Unit (Subp); - - -- Inline calls to _Wrapped_Statements when generating C - - elsif Modify_Tree_For_C - and then In_Same_Extended_Unit (Sloc (Bod), Loc) - and then Chars (Name (Call_Node)) - = Name_uWrapped_Statements - then - Must_Inline := True; end if; end if; @@ -6173,7 +6082,6 @@ package body Exp_Ch6 is Prot_Bod : Node_Id; Prot_Decl : Node_Id; Prot_Id : Entity_Id; - Typ : Entity_Id; begin -- Deal with case of protected subprogram. Do not generate protected @@ -6239,25 +6147,6 @@ package body Exp_Ch6 is Set_Is_Inlined (Subp, False); end; end if; - - -- When generating C code, transform a function that returns a - -- constrained array type into a procedure with an out parameter - -- that carries the return value. - - -- We skip this transformation for unchecked conversions, since they - -- are not needed by the C generator (and this also produces cleaner - -- output). - - Typ := Get_Fullest_View (Etype (Subp)); - - if Transform_Function_Array - and then Nkind (Specification (N)) = N_Function_Specification - and then Is_Array_Type (Typ) - and then Is_Constrained (Typ) - and then not Is_Unchecked_Conversion_Instance (Subp) - then - Build_Procedure_Form (N); - end if; end Expand_N_Subprogram_Declaration; -------------------------------- @@ -9719,120 +9608,6 @@ package body Exp_Ch6 is Set_Is_Aliased (Orig_Id, Is_Aliased (New_Id)); end Replace_Renaming_Declaration_Id; - --------------------------------- - -- Rewrite_Function_Call_For_C -- - --------------------------------- - - procedure Rewrite_Function_Call_For_C (N : Node_Id) is - Orig_Func : constant Entity_Id := Entity (Name (N)); - Func_Id : constant Entity_Id := Ultimate_Alias (Orig_Func); - Par : constant Node_Id := Parent (N); - Proc_Id : constant Entity_Id := Corresponding_Procedure (Func_Id); - Loc : constant Source_Ptr := Sloc (Par); - Actuals : List_Id; - Last_Actual : Node_Id; - Last_Formal : Entity_Id; - - -- Start of processing for Rewrite_Function_Call_For_C - - begin - -- The actuals may be given by named associations, so the added actual - -- that is the target of the return value of the call must be a named - -- association as well, so we retrieve the name of the generated - -- out_formal. - - Last_Formal := First_Formal (Proc_Id); - while Present (Next_Formal (Last_Formal)) loop - Next_Formal (Last_Formal); - end loop; - - Actuals := Parameter_Associations (N); - - -- The original function may lack parameters - - if No (Actuals) then - Actuals := New_List; - end if; - - -- If the function call is the expression of an assignment statement, - -- transform the assignment into a procedure call. Generate: - - -- LHS := Func_Call (...); - - -- Proc_Call (..., LHS); - - -- If function is inherited, a conversion may be necessary. - - if Nkind (Par) = N_Assignment_Statement then - Last_Actual := Name (Par); - - if not Comes_From_Source (Orig_Func) - and then Etype (Orig_Func) /= Etype (Func_Id) - then - Last_Actual := - Make_Type_Conversion (Loc, - New_Occurrence_Of (Etype (Func_Id), Loc), - Last_Actual); - end if; - - Append_To (Actuals, - Make_Parameter_Association (Loc, - Selector_Name => - Make_Identifier (Loc, Chars (Last_Formal)), - Explicit_Actual_Parameter => Last_Actual)); - - Rewrite (Par, - Make_Procedure_Call_Statement (Loc, - Name => New_Occurrence_Of (Proc_Id, Loc), - Parameter_Associations => Actuals)); - Analyze (Par); - - -- Otherwise the context is an expression. Generate a temporary and a - -- procedure call to obtain the function result. Generate: - - -- ... Func_Call (...) ... - - -- Temp : ...; - -- Proc_Call (..., Temp); - -- ... Temp ... - - else - declare - Temp_Id : constant Entity_Id := Make_Temporary (Loc, 'T'); - Call : Node_Id; - Decl : Node_Id; - - begin - -- Generate: - -- Temp : ...; - - Decl := - Make_Object_Declaration (Loc, - Defining_Identifier => Temp_Id, - Object_Definition => - New_Occurrence_Of (Etype (Func_Id), Loc)); - - -- Generate: - -- Proc_Call (..., Temp); - - Append_To (Actuals, - Make_Parameter_Association (Loc, - Selector_Name => - Make_Identifier (Loc, Chars (Last_Formal)), - Explicit_Actual_Parameter => - New_Occurrence_Of (Temp_Id, Loc))); - - Call := - Make_Procedure_Call_Statement (Loc, - Name => New_Occurrence_Of (Proc_Id, Loc), - Parameter_Associations => Actuals); - - Insert_Actions (Par, New_List (Decl, Call)); - Rewrite (N, New_Occurrence_Of (Temp_Id, Loc)); - end; - end if; - end Rewrite_Function_Call_For_C; - ------------------------------------ -- Set_Enclosing_Sec_Stack_Return -- ------------------------------------ diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 16d53853646..a6912f7ad48 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -3870,17 +3870,13 @@ package body Exp_Ch7 is end if; end; - elsif Nkind (Decl_Or_Stmt) = N_Package_Declaration - and then not Modify_Tree_For_C - then + elsif Nkind (Decl_Or_Stmt) = N_Package_Declaration then Check_Unnesting_In_Decls_Or_Stmts (Visible_Declarations (Specification (Decl_Or_Stmt))); Check_Unnesting_In_Decls_Or_Stmts (Private_Declarations (Specification (Decl_Or_Stmt))); - elsif Nkind (Decl_Or_Stmt) = N_Package_Body - and then not Modify_Tree_For_C - then + elsif Nkind (Decl_Or_Stmt) = N_Package_Body then Check_Unnesting_In_Decls_Or_Stmts (Declarations (Decl_Or_Stmt)); if Present (Statements (Handled_Statement_Sequence (Decl_Or_Stmt))) diff --git a/gcc/ada/exp_ch8.adb b/gcc/ada/exp_ch8.adb index 011c1feaf33..518ce8b1cc5 100644 --- a/gcc/ada/exp_ch8.adb +++ b/gcc/ada/exp_ch8.adb @@ -113,8 +113,6 @@ package body Exp_Ch8 is -- atomic object. Note that we are only interested in these operations -- if they occur as part of the name itself, subscripts are just values -- that are computed as part of the evaluation, so they are unimportant. - -- In addition, always return True for Modify_Tree_For_C since the - -- code generator doesn't know how to handle renamings. ------------------------- -- Evaluation_Required -- @@ -122,10 +120,7 @@ package body Exp_Ch8 is function Evaluation_Required (Nam : Node_Id) return Boolean is begin - if Modify_Tree_For_C then - return True; - - elsif Nkind (Nam) in N_Indexed_Component | N_Slice then + if Nkind (Nam) in N_Indexed_Component | N_Slice then if Is_Packed (Etype (Prefix (Nam))) then return True; diff --git a/gcc/ada/exp_dbug.adb b/gcc/ada/exp_dbug.adb index e0f0f4f48b7..64e3871ef82 100644 --- a/gcc/ada/exp_dbug.adb +++ b/gcc/ada/exp_dbug.adb @@ -1504,52 +1504,12 @@ package body Exp_Dbug is Name_Len := Full_Qualify_Len; Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len); - -- Qualification needed for enumeration literals when generating C code - -- (to simplify their management in the backend). - - elsif Modify_Tree_For_C - and then Ekind (Ent) = E_Enumeration_Literal - and then Scope (Ultimate_Alias (Ent)) /= Standard_Standard - then - Fully_Qualify_Name (Ent); - Name_Len := Full_Qualify_Len; - Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len); - elsif Qualify_Needed (Scope (Ent)) then Name_Len := 0; Set_Entity_Name (Ent); else Set_Has_Qualified_Name (Ent); - - -- If a variable is hidden by a subsequent loop variable, qualify - -- the name of that loop variable to prevent visibility issues when - -- translating to C. Note that gdb probably never handled properly - -- this accidental hiding, given that loops are not scopes at - -- runtime. We also qualify a name if it hides an outer homonym, - -- and both are declared in blocks. - - if Modify_Tree_For_C and then Ekind (Ent) = E_Variable then - if Present (Hiding_Loop_Variable (Ent)) then - declare - Var : constant Entity_Id := Hiding_Loop_Variable (Ent); - - begin - Set_Entity_Name (Var); - Add_Char_To_Name_Buffer ('L'); - Set_Chars (Var, Name_Enter); - end; - - elsif Present (Homonym (Ent)) - and then Ekind (Scope (Ent)) = E_Block - and then Ekind (Scope (Homonym (Ent))) = E_Block - then - Set_Entity_Name (Ent); - Add_Char_To_Name_Buffer ('B'); - Set_Chars (Ent, Name_Enter); - end if; - end if; - return; end if; diff --git a/gcc/ada/exp_dbug.ads b/gcc/ada/exp_dbug.ads index 2b892c874d7..92502173639 100644 --- a/gcc/ada/exp_dbug.ads +++ b/gcc/ada/exp_dbug.ads @@ -445,21 +445,6 @@ package Exp_Dbug is -- WARNING: There is a matching C declaration of this subprogram in fe.h - ------------------------------------- - -- Encoding for translation into C -- - ------------------------------------- - - -- In Modify_Tree_For_C mode we must add encodings to dismabiguate cases - -- where Ada block structure cannot be directly translated. These cases - -- are as follows: - - -- a) A loop variable may hide a homonym in an enclosing block - -- b) A block-local variable may hide a homonym in an enclosing block - - -- In C these constructs are not scopes and we must distinguish the names - -- explicitly. In the first case we create a qualified name with the suffix - -- 'L', in the second case with a suffix 'B'. - -------------------------------------------- -- Subprograms for Handling Qualification -- -------------------------------------------- diff --git a/gcc/ada/exp_intr.adb b/gcc/ada/exp_intr.adb index 57f681a84b6..a076eb0eeb6 100644 --- a/gcc/ada/exp_intr.adb +++ b/gcc/ada/exp_intr.adb @@ -754,14 +754,9 @@ package body Exp_Intr is Rewrite (N, Snode); Set_Analyzed (N); - -- However, we do call the expander, so that the expansion for - -- rotates and shift_right_arithmetic happens if Modify_Tree_For_C - -- is set. - if Expander_Active then Expand (N); end if; - else -- If the context type is not the type of the operator, it is an -- inherited operator for a derived type. Wrap the node in a diff --git a/gcc/ada/exp_unst.adb b/gcc/ada/exp_unst.adb index d3f31448054..19bb8948a89 100644 --- a/gcc/ada/exp_unst.adb +++ b/gcc/ada/exp_unst.adb @@ -29,7 +29,6 @@ with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; with Elists; use Elists; -with Exp_Util; use Exp_Util; with Lib; use Lib; with Namet; use Namet; with Nlists; use Nlists; @@ -282,13 +281,6 @@ package body Exp_Unst is if E = Sub and then Present (Protected_Body_Subprogram (E)) then E := Protected_Body_Subprogram (E); end if; - - if Ekind (E) = E_Function - and then Rewritten_For_C (E) - and then Present (Corresponding_Procedure (E)) - then - E := Corresponding_Procedure (E); - end if; end if; pragma Assert (Subps_Index (E) /= Uint_0); @@ -786,16 +778,6 @@ package body Exp_Unst is if Caller = Callee then return; - -- Callee may be a function that returns an array, and that has - -- been rewritten as a procedure. If caller is that procedure, - -- nothing to do either. - - elsif Ekind (Callee) = E_Function - and then Rewritten_For_C (Callee) - and then Corresponding_Procedure (Callee) = Caller - then - return; - elsif Ekind (Callee) in E_Entry | E_Entry_Family then return; end if; @@ -2223,13 +2205,15 @@ package body Exp_Unst is -- Also ignore if no reference was specified or if the rewriting -- has already been done (this can happen if the N_Identifier -- occurs more than one time in the tree). Also ignore references - -- when not generating C code (in particular for the case of LLVM, - -- since GNAT-LLVM will handle the processing for up-level refs). + -- with GNAT-LLVM (CCG_Mode), since it will handle the processing + -- for up-level refs). + -- ??? At this stage, only GNAT LLVM uses front-end unnesting, so + -- consider remove the code below. if No (UPJ.Ref) or else not Is_Entity_Name (UPJ.Ref) or else No (Entity (UPJ.Ref)) - or else not Opt.Generate_C_Code + or else Opt.CCG_Mode then goto Continue; end if; @@ -2390,17 +2374,6 @@ package body Exp_Unst is -- expect any exceptions) Analyze_And_Resolve (UPJ.Ref, Typ, Suppress => All_Checks); - - -- Generate an extra temporary to facilitate the C backend - -- processing this dereference - - if Opt.Modify_Tree_For_C - and then Nkind (Parent (UPJ.Ref)) in - N_Type_Conversion | N_Unchecked_Type_Conversion - then - Force_Evaluation (UPJ.Ref, Mode => Strict); - end if; - Pop_Scope; end Rewrite_One_Ref; end; diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index fcb62a64e70..de096ea752a 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -4061,91 +4061,6 @@ package body Exp_Util is Restore_Ghost_Region (Saved_GM, Saved_IGR); end Build_Invariant_Procedure_Declaration; - -------------------------- - -- Build_Procedure_Form -- - -------------------------- - - procedure Build_Procedure_Form (N : Node_Id) is - Loc : constant Source_Ptr := Sloc (N); - Subp : constant Entity_Id := Defining_Entity (N); - - Func_Formal : Entity_Id; - Proc_Formals : List_Id; - Proc_Decl : Node_Id; - - begin - -- No action needed if this transformation was already done, or in case - -- of subprogram renaming declarations. - - if Nkind (Specification (N)) = N_Procedure_Specification - or else Nkind (N) = N_Subprogram_Renaming_Declaration - then - return; - end if; - - -- Ditto when dealing with an expression function, where both the - -- original expression and the generated declaration end up being - -- expanded here. - - if Rewritten_For_C (Subp) then - return; - end if; - - Proc_Formals := New_List; - - -- Create a list of formal parameters with the same types as the - -- function. - - Func_Formal := First_Formal (Subp); - while Present (Func_Formal) loop - Append_To (Proc_Formals, - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Chars (Func_Formal)), - Parameter_Type => - New_Occurrence_Of (Etype (Func_Formal), Loc))); - - Next_Formal (Func_Formal); - end loop; - - -- Add an extra out parameter to carry the function result - - Append_To (Proc_Formals, - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Name_UP_RESULT), - Out_Present => True, - Parameter_Type => New_Occurrence_Of (Etype (Subp), Loc))); - - -- The new procedure declaration is inserted before the function - -- declaration. The processing in Build_Procedure_Body_Form relies on - -- this order. Note that we insert before because in the case of a - -- function body with no separate spec, we do not want to insert the - -- new spec after the body which will later get rewritten. - - Proc_Decl := - Make_Subprogram_Declaration (Loc, - Specification => - Make_Procedure_Specification (Loc, - Defining_Unit_Name => - Make_Defining_Identifier (Loc, Chars (Subp)), - Parameter_Specifications => Proc_Formals)); - - Insert_Before_And_Analyze (Unit_Declaration_Node (Subp), Proc_Decl); - - -- Entity of procedure must remain invisible so that it does not - -- overload subsequent references to the original function. - - Set_Is_Immediately_Visible (Defining_Entity (Proc_Decl), False); - - -- Mark the function as having a procedure form and link the function - -- and its internally built procedure. - - Set_Rewritten_For_C (Subp); - Set_Corresponding_Procedure (Subp, Defining_Entity (Proc_Decl)); - Set_Corresponding_Function (Defining_Entity (Proc_Decl), Subp); - end Build_Procedure_Form; - ------------------------ -- Build_Runtime_Call -- ------------------------ @@ -12451,16 +12366,6 @@ package body Exp_Util is and then Side_Effect_Free (Exp, Name_Req, Variable_Ref) then return; - - -- Generating C code we cannot remove side effect of function returning - -- class-wide types since there is no secondary stack (required to use - -- 'reference). - - elsif Modify_Tree_For_C - and then Nkind (Exp) = N_Function_Call - and then Is_Class_Wide_Type (Etype (Exp)) - then - return; end if; -- The remaining processing is done with all checks suppressed @@ -12603,30 +12508,7 @@ package body Exp_Util is and then Etype (Expression (Exp)) /= Universal_Integer then Remove_Side_Effects (Expression (Exp), Name_Req, Variable_Ref); - - -- Generating C code the type conversion of an access to constrained - -- array type into an access to unconstrained array type involves - -- initializing a fat pointer and the expression must be free of - -- side effects to safely compute its bounds. - - if Modify_Tree_For_C - and then Is_Access_Type (Etype (Exp)) - and then Is_Array_Type (Designated_Type (Etype (Exp))) - and then not Is_Constrained (Designated_Type (Etype (Exp))) - then - Def_Id := Build_Temporary (Loc, 'R', Exp); - Set_Etype (Def_Id, Exp_Type); - Res := New_Occurrence_Of (Def_Id, Loc); - - Insert_Action (Exp, - Make_Object_Declaration (Loc, - Defining_Identifier => Def_Id, - Object_Definition => New_Occurrence_Of (Exp_Type, Loc), - Constant_Present => True, - Expression => Relocate_Node (Exp))); - else - goto Leave; - end if; + goto Leave; -- If this is an unchecked conversion that Gigi can't handle, make -- a copy or a use a renaming to capture the value. @@ -12712,30 +12594,6 @@ package body Exp_Util is -- Otherwise we generate a reference to the expression else - -- When generating C code we cannot consider side-effect-free object - -- declarations that have discriminants and are initialized by means - -- of a function call since on this target there is no secondary - -- stack to store the return value and the expander may generate an - -- extra call to the function to compute the discriminant value. In - -- addition, for targets that have secondary stack, the expansion of - -- functions with side effects involves the generation of an access - -- type to capture the return value stored in the secondary stack; - -- by contrast when generating C code such expansion generates an - -- internal object declaration (no access type involved) which must - -- be identified here to avoid entering into a never-ending loop - -- generating internal object declarations. - - if Modify_Tree_For_C - and then Nkind (Parent (Exp)) = N_Object_Declaration - and then - (Nkind (Exp) /= N_Function_Call - or else not Has_Discriminants (Exp_Type) - or else Is_Internal_Name - (Chars (Defining_Identifier (Parent (Exp))))) - then - goto Leave; - end if; - -- Special processing for function calls that return a limited type. -- We need to build a declaration that will enable build-in-place -- expansion of the call. This is not done if the context is already @@ -12774,10 +12632,8 @@ package body Exp_Util is -- the secondary stack. Since SPARK (and why) cannot process access -- types, use a different approach which ignores the secondary stack -- and "copies" the returned object. - -- When generating C code, no need for a 'reference since the - -- secondary stack is not supported. - if GNATprove_Mode or Modify_Tree_For_C then + if GNATprove_Mode then Res := New_Occurrence_Of (Def_Id, Loc); Ref_Type := Exp_Type; @@ -12812,10 +12668,10 @@ package body Exp_Util is else E := Relocate_Node (E); - -- Do not generate a 'reference in SPARK mode or C generation - -- since the access type is not created in the first place. + -- Do not generate a 'reference in SPARK mode since the access + -- type is not created in the first place. - if GNATprove_Mode or Modify_Tree_For_C then + if GNATprove_Mode then New_Exp := E; -- Otherwise generate reference, marking the value as non-null @@ -12875,39 +12731,12 @@ package body Exp_Util is Set_Analyzed (E, False); end if; - -- Generating C code of object declarations that have discriminants - -- and are initialized by means of a function call we propagate the - -- discriminants of the parent type to the internally built object. - -- This is needed to avoid generating an extra call to the called - -- function. - - -- For example, if we generate here the following declaration, it - -- will be expanded later adding an extra call to evaluate the value - -- of the discriminant (needed to compute the size of the object). - -- - -- type Rec (D : Integer) is ... - -- Obj : constant Rec := SomeFunc; - - if Modify_Tree_For_C - and then Nkind (Parent (Exp)) = N_Object_Declaration - and then Has_Discriminants (Exp_Type) - and then Nkind (Exp) = N_Function_Call - then - Insert_Action (Exp, - Make_Object_Declaration (Loc, - Defining_Identifier => Def_Id, - Object_Definition => New_Copy_Tree - (Object_Definition (Parent (Exp))), - Constant_Present => True, - Expression => New_Exp)); - else - Insert_Action (Exp, - Make_Object_Declaration (Loc, - Defining_Identifier => Def_Id, - Object_Definition => New_Occurrence_Of (Ref_Type, Loc), - Constant_Present => True, - Expression => New_Exp)); - end if; + Insert_Action (Exp, + Make_Object_Declaration (Loc, + Defining_Identifier => Def_Id, + Object_Definition => New_Occurrence_Of (Ref_Type, Loc), + Constant_Present => True, + Expression => New_Exp)); end if; -- Preserve the Assignment_OK flag in all copies, since at least one @@ -14306,19 +14135,6 @@ package body Exp_Util is and then Is_Class_Wide_Type (Typ) then return True; - - -- Generating C the type conversion of an access to constrained array - -- type into an access to unconstrained array type involves initializing - -- a fat pointer and the expression cannot be assumed to be free of side - -- effects since it must referenced several times to compute its bounds. - - elsif Modify_Tree_For_C - and then Nkind (N) = N_Type_Conversion - and then Is_Access_Type (Typ) - and then Is_Array_Type (Designated_Type (Typ)) - and then not Is_Constrained (Designated_Type (Typ)) - then - return False; end if; -- For other than entity names and compile time known values, diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 96d896a0b98..c772d411bcf 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -318,10 +318,6 @@ package Exp_Util is -- type Typ at runtime. Flag Partial_Invariant should be set when building -- the invariant procedure for a private type. - procedure Build_Procedure_Form (N : Node_Id); - -- Create a procedure declaration which emulates the behavior of a function - -- that returns an array type, for C-compatible generation. - function Build_Runtime_Call (Loc : Source_Ptr; RE : RE_Id) return Node_Id; -- Build an N_Procedure_Call_Statement calling the given runtime entity. -- The call has no parameters. The first argument provides the location diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 7cf7e847677..9c533722985 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -10314,18 +10314,6 @@ package body Freeze is then Check_Overriding_Indicator (E, Empty, Is_Primitive (E)); end if; - - Retype := Get_Fullest_View (Etype (E)); - - if Transform_Function_Array - and then Nkind (Parent (E)) = N_Function_Specification - and then Is_Array_Type (Retype) - and then Is_Constrained (Retype) - and then not Is_Unchecked_Conversion_Instance (E) - and then not Rewritten_For_C (E) - then - Build_Procedure_Form (Unit_Declaration_Node (E)); - end if; end Freeze_Subprogram; ---------------------- diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads index ef37bb20f53..a3e85ac6531 100644 --- a/gcc/ada/gen_il-fields.ads +++ b/gcc/ada/gen_il-fields.ads @@ -473,8 +473,6 @@ package Gen_IL.Fields is Corresponding_Concurrent_Type, Corresponding_Discriminant, Corresponding_Equality, - Corresponding_Function, - Corresponding_Procedure, Corresponding_Record_Component, Corresponding_Record_Type, Corresponding_Remote_Type, @@ -881,7 +879,6 @@ package Gen_IL.Fields is Returns_By_Ref, Reverse_Bit_Order, Reverse_Storage_Order, - Rewritten_For_C, RM_Size, Scalar_Range, Scale_Value, diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb index bdc81202645..80b5925ebb8 100644 --- a/gcc/ada/gen_il-gen-gen_entities.adb +++ b/gcc/ada/gen_il-gen-gen_entities.adb @@ -997,7 +997,6 @@ begin -- Gen_IL.Gen.Gen_Entities (Sm (Anonymous_Collections, Elist_Id), Sm (Corresponding_Equality, Node_Id, Pre => "not Comes_From_Source (N) and then Chars (N) = Name_Op_Ne"), - Sm (Corresponding_Procedure, Node_Id), Sm (DT_Position, Uint, Pre_Get => "Present (DTC_Entity (N))"), Sm (DTC_Entity, Node_Id), @@ -1025,7 +1024,6 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Protected_Subprogram, Node_Id), Sm (Protection_Object, Node_Id), Sm (Related_Expression, Node_Id), - Sm (Rewritten_For_C, Flag), Sm (Thunk_Entity, Node_Id, Pre => "Is_Thunk (N)"), Sm (Wrapped_Entity, Node_Id, @@ -1045,7 +1043,6 @@ begin -- Gen_IL.Gen.Gen_Entities -- body that acts as its own declaration. (Sm (Anonymous_Collections, Elist_Id), Sm (Associated_Node_For_Itype, Node_Id), - Sm (Corresponding_Function, Node_Id), Sm (DT_Position, Uint, Pre_Get => "Present (DTC_Entity (N))"), Sm (DTC_Entity, Node_Id), diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index 9743dfd4c4c..6b6fbf3a174 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -164,11 +164,10 @@ procedure Gnat1drv is Unnest_Subprogram_Mode := True; end if; - -- -gnatd.u enables special C expansion mode + -- Force pseudo code generation with -gnatceg - if Debug_Flag_Dot_U then - Modify_Tree_For_C := True; - Transform_Function_Array := True; + if Generate_C_Header then + Operating_Mode := Generate_Code; end if; -- -gnatd_A disables generation of ALI files @@ -177,29 +176,6 @@ procedure Gnat1drv is Disable_ALI_File := True; end if; - -- Set all flags required when generating C code - - if Generate_C_Code then - CCG_Mode := True; - Modify_Tree_For_C := True; - Transform_Function_Array := True; - Unnest_Subprogram_Mode := True; - Building_Static_Dispatch_Tables := False; - Minimize_Expression_With_Actions := True; - Expand_Nonbinary_Modular_Ops := True; - Back_End_Return_Slot := False; - - -- Set operating mode to Generate_Code to benefit from full front-end - -- expansion (e.g. generics). - - Operating_Mode := Generate_Code; - - -- Suppress alignment checks since we do not have access to alignment - -- info on the target. - - Suppress_Options.Suppress (Alignment_Check) := False; - end if; - -- -gnatd.E sets Error_To_Warning mode, causing selected error messages -- to be treated as warnings instead of errors. @@ -238,16 +214,9 @@ procedure Gnat1drv is Debug_Flag_Dot_PP := True; - -- Turn off C tree generation, not compatible with CodePeer mode. We - -- do not expect this to happen in normal use, since both modes are - -- enabled by special tools, but it is useful to turn off these flags - -- this way when we are doing CodePeer tests on existing test suites - -- that may have -gnateg set, to avoid the need for special casing. + -- Turn off front-end unnesting to be safe - Modify_Tree_For_C := False; - Transform_Function_Array := False; - Generate_C_Code := False; - Unnest_Subprogram_Mode := False; + Unnest_Subprogram_Mode := False; -- Turn off inlining, confuses CodePeer output and gains nothing @@ -457,16 +426,9 @@ procedure Gnat1drv is CodePeer_Mode := False; Generate_SCIL := False; - -- Turn off C tree generation, not compatible with GNATprove mode. We - -- do not expect this to happen in normal use, since both modes are - -- enabled by special tools, but it is useful to turn off these flags - -- this way when we are doing GNATprove tests on existing test suites - -- that may have -gnateg set, to avoid the need for special casing. + -- Turn off front-end unnesting to be safe - Modify_Tree_For_C := False; - Transform_Function_Array := False; - Generate_C_Code := False; - Unnest_Subprogram_Mode := False; + Unnest_Subprogram_Mode := False; -- Turn off inlining, which would confuse formal verification output -- and gain nothing. @@ -726,29 +688,14 @@ procedure Gnat1drv is end if; end if; - -- Treat -gnatn as equivalent to -gnatN for non-GCC targets - - if Inline_Active and not Front_End_Inlining then - - -- We really should have a tag for this, what if we added a new - -- back end some day, it would not be true for this test, but it - -- would be non-GCC, so this is a bit troublesome ??? - - Front_End_Inlining := Generate_C_Code; - end if; - -- Set back-end inlining indication Back_End_Inlining := - -- No back-end inlining available on C generation - - not Generate_C_Code - -- No back-end inlining in GNATprove mode, since it just confuses -- the formal verification process. - and then not GNATprove_Mode + not GNATprove_Mode -- No back-end inlining if front-end inlining explicitly enabled. -- Done to minimize the output differences to customers still using @@ -1234,8 +1181,7 @@ begin -- Ditto for old C files before regenerating new ones - if Generate_C_Code then - Delete_C_File; + if Generate_C_Header then Delete_H_File; end if; @@ -1340,20 +1286,10 @@ begin elsif CodePeer_Mode then Back_End_Mode := Generate_Object; - -- Differentiate use of -gnatceg to generate a C header from an Ada spec - -- to the CCG case (standard.h found) where C code generation should - -- only be performed on full units. - - elsif Generate_C_Code then - Name_Len := 10; - Name_Buffer (1 .. Name_Len) := "standard.h"; + -- Force pseudo code generation with -gnatceg - if Find_File (Name_Find, Osint.Source, Full_Name => True) = No_File - then - Back_End_Mode := Generate_Object; - else - Back_End_Mode := Skip; - end if; + elsif Generate_C_Header then + Back_End_Mode := Generate_Object; -- It is not an error to analyze in GNATprove mode a spec which requires -- a body, when the body is not available. During frame condition diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 785ad147755..519e26ecec8 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -3363,20 +3363,11 @@ package body Inline is Targ1 : Node_Id := Empty; -- A separate target used when the return type is unconstrained - procedure Declare_Postconditions_Result; - -- When generating C code, declare _Result, which may be used in the - -- inlined _Postconditions procedure to verify the return value. - procedure Make_Exit_Label; -- Build declaration for exit label to be used in Return statements, -- sets Exit_Lab (the label node) and Lab_Decl (corresponding implicit -- declaration). Does nothing if Exit_Lab already set. - procedure Make_Loop_Labels_Unique (HSS : Node_Id); - -- When compiling for CCG and performing front-end inlining, replace - -- loop names and references to them so that they do not conflict with - -- homographs in the current subprogram. - function Process_Formals (N : Node_Id) return Traverse_Result; -- Replace occurrence of a formal with the corresponding actual, or the -- thunk generated for it. Replace a return statement with an assignment @@ -3411,45 +3402,6 @@ package body Inline is -- If procedure body has no local variables, inline body without -- creating block, otherwise rewrite call with block. - ----------------------------------- - -- Declare_Postconditions_Result -- - ----------------------------------- - - procedure Declare_Postconditions_Result is - Enclosing_Subp : constant Entity_Id := Scope (Subp); - - begin - pragma Assert - (Modify_Tree_For_C - and then Is_Subprogram (Enclosing_Subp) - and then Present (Wrapped_Statements (Enclosing_Subp))); - - if Ekind (Enclosing_Subp) = E_Function then - if Nkind (First (Parameter_Associations (N))) in - N_Numeric_Or_String_Literal - then - Append_To (Declarations (Blk), - Make_Object_Declaration (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Name_uResult), - Constant_Present => True, - Object_Definition => - New_Occurrence_Of (Etype (Enclosing_Subp), Loc), - Expression => - New_Copy_Tree (First (Parameter_Associations (N))))); - else - Append_To (Declarations (Blk), - Make_Object_Renaming_Declaration (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Name_uResult), - Subtype_Mark => - New_Occurrence_Of (Etype (Enclosing_Subp), Loc), - Name => - New_Copy_Tree (First (Parameter_Associations (N))))); - end if; - end if; - end Declare_Postconditions_Result; - --------------------- -- Make_Exit_Label -- --------------------- @@ -3468,61 +3420,6 @@ package body Inline is end if; end Make_Exit_Label; - ----------------------------- - -- Make_Loop_Labels_Unique -- - ----------------------------- - - procedure Make_Loop_Labels_Unique (HSS : Node_Id) is - function Process_Loop (N : Node_Id) return Traverse_Result; - - ------------------ - -- Process_Loop -- - ------------------ - - function Process_Loop (N : Node_Id) return Traverse_Result is - Id : Entity_Id; - - begin - if Nkind (N) = N_Loop_Statement - and then Present (Identifier (N)) - then - -- Create new external name for loop and update the - -- corresponding entity. - - Id := Entity (Identifier (N)); - Set_Chars (Id, New_External_Name (Chars (Id), 'L', -1)); - Set_Chars (Identifier (N), Chars (Id)); - - elsif Nkind (N) = N_Exit_Statement - and then Present (Name (N)) - then - -- The exit statement must name an enclosing loop, whose name - -- has already been updated. - - Set_Chars (Name (N), Chars (Entity (Name (N)))); - end if; - - return OK; - end Process_Loop; - - procedure Update_Loop_Names is new Traverse_Proc (Process_Loop); - - -- Local variables - - Stmt : Node_Id; - - -- Start of processing for Make_Loop_Labels_Unique - - begin - if Modify_Tree_For_C then - Stmt := First (Statements (HSS)); - while Present (Stmt) loop - Update_Loop_Names (Stmt); - Next (Stmt); - end loop; - end if; - end Make_Loop_Labels_Unique; - --------------------- -- Process_Formals -- --------------------- @@ -3811,8 +3708,6 @@ package body Inline is Fst : constant Node_Id := First (Statements (HSS)); begin - Make_Loop_Labels_Unique (HSS); - -- Optimize simple case: function body is a single return statement, -- which has been expanded into an assignment. @@ -3899,8 +3794,6 @@ package body Inline is HSS : constant Node_Id := Handled_Statement_Sequence (Blk); begin - Make_Loop_Labels_Unique (HSS); - -- If there is a transient scope for N, this will be the scope of the -- actions for N, and the statements in Blk need to be within this -- scope. For example, they need to have visibility on the constant @@ -4005,16 +3898,6 @@ package body Inline is Set_Declarations (Blk, New_List); end if; - -- When generating C code, declare _Result, which may be used to - -- verify the return value. - - if Modify_Tree_For_C - and then Nkind (N) = N_Procedure_Call_Statement - and then Chars (Name (N)) = Name_uWrapped_Statements - then - Declare_Postconditions_Result; - end if; - -- For the unconstrained case, capture the name of the local -- variable that holds the result. This must be the first -- declaration in the block, because its bounds cannot depend diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 71d031a69dc..cc3723e1daa 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -699,10 +699,10 @@ package Opt is -- GNAT -- True if generating assembly instead of an object file, via the -S switch - Generate_C_Code : Boolean := False; - -- GNAT, GNATBIND + Generate_C_Header : Boolean := False; + -- GNAT -- If True, the Cprint circuitry to generate C code output is activated. - -- Set True by use of -gnateg or -gnatd.V for GNAT, and -G for GNATBIND. + -- Set True by use of -gnateg for GNAT. Generate_CodePeer_Messages : Boolean := False; -- GNAT @@ -1054,19 +1054,6 @@ package Opt is -- GNATMAKE -- Set to True if minimal recompilation mode requested - Minimize_Expression_With_Actions : Boolean := False; - -- GNAT - -- If True, minimize the use of N_Expression_With_Actions node. - -- This can be used in particular on some back-ends where this node is - -- difficult to support. - - Modify_Tree_For_C : Boolean := False; - -- GNAT - -- If this switch is set True (currently it is set only by -gnatd.V), then - -- certain meaning-preserving transformations are applied to the tree to - -- make it easier to interface with back ends that implement C semantics. - -- There is a section in Sinfo which describes the transformations made. - Multiple_Unit_Index : Nat := 0; -- GNAT -- This is set non-zero if the current unit is being compiled in multiple @@ -1538,12 +1525,6 @@ package Opt is -- Tolerate time stamp and other consistency errors. If this flag is set to -- True (-t), then inconsistencies result in warnings rather than errors. - Transform_Function_Array : Boolean := False; - -- GNAT - -- If this switch is set True, then functions returning constrained arrays - -- are transformed into a procedure with an out parameter, and all calls - -- are updated accordingly. - Treat_Categorization_Errors_As_Warnings : Boolean := False; -- Normally categorization errors are true illegalities. If this switch -- is set, then such errors result in warning messages rather than error diff --git a/gcc/ada/osint-c.adb b/gcc/ada/osint-c.adb index 08abbae9464..0fef274217a 100644 --- a/gcc/ada/osint-c.adb +++ b/gcc/ada/osint-c.adb @@ -44,23 +44,6 @@ package body Osint.C is -- output file and Suffix is the desired suffix (dg/rep/xxx for debug/ -- repinfo/list file where xxx is specified extension. - ------------------ - -- Close_C_File -- - ------------------ - - procedure Close_C_File is - Status : Boolean; - - begin - Close (Output_FD, Status); - - if not Status then - Fail - ("error while closing file " - & Get_Name_String (Output_File_Name)); - end if; - end Close_C_File; - ---------------------- -- Close_Debug_File -- ---------------------- @@ -190,18 +173,6 @@ package body Osint.C is return Result; end Create_Auxiliary_File; - ------------------- - -- Create_C_File -- - ------------------- - - procedure Create_C_File is - Dummy : Boolean; - begin - Set_File_Name ("c"); - Delete_File (Name_Buffer (1 .. Name_Len), Dummy); - Create_File_And_Check (Output_FD, Text); - end Create_C_File; - ----------------------- -- Create_Debug_File -- ----------------------- @@ -294,17 +265,6 @@ package body Osint.C is end if; end Debug_File_Eol_Length; - ------------------- - -- Delete_C_File -- - ------------------- - - procedure Delete_C_File is - Dummy : Boolean; - begin - Set_File_Name ("c"); - Delete_File (Name_Buffer (1 .. Name_Len), Dummy); - end Delete_C_File; - ------------------- -- Delete_H_File -- ------------------- diff --git a/gcc/ada/osint-c.ads b/gcc/ada/osint-c.ads index 6f8fbb851fd..bde37c72723 100644 --- a/gcc/ada/osint-c.ads +++ b/gcc/ada/osint-c.ads @@ -160,26 +160,22 @@ package Osint.C is -------------------------- -- These routines are used by the compiler when the C translation option - -- is activated to write *.c or *.h files to the current object directory. - -- Each routine exists in a C and an H form for the two kinds of files. - -- Only one of these files can be written at a time. Note that the files - -- are written via the Output package routines, using Output_FD. + -- is activated to write *.h files to the current object directory. + -- Note that the files are written via the Output package routines, using + -- Output_FD. - procedure Create_C_File; procedure Create_H_File; - -- Creates the *.c or *.h file for the source file which is currently - -- being compiled (i.e. the file which was most recently returned by + -- Creates the *.h file for the source file which is currently being + -- compiled (i.e. the file which was most recently returned by -- Next_Main_Source). - procedure Close_C_File; procedure Close_H_File; - -- Closes the file created by Create_C_File or Create_H file, flushing any - -- buffers etc. from writes by Write_C_File and Write_H_File; + -- Closes the file created by Create_H file, flushing any buffers, etc. + -- from writes by Write_C_File and Write_H_File; - procedure Delete_C_File; procedure Delete_H_File; - -- Deletes the .c or .h file corresponding to the source file which is - -- currently being compiled. + -- Deletes the .h file corresponding to the source file which is currently + -- being compiled. ---------------------- -- List File Output -- diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 0b0adac1126..d742e1075c0 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -1509,25 +1509,15 @@ package body Sem_Attr is -- appear on a subprogram renaming, when the renamed entity is an -- attribute reference. - -- Generating C code the internally built nested _postcondition - -- subprograms are inlined; after expanded, inlined aspects are - -- located in the internal block generated by the frontend. - - if Nkind (Subp_Decl) = N_Block_Statement - and then Modify_Tree_For_C - and then In_Inlined_Body - then - null; - - elsif Nkind (Subp_Decl) not in N_Abstract_Subprogram_Declaration - | N_Entry_Declaration - | N_Expression_Function - | N_Full_Type_Declaration - | N_Generic_Subprogram_Declaration - | N_Subprogram_Body - | N_Subprogram_Body_Stub - | N_Subprogram_Declaration - | N_Subprogram_Renaming_Declaration + if Nkind (Subp_Decl) not in N_Abstract_Subprogram_Declaration + | N_Entry_Declaration + | N_Expression_Function + | N_Full_Type_Declaration + | N_Generic_Subprogram_Declaration + | N_Subprogram_Body + | N_Subprogram_Body_Stub + | N_Subprogram_Declaration + | N_Subprogram_Renaming_Declaration then return; end if; @@ -1536,26 +1526,6 @@ package body Sem_Attr is Legal := True; Spec_Id := Unique_Defining_Entity (Subp_Decl); - - -- When generating C code, nested _postcondition subprograms are - -- inlined by the front end to avoid problems (when unnested) with - -- referenced itypes. Handle that here, since as part of inlining the - -- expander nests subprogram within a dummy procedure named _parent - -- (see Build_Postconditions_Procedure and Build_Body_To_Inline). - -- Hence, in this context, the spec_id of _postconditions is the - -- enclosing scope. - - if Modify_Tree_For_C - and then Chars (Spec_Id) = Name_uParent - and then Chars (Scope (Spec_Id)) = Name_uWrapped_Statements - then - -- This situation occurs only when analyzing the body-to-inline - - pragma Assert (Inside_A_Generic); - - Spec_Id := Scope (Spec_Id); - pragma Assert (Is_Inlined (Spec_Id)); - end if; end Analyze_Attribute_Old_Result; ----------------------------- @@ -5530,16 +5500,7 @@ package body Sem_Attr is -- the case, then the aspect or pragma is illegal. Return as analysis -- cannot be carried out. - -- The exception to this rule is when generating C since in this case - -- postconditions are inlined. - - if No (Spec_Id) - and then Modify_Tree_For_C - and then In_Inlined_Body - then - Spec_Id := Entity (P); - - elsif not Legal then + if not Legal then return; end if; @@ -5987,10 +5948,6 @@ package body Sem_Attr is -- Local variables - In_Inlined_C_Postcondition : constant Boolean := - Modify_Tree_For_C - and then In_Inlined_Body; - Legal : Boolean; Pref_Id : Entity_Id; Spec_Id : Entity_Id; @@ -6021,13 +5978,7 @@ package body Sem_Attr is -- the case, then the aspect or pragma is illegal. Return as analysis -- cannot be carried out. - -- The exception to this rule is when generating C since in this case - -- postconditions are inlined. - - if No (Spec_Id) and then In_Inlined_C_Postcondition then - Spec_Id := Entity (P); - - elsif not Legal then + if not Legal then Error_Attr ("prefix of % attribute must be a function", P); end if; @@ -6037,11 +5988,7 @@ package body Sem_Attr is -- Instead, rewrite the attribute as a reference to formal parameter -- _Result of the _Wrapped_Statements procedure. - if Chars (Spec_Id) = Name_uWrapped_Statements - or else - (In_Inlined_C_Postcondition - and then Nkind (Parent (Spec_Id)) = N_Block_Statement) - then + if Chars (Spec_Id) = Name_uWrapped_Statements then Rewrite (N, Make_Identifier (Loc, Name_uResult)); -- The type of formal parameter _Result is that of the function diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 127b521e0a5..8714efe1461 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -8965,9 +8965,7 @@ package body Sem_Ch12 is -- are inlined by the front end, and the front-end inlining machinery -- relies on this routine to perform inlining. - elsif From_Aspect_Specification (N) - and then not Modify_Tree_For_C - then + elsif From_Aspect_Specification (N) then New_N := Make_Null_Statement (Sloc (N)); else diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index c0943f97341..8787a904e9f 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -4551,11 +4551,7 @@ package body Sem_Ch3 is -- If the aggregate is limited it will be built in place, and its -- expansion is deferred until the object declaration is expanded. - -- This is also required when generating C code to ensure that an - -- object with an alignment or address clause can be initialized - -- by means of component by component assignments. - - if Is_Limited_Type (T) or else Modify_Tree_For_C then + if Is_Limited_Type (T) then Set_Expansion_Delayed (E); end if; diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 4e1d1bc7ed7..2281ef9ce71 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -4709,13 +4709,6 @@ package body Sem_Ch4 is begin if Warn_On_Suspicious_Contract and then not Is_Internal_Name (Chars (Loop_Id)) - - -- Generating C, this check causes spurious warnings on inlined - -- postconditions; we can safely disable it because this check - -- was previously performed when analyzing the internally built - -- postconditions procedure. - - and then not (Modify_Tree_For_C and In_Inlined_Body) then if not Referenced (Loop_Id, Cond) then Error_Msg_N ("?.t?unused variable &", Loop_Id); diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 43aa2e636fa..9b85d65862b 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -2686,22 +2686,6 @@ package body Sem_Ch6 is Analyze (Subp_Decl); - -- Propagate the attributes Rewritten_For_C and Corresponding_Proc to - -- the body since the expander may generate calls using that entity. - -- Required to ensure that Expand_Call rewrites calls to this - -- function by calls to the built procedure. - - if Transform_Function_Array - and then Nkind (Body_Spec) = N_Function_Specification - and then - Rewritten_For_C (Defining_Entity (Specification (Subp_Decl))) - then - Set_Rewritten_For_C (Defining_Entity (Body_Spec)); - Set_Corresponding_Procedure (Defining_Entity (Body_Spec), - Corresponding_Procedure - (Defining_Entity (Specification (Subp_Decl)))); - end if; - -- Analyze any relocated source pragmas or pragmas created for aspect -- specifications. @@ -3740,18 +3724,6 @@ package body Sem_Ch6 is and then not Inside_A_Generic then Build_Subprogram_Declaration; - - -- If this is a function that returns a constrained array, and - -- Transform_Function_Array is set, create subprogram - -- declaration to simplify e.g. subsequent C generation. - - elsif No (Spec_Id) - and then Transform_Function_Array - and then Nkind (Body_Spec) = N_Function_Specification - and then Is_Array_Type (Etype (Body_Id)) - and then Is_Constrained (Etype (Body_Id)) - then - Build_Subprogram_Declaration; end if; end if; @@ -3830,60 +3802,6 @@ package body Sem_Ch6 is Spec_Id := Build_Internal_Protected_Declaration (N); end if; - -- If Transform_Function_Array is set and this is a function returning a - -- constrained array type for which we must create a procedure with an - -- extra out parameter, build and analyze the body now. The procedure - -- declaration has already been created. We reuse the source body of the - -- function, because in an instance it may contain global references - -- that cannot be reanalyzed. The source function itself is not used any - -- further, so we mark it as having a completion. If the subprogram is a - -- stub the transformation is done later, when the proper body is - -- analyzed. - - if Expander_Active - and then Transform_Function_Array - and then Nkind (N) /= N_Subprogram_Body_Stub - then - declare - S : constant Entity_Id := - (if Present (Spec_Id) - then Spec_Id - else Defining_Unit_Name (Specification (N))); - Proc_Body : Node_Id; - - begin - if Ekind (S) = E_Function and then Rewritten_For_C (S) then - Set_Has_Completion (S); - Proc_Body := Build_Procedure_Body_Form (S, N); - - if Present (Spec_Id) then - Rewrite (N, Proc_Body); - Analyze (N); - - -- The entity for the created procedure must remain - -- invisible, so it does not participate in resolution of - -- subsequent references to the function. - - Set_Is_Immediately_Visible (Corresponding_Spec (N), False); - - -- If we do not have a separate spec for N, build one and - -- insert the new body right after. - - else - Rewrite (N, - Make_Subprogram_Declaration (Loc, - Specification => Relocate_Node (Specification (N)))); - Analyze (N); - Insert_After_And_Analyze (N, Proc_Body); - Set_Is_Immediately_Visible - (Corresponding_Spec (Proc_Body), False); - end if; - - goto Leave; - end if; - end; - end if; - -- If a separate spec is present, then deal with freezing issues if Present (Spec_Id) then diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index cebef2ca44f..a030d6b06f1 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -10881,20 +10881,7 @@ package body Sem_Elab is Spec_Id : Entity_Id; begin - Spec_Id := Subp_Id; - - -- The elaboration target denotes an internal function that returns a - -- constrained array type in a SPARK-to-C compilation. In this case - -- the function receives a corresponding procedure which has an out - -- parameter. The proper body for ABE checks and diagnostics is that - -- of the procedure. - - if Ekind (Spec_Id) = E_Function - and then Rewritten_For_C (Spec_Id) - then - Spec_Id := Corresponding_Procedure (Spec_Id); - end if; - + Spec_Id := Subp_Id; Rec.Kind := Subprogram_Target; Spec_And_Body_From_Entity diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 72bba1f97af..19e52260661 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -11479,10 +11479,10 @@ package body Sem_Res is -- Ensure all actions associated with the left operand (e.g. -- finalization of transient objects) are fully evaluated locally within -- an expression with actions. This is particularly helpful for coverage - -- analysis. However this should not happen in generics or if option - -- Minimize_Expression_With_Actions is set. + -- analysis at the object level. However this should not happen in + -- generics. - if Expander_Active and not Minimize_Expression_With_Actions then + if Expander_Active then declare Reloc_L : constant Node_Id := Relocate_Node (L); begin @@ -12514,23 +12514,6 @@ package body Sem_Res is then Set_Do_Range_Check (Operand); end if; - - -- Generating C code a type conversion of an access to constrained - -- array type to access to unconstrained array type involves building - -- a fat pointer which in general cannot be generated on the fly. We - -- remove side effects in order to store the result of the conversion - -- into a temporary. - - if Modify_Tree_For_C - and then Nkind (N) = N_Type_Conversion - and then Nkind (Parent (N)) /= N_Object_Declaration - and then Is_Access_Type (Etype (N)) - and then Is_Array_Type (Designated_Type (Etype (N))) - and then not Is_Constrained (Designated_Type (Etype (N))) - and then Is_Constrained (Designated_Type (Etype (Expression (N)))) - then - Remove_Side_Effects (N); - end if; end Resolve_Type_Conversion; ---------------------- diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 3696ca4f7b4..768bcc0de82 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -727,46 +727,6 @@ package Sinfo is -- refers to a node or is posted on its source location, and has the -- effect of inhibiting further messages involving this same node. - ----------------------- - -- Modify_Tree_For_C -- - ----------------------- - - -- If the flag Opt.Modify_Tree_For_C is set True, then the tree is modified - -- in ways that help match the semantics better with C, easing the task of - -- interfacing to C code generators (other than GCC, where the work is done - -- in gigi, and there is no point in changing that), and also making life - -- easier for Cprint in generating C source code. - - -- The current modifications implemented are as follows: - - -- N_Op_Rotate_Left, N_Op_Rotate_Right, N_Shift_Right_Arithmetic nodes - -- are eliminated from the tree (since these operations do not exist in - -- C), and the operations are rewritten in terms of logical shifts and - -- other logical operations that do exist in C. See Exp_Ch4 expansion - -- routines for these operators for details of the transformations made. - - -- The right operand of N_Op_Shift_Right and N_Op_Shift_Left is always - -- less than the word size (since other values are not well-defined in - -- C). This is done using an explicit test if necessary. - - -- Min and Max attributes are expanded into equivalent if expressions, - -- dealing properly with side effect issues. - - -- Mod for signed integer types is expanded into equivalent expressions - -- using Rem (which is % in C) and other C-available operators. - - -- Functions returning bounded arrays are transformed into procedures - -- with an extra out parameter, and the calls updated accordingly. - - -- Aggregates are only kept unexpanded for object declarations, otherwise - -- they are systematically expanded into loops (for arrays) and - -- individual assignments (for records). - - -- Unconstrained array types are handled by means of fat pointers. - - -- Postconditions are inlined by the frontend since their body may have - -- references to itypes defined in the enclosing subprogram. - ------------------------------------ -- Description of Semantic Fields -- ------------------------------------ @@ -4020,9 +3980,6 @@ package Sinfo is -- Must_Be_Byte_Aligned -- plus fields for expression - -- Note: in Modify_Tree_For_C mode, Max and Min attributes are expanded - -- into equivalent if expressions, properly taking care of side effects. - --------------------------------- -- 4.1.4 Attribute Designator -- --------------------------------- @@ -4630,11 +4587,6 @@ package Sinfo is -- and we are running in ELIMINATED mode, the operator node will be -- changed to be a call to the appropriate routine in System.Bignums. - -- Note: In Modify_Tree_For_C mode, we do not generate an N_Op_Mod node - -- for signed integer types (since there is no equivalent operator in - -- C). Instead we rewrite such an operation in terms of REM (which is - -- % in C) and other C-available operators. - ------------------------------------ -- 4.5.7 Conditional Expressions -- ------------------------------------ @@ -7798,12 +7750,6 @@ package Sinfo is -- plus fields for expression -- Shift_Count_OK - -- Note: N_Op_Rotate_Left, N_Op_Rotate_Right, N_Shift_Right_Arithmetic - -- never appear in the expanded tree if Modify_Tree_For_C mode is set. - - -- Note: For N_Op_Shift_Left and N_Op_Shift_Right, the right operand is - -- always less than the word size if Modify_Tree_For_C mode is set. - -------------------------- -- Obsolescent Features -- -------------------------- @@ -8113,9 +8059,6 @@ package Sinfo is -- the expression of the node is fully analyzed and expanded, at which -- point it is safe to remove it, since no more actions can be inserted. - -- Note: In Modify_Tree_For_C, we never generate any declarations in - -- the action list, which can contain only non-declarative statements. - -------------------- -- Free Statement -- -------------------- diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl index 5be3044158e..eb4eca0cf7d 100644 --- a/gcc/ada/snames.ads-tmpl +++ b/gcc/ada/snames.ads-tmpl @@ -1376,9 +1376,8 @@ package Snames is -- Other miscellaneous names used in front end -- Note that the UP_ prefix means use the rest of the name in uppercase, - -- e.g. Name_UP_RESULT corresponds to the name "RESULT". + -- e.g. Name_UP_RESULT maps to "RESULT". - Name_UP_RESULT : constant Name_Id := N + $; Name_Synchronous_Task_Control : constant Name_Id := N + $; -- Names used to implement iterators over predefined containers diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb index 2de516dba56..7cc0b8f0e3d 100644 --- a/gcc/ada/switch-b.adb +++ b/gcc/ada/switch-b.adb @@ -362,12 +362,6 @@ package body Switch.B is Debugger_Level := 2; end if; - -- Processing for G switch - - when 'G' => - Ptr := Ptr + 1; - Generate_C_Code := True; - -- Processing for h switch when 'h' => diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb index 25cb6f20da6..9b5dde7c8d8 100644 --- a/gcc/ada/switch-c.adb +++ b/gcc/ada/switch-c.adb @@ -616,7 +616,7 @@ package body Switch.C is Ptr := Ptr + 1; Check_Float_Overflow := not Machine_Overflows_On_Target; - -- -gnateg (generate C code) + -- -gnateg (generate C header) when 'g' => -- Special check, -gnateg must occur after -gnatc @@ -626,7 +626,7 @@ package body Switch.C is ("gnateg requires previous occurrence of -gnatc"); end if; - Generate_C_Code := True; + Generate_C_Header := True; Ptr := Ptr + 1; -- -gnateG (save preprocessor output) From patchwork Thu Aug 1 15:17:13 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: 1967859 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=i1syasve; 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 4WZY6y4ZCWz1ybX for ; Fri, 2 Aug 2024 01:39:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C04503864807 for ; Thu, 1 Aug 2024 15:39:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 0301D385DDC4 for ; Thu, 1 Aug 2024 15:17:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0301D385DDC4 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 0301D385DDC4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525488; cv=none; b=STHbJpmx4pL2SNurRfM2naPEoKJLSEczwQfhNL732jvAcxGUEILiooltN9xyaIT5jRLk2XrV3I7S7AS+wseZsv7sZh4Gs/rp7VW0BQAjiVuu4jTlg8t/XyoYiTqMZn504apqTMD5EwXD3DOjW91hfvefHf93RIb7tdlUdVcFQCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525488; c=relaxed/simple; bh=ocB3nK/9b4fA08JIHF45zbqbW5d7APNOw1pRqAVtGdU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UAnNur9gIv66OExdxq7JAUj8z0vVYCFfQXHwhOIKB6fJGsX3KmuMF7R7Z4bILuCykcf3eYoEUC0N5glOeSqiNc97T6tMdYKBupbPz67KSZaFeqm7PWYUL5HBoGH+2EhuphqF2kZhTZERYVn4fdlOdXHeHLTY7VfmXeACZr6Roxc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4281c164408so39763935e9.1 for ; Thu, 01 Aug 2024 08:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525474; x=1723130274; 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=CWtwBJ2QqbIV9xRFfQ09C26DhXeBdHUixHh1txVB0+A=; b=i1syasveaGGxg7h/8ZYs/uKaIefdoEJ2mL+FKwKfLLIFQBrA/QJb/AjdLky/ZQAMTv rJVr7uldXgK2c0bEnVuS33rHwgTVTrbWGwhclwOQDIIhy3hbNyYBion6g8gnhVEirYPQ t0eq/MGnHiE7psH6MW3IEYQ/hTF+WjoaTSbb//Kg7T7L9207l7zkX+C0Q+9GCK4eGDF0 DIo2nxvPimCe/oMdyWLvKzSm37Gdvw6L9aB69R2jcfs6ZzI3pDO5CPmIQ/3vFM5i05m2 M9YFMnLTSKDize8BPRKpWjSZboW/hTyj7lFwhsZ4W8rzTkdAW847i1lDdu445Eh6iK15 0gpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525474; x=1723130274; 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=CWtwBJ2QqbIV9xRFfQ09C26DhXeBdHUixHh1txVB0+A=; b=KSj2bhHq67nMClA9sk7hUMuLBJ7mrnPjseuPElSIjkZW8tnMIst4deMdRyTAnM19A0 YAOUMwzaVpg2iyfZGp3E2lfwAnoX053FuVrsBWxxoaTlYEDzLAgz0pdYlV8RISyiarCz DNxJv7tSxdk487OZEDiZ9WPFQQs8WljS4z09xUwxzc2pvvp3Ou2hz1BdVm/485EhvU1a sXkNejr4MRtY0K44B4bdOnupANARyARbYTPE+rtXupBd68VmEhyuzfh1svBKnLO+cUNi J1li86GFp8NdMf3UOolbf9ZZevQtTr67ZYS0bx08PbO1SH3Zko1N5AAPPdtXo9Kjm+V6 MB6A== X-Gm-Message-State: AOJu0YzIBdoWsi4K7xKe3X/MYPT/0Q4igFYotCZ2uNGQxI7Z8zl5oT/X M9U1y5NdJiXEKIe1UP0lJl+XvetL0fnwXrJKwFnL3wOehV8+YXOtdqWJRJGydeg0vzz/V1IOluN +DQ== X-Google-Smtp-Source: AGHT+IFyFwBzzM4bt0tm0d4PrvFtWbI/U/BQMTpOGZOEck7tKH6sSmm+hlykxFBSVIQ5+E6vJBPTjQ== X-Received: by 2002:a05:6000:acf:b0:368:3f6a:1dec with SMTP id ffacd0b85a97d-36bbc0c6b26mr122264f8f.9.1722525474435; Thu, 01 Aug 2024 08:17:54 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:54 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED 05/30] ada: Fix test for wrapping loop parameter spec Date: Thu, 1 Aug 2024 17:17:13 +0200 Message-ID: <20240801151738.400796-5-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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: Ronan Desplanques This patches fixes a problem where cleanup statements would be missing for some cases of loop parameter specifications that allocate on the secondary stack. gcc/ada/ * sem_ch5.adb (Prepare_Param_Spec_Loop): Fix criterion for wrapping loop statements into blocks. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch5.adb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 5739fe06ea2..ac8cd0821ff 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -3806,20 +3806,16 @@ package body Sem_Ch5 is Rng_Typ := Etype (Rng_Copy); -- Wrap the loop statement within a block in order to manage - -- the secondary stack when the discrete range is + -- the secondary stack when the discrete range: -- - -- * Either a Forward_Iterator or a Reverse_Iterator + -- * is either a Forward_Iterator or a Reverse_Iterator + -- or -- - -- * Function call whose return type requires finalization - -- actions. - - -- ??? it is unclear why using Has_Sec_Stack_Call directly on - -- the discrete range causes the freeze node of an itype to be - -- in the wrong scope in complex assertion expressions. + -- * contains a function call that returns on the secondary + -- stack. if Is_Iterator (Rng_Typ) - or else (Nkind (Rng_Copy) = N_Function_Call - and then Needs_Finalization (Rng_Typ)) + or else Has_Sec_Stack_Call (Rng_Copy) then Wrap_Loop_Statement (Manage_Sec_Stack => True); Stop_Processing := True; From patchwork Thu Aug 1 15:17: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: 1967834 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=HRy01Jkn; 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 4WZY1r2cMwz1ybX for ; Fri, 2 Aug 2024 01:35:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B63D384F4B8 for ; Thu, 1 Aug 2024 15:35:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id D14DE3864C15 for ; Thu, 1 Aug 2024 15:17:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D14DE3864C15 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 D14DE3864C15 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525479; cv=none; b=w0rD41fFmcHHy8INasA96u2Mu1vtKBVbnEZWfg1lEeg7sdIuslUQd9amv6pfVZmSluB4ts92EZYDw2YeM73lTGNW52qyuJizTZSJaWLW9GIle6aNVLL0Y0+91qcqCkZfodMw3vUp++EydxX2nBU0FtIIDTQm802UjZOIVxv+iTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525479; c=relaxed/simple; bh=0mTxp44rzfMcmyfwHjbgSV8KgCODUgOaOUnvISxNnTE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JWegTVZiTyQlq3+M1TOEpP8pfZAk9BqkgktNMNb3PGgx1pyKXvSmR6dP/dnF0D3c7afIo0IPZZJr2D2pXewMN2J/MmWAzJAkVmUQAiMDxZ2SdvXGXvnFgO4y/LV2pbv9N2npUBXET8Nkb/vsKnB048s52kcsvAd8xxo0bJoXA9Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3683f56b9bdso3582027f8f.1 for ; Thu, 01 Aug 2024 08:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525475; x=1723130275; 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=OtLUOUfxfc+bKclqTVqB4DyZ2Bs/O1i9LNEK0sb4JZY=; b=HRy01JknHz5Zs+emTSA5XMpFYQpp0Ed3U7YecDkRlQ4dAFwjzRQ3rCzDp3mjbM5ZIT tGWUnWtfmBU7nPn12mQhRAEgWnYpcS/YhXDKDa+8efYW7WvyNzQmRvhPQljqUydOQ2Gm SX1VrjoBT5OqDeOTho8VtdMHidy8YLYveurc/f0oJlz6LQP6Y39g6dpeeFIGyRmUWn3z QU9zh2ID2+PL7ySIYyiICXoM6+cH5a/n4N8CoKD6j6jVKL2IPJx7KkfeOWIT4f5ngNwN QFNdH3NDAZH+TwieWauT26Xt5Yuy75Lo8hxci8otHTl4M0iOyoo5deCPWFRK6pFDXB7h P/1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525475; x=1723130275; 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=OtLUOUfxfc+bKclqTVqB4DyZ2Bs/O1i9LNEK0sb4JZY=; b=KMEsLHQ1J+L4aMQUmuAyFcmN4Gdqy+4iw6bQHz6lfLDZmMw7g2ue8c1djwlAUUPHC/ ADIWD4bkv0dCEYnpr47J1vNNUahhOwpQnETjGszsyTC9zME2nqiGb13Xt02xguR/QLIX XtUASjlYKR7mW2ZUnsThUcq2+Yo6nW6kXQD5gnI5xPghOud1i8YUTk63xHNaDYMByF6K VtIZz55d9HiIeTkchfv1ncjrQR4U3kX76aEF9T9IMKfkkZU3cLd4b6XCAwY4ekFfdvcd wGXbqsEfGxPdSV7D82ud1uNDUrjGlpdVv+3YTkZFW9yCwKez/tVldxkxsHw4n2us7+ER HtfA== X-Gm-Message-State: AOJu0YzZqvnisOX4nQtJLn8RVVzZwOHBaqiWOxAY406pnIomKPn+ZWvs A+OZRzqQboYLwBqS8WfzYrsmdhIgapS7RSmhNROXHOkd3p5nu3ffiG7MpS2hw24aBfE8LrFteVd LBA== X-Google-Smtp-Source: AGHT+IEBiz/RgmTs8xFwCypw3vLOm8VPpC1K46fGQS6eCHGoikqiuACTIcQ5SB/7coS9im18ArbNTA== X-Received: by 2002:a05:6000:1e97:b0:367:992f:4ac4 with SMTP id ffacd0b85a97d-36bbc00526fmr150587f8f.0.1722525475296; Thu, 01 Aug 2024 08:17:55 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:54 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ghjuvan Lacambre Subject: [COMMITTED 06/30] ada: Stop ignoring Component_Size attribute in CodePeer_Mode Date: Thu, 1 Aug 2024 17:17:14 +0200 Message-ID: <20240801151738.400796-6-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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: Ghjuvan Lacambre This piece of code was introduced in 2011 in order to prevent spurious false positives from appearing on specific code patterns making use of Component_Size. It seems that now this piece of code is causing small false positives instead of preventing them, so let's remove it. gcc/ada/ * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Stop ignoring Component_Size attribute in CodePeer_Mode. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 957c43d689b..a7936641d34 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -6079,24 +6079,6 @@ package body Sem_Ch13 is Check_Restriction_No_Specification_Of_Aspect (N); end if; - -- Ignore some selected attributes in CodePeer mode since they are not - -- relevant in this context. - - if CodePeer_Mode then - case Id is - - -- Ignore Component_Size in CodePeer mode, to avoid changing the - -- internal representation of types by implicitly packing them. - - when Attribute_Component_Size => - Rewrite (N, Make_Null_Statement (Sloc (N))); - return; - - when others => - null; - end case; - end if; - -- Process Ignore_Rep_Clauses option if Ignore_Rep_Clauses then From patchwork Thu Aug 1 15:17:15 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: 1967832 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=aCvMp1TD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZY1X4Lssz1yZv for ; Fri, 2 Aug 2024 01:34:56 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA52D385DDE7 for ; Thu, 1 Aug 2024 15:34:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 939493861029 for ; Thu, 1 Aug 2024 15:17:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 939493861029 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 939493861029 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525491; cv=none; b=XxYuZ1n6HO//wWaDWetHKc3cZeLpbz9urakHYzHOwr9nCRUQnbShkhL80aCBQtrPR59s0PDfIv1J/LDFHw6468AlIxQZ8j4V33z+xM89CP8AGwfZ8JUiUZrDTlKvqhpObQUwYTWmYSzvQug5rR2RGvlmzAnAkgPtvrm9HyeR4xc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525491; c=relaxed/simple; bh=tAn5ChrVUgi73eRzNLLv8C0cfXHuKGGprngJjZRn4ro=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sgDqtylbBGKD3AE1BUDzT2ISG/GLgx/QFJp8EFP1LE+9gOpW8oonX3Mynxc3x99SrJfxO/IpHGAqf2ImugCeV7rtoeTcd9s/M7JoBuJ91NmU98rnUw3UbQ4JZxisxON9YZRvM0U8eanGtd1cANB28u1zTjVL48WiwOpoe+RbiQc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-368663d7f80so3573142f8f.3 for ; Thu, 01 Aug 2024 08:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525476; x=1723130276; 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=sVdTeD1mLj1O2f+ALPo2XZSwQ7e4Wi9EG3wtQEEsAEU=; b=aCvMp1TDSzB4RN7nAJeL/6Lw6SpiCVecWBMYxv6/Wh58B4zDybjdpSJoRc61n/TTbF JngMD8k46RDzRZmZumWav8vfceGU2OhDnCD0ygsT0AI8zPzz7qXf16ORBCCWSHHYW7fP 1yfgIoDcXPUA7viwMcRNE+kpC51rbT85Pb6LS2UxFpRed27Gc6O6y5WVxTJGi49LsLJr 03Lk0hsDtfEV8Y+Sp/0jnIXSo1dgAV7GHGAwunF2cAmDFHa+HPYbHEmiHdnWSfH8a5Tp 6W7Qb9WFEvu7XEeosYRusoUszdKeASsIt+mXThmNK1n6Ljj+oZXlvTVWk9hBYzEKmN7N z+tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525476; x=1723130276; 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=sVdTeD1mLj1O2f+ALPo2XZSwQ7e4Wi9EG3wtQEEsAEU=; b=vYAUP2P3eiyHKefjVK5jM67jSjeI8d9etZWETOj7lDqdIf+lShfij03xN0GeruIwXa xFK7xfQSSczwy3GyMieKwHgbPyNYUXzUWcEMWtEA4X056v1uae7Gk8Xol6/HTOBF+DAa jUj+N0d1vvB7SECdbmMDM+5yTDo0767AmwiVVVHXfdgpsvCYl2Y56kyn/EU/jDPRl0wv eZFBlu2BCCyGy8DVCJW0y4ZXhXTorOihuHiRDbTRG23D0lH5LJd6PUJ6HZY423WXFTeu KKdu1lECAzhAtqZxscSmmRJSjo8lQKoY/7aqnLznC9MrDr5KblEKdRiRiWXQE4GXOYnN qAww== X-Gm-Message-State: AOJu0Yw+5uyuGFGEPI8rne4tsOswUVTDFEjKO9+fWUM8PlDVpYRp6xpv 9evlu2VM5ScRuXyHh/Q7baBlAFWdGucg7NzEuDYykK1rIUtOWe9lNMZf6OjGYN8JVZCo8CqLwpi YMw== X-Google-Smtp-Source: AGHT+IGL8iDNx9aIxBKSwk28P5yE7j3kttoQC4R0cA0ga3Q7z2p9Umc7nbjGluOqCqjb28no5C7xng== X-Received: by 2002:a05:6000:4595:b0:362:b906:99c4 with SMTP id ffacd0b85a97d-36bbc1706f5mr104078f8f.58.1722525476133; Thu, 01 Aug 2024 08:17:56 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:55 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 07/30] ada: Operator visibility bug in static expression functions Date: Thu, 1 Aug 2024 17:17:15 +0200 Message-ID: <20240801151738.400796-7-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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: Steve Baird In some cases, an expanded name refering to a predefined operator (such as Some_Package."+") occurring in a static expression function would be incorrectly rejected with a message saying that the operator is not directly visible (which, while True, does not make the reference illegal). gcc/ada/ * sem_ch4.adb (Is_Effectively_Visible_Opertor): Return True if Checking_Potentially_Static_Expression is True. The accompanying comment says True is returned "if there is a reason it is ok for Is_Visible_Operator to return False"; if Checking_Potentially_Static_Expression is true, that is such a reason. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 2281ef9ce71..fc3a2a43c3c 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -278,6 +278,7 @@ package body Sem_Ch4 is (N /= Original_Node (N) and then Is_Effectively_Visible_Operator (N => Original_Node (N), Typ => Typ)) + or else Checking_Potentially_Static_Expression or else not Comes_From_Source (N)); -- Return True iff either Is_Visible_Operator returns True or if -- there is a reason it is ok for Is_Visible_Operator to return False. From patchwork Thu Aug 1 15:17:16 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: 1967840 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=MSSN1NuM; 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 4WZY2p1xtyz1ybX for ; Fri, 2 Aug 2024 01:36:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8471B3860C07 for ; Thu, 1 Aug 2024 15:36:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 78D07385C6C8 for ; Thu, 1 Aug 2024 15:17:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78D07385C6C8 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 78D07385C6C8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525494; cv=none; b=hObBCocNx12k/vVZpOSeEXvB8wfrlIoLK6ztvRoJ/INQoz44ICkyM7kNFl8d4xDtyNfZ2SDRtGMZ1/lfRQDI3SJuM1VoR5brLzc/mLR+cEu7mpA0XehOfhmG60oSpj0kA22qcguzdhbMXD4XQfMPlLON/lzxDqgY/5C3bqV0V3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525494; c=relaxed/simple; bh=TfD3gBwistjdaDrEEKJfxdv7K1w/5En9EM1JGn5zGtY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tvgbTtL96TYiQkk4JZFb5KwkcqDc1f1jtX2BQGcvWRsk88HfC8rKLislI4WED+RJMPdZCm6qYlZU0St0KwE3HzJyywQ0orm1AYnURb+7NELnDAAVH2fEP6qy0foK2NkGYXiS4jxblUUAVYIrSPbibEj28E9XxASyHC/SAXbrC8Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-369cb9f086aso3890292f8f.0 for ; Thu, 01 Aug 2024 08:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525477; x=1723130277; 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=c1Pb9QS/v2f3vAGxs3TsdsN7p4/3DlmEbF7eHgwyUYY=; b=MSSN1NuMe2WUduGbpCI69ccvxvkNr5TPVPvTX4R55pdNwBTetwTrXnXj6VG4BnT4jT nQiUPoDKLUqhUWWIzJIXtYKsSuFLgTXq4vn7CvuXLOKJErgPdr0kjkh4B9GBoH9QSBef MQW1RQZ7WycpzmGjWPWbIfMcB5kKrfRuFms1VOmBXW2wyYaVv8pel0iNjNxdQyJtZ9FF rQTDda0973WklA3JAnMTCHujZ7Qy5k0aaeaoZK7Ile8ZCyfhZHzln+WLYt8lTTDuG1jY PC+5YzhjJoAGG1QV2hau3Ua8wu3TSCdMOu6KqjoyF/NZ1J5GizJp4+RG4QkbMUGwAtDD 3bJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525477; x=1723130277; 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=c1Pb9QS/v2f3vAGxs3TsdsN7p4/3DlmEbF7eHgwyUYY=; b=hcYs8nAdXizDHUbXSmjgCkqzClXiiTcTg2Bw7xDbI2+0vakWh5CGLToMQt6Xghk/2D ZvnDFVeJryp3ib+NZizgnFlFN9lj9cen9aLyQ8HC4ZKrgINGSxJNFE3CUxxfHEpwlRNk SM+QHfU8V6sLLsOqemiQkReFikdre6vpAh3+DpbkT6tcWR1Yvc+4d175dEbR/FdSudLg R/MfV5bf7T8hcsG1IF82Go2Hrk0YY2XNriirVsRqv4igwHuiq4pL7J1nuHi0TUyif0on LVbAitKD0YnEDRHZ+/IAJeIDGVjhEDsab1YeXYyne+ZTZaKngG1iCBwkEIpnNFM+TzJe BEgQ== X-Gm-Message-State: AOJu0YzhHPruLUeLCMwIZNAK856BHm+9p+gJvD3SiGRAphgd/ucbcU1y sU+O5ey52vi119zteT7sBci03RbHqtUCJK0t3cGP21TGLnDrFvdvsq6k90ybHZSywQCGduR0mbp E3g== X-Google-Smtp-Source: AGHT+IFmxeKNBpJrXmrm+3bSyXyRu4Nd/8hqUVs8v0Aru5A0Uv1b0NH92SEo5Tg0LwcGmAdyBaA+xA== X-Received: by 2002:adf:ebd2:0:b0:36b:555a:e966 with SMTP id ffacd0b85a97d-36bbc130630mr92820f8f.35.1722525476949; Thu, 01 Aug 2024 08:17:56 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:56 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 08/30] ada: Fix internal error on limited aggregate in nested conditional expression Date: Thu, 1 Aug 2024 17:17:16 +0200 Message-ID: <20240801151738.400796-8-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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 This is a fallout of an earlier fix to Is_Build_In_Place_Aggregate_Return that made it take into account intermediate conditional expressions, but turned out to work only for a single nesting level of them. The fix reuses the delayed expansion mechanism recently extended to deal with conditional expressions in a straightforward way. gcc/ada/ * exp_aggr.adb (Convert_To_Assignments): Set Expansion_Delayed on intermediate conditional expressions for BIP aggregate returns too. * exp_ch4.adb (Expand_N_Case_Expression): Also deal with delayed expansion in the return case. (Expand_N_If_Expression): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 28 ++++++++--------- gcc/ada/exp_ch4.adb | 73 ++++++++++++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 35 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index c7730ca754a..2031d042fa5 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -4265,6 +4265,19 @@ package body Exp_Aggr is or else (Nkind (Parent_Node) = N_Assignment_Statement and then Inside_Init_Proc) + + -- (Ada 2005) An inherently limited type in a return statement, which + -- will be handled in a build-in-place fashion, and may be rewritten + -- as an extended return and have its own finalization machinery. + -- In the case of a simple return, the aggregate needs to be delayed + -- until the scope for the return statement has been created, so + -- that any finalization chain will be associated with that scope. + -- For extended returns, we delay expansion to avoid the creation + -- of an unwanted transient scope that could result in premature + -- finalization of the return object (which is built in place + -- within the caller's scope). + + or else Is_Build_In_Place_Aggregate_Return (N) then Node := N; @@ -4286,21 +4299,6 @@ package body Exp_Aggr is end loop; return; - - -- (Ada 2005) An inherently limited type in a return statement, which - -- will be handled in a build-in-place fashion, and may be rewritten - -- as an extended return and have its own finalization machinery. - -- In the case of a simple return, the aggregate needs to be delayed - -- until the scope for the return statement has been created, so - -- that any finalization chain will be associated with that scope. - -- For extended returns, we delay expansion to avoid the creation - -- of an unwanted transient scope that could result in premature - -- finalization of the return object (which is built in place - -- within the caller's scope). - - elsif Is_Build_In_Place_Aggregate_Return (N) then - Set_Expansion_Delayed (N); - return; end if; -- Otherwise, if a transient scope is required, create it now diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index f952005ed75..50c3cd430ce 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -5010,7 +5010,7 @@ package body Exp_Ch4 is Target : Entity_Id := Empty; Target_Typ : Entity_Id; - Optimize_Assignment_Stmt : Boolean; + Optimize_Assignment_Stmt : Boolean := False; -- Small optimization: when the case expression appears in the context -- of a safe assignment statement, expand into @@ -5029,18 +5029,22 @@ package body Exp_Ch4 is begin -- If the expansion of the expression has been delayed, we wait for the - -- rewriting of its parent as an assignment statement; when that's done, - -- we optimize the assignment (the very purpose of the manipulation). + -- rewriting of its parent as an assignment or return statement; when + -- that's done, we optimize the assignment or the return statement (the + -- very purpose of the manipulation). if Expansion_Delayed (N) then - if Nkind (Par) /= N_Assignment_Statement then + if Nkind (Par) = N_Assignment_Statement then + Optimize_Assignment_Stmt := True; + + elsif Optimize_Return_Stmt then + null; + + else return; end if; - Optimize_Assignment_Stmt := True; - - else - Optimize_Assignment_Stmt := False; + Set_Expansion_Delayed (N, False); end if; -- Check for MINIMIZED/ELIMINATED overflow mode @@ -5192,6 +5196,13 @@ package body Exp_Ch4 is Make_Simple_Return_Statement (Alt_Loc, Expression => Alt_Expr)); + -- If the expression is itself a conditional expression whose + -- expansion has been delayed, analyze it again and expand it. + + if Is_Delayed_Conditional_Expression (Alt_Expr) then + Set_Analyzed (Alt_Expr, False); + end if; + -- Take the unrestricted access of the expression value for non- -- scalar types. This approach avoids big copies and covers the -- limited and unconstrained cases. @@ -5493,7 +5504,7 @@ package body Exp_Ch4 is New_N : Node_Id; New_Then : Node_Id; - Optimize_Assignment_Stmt : Boolean; + Optimize_Assignment_Stmt : Boolean := False; -- Small optimization: when the if expression appears in the context of -- a safe assignment statement, expand into @@ -5510,18 +5521,22 @@ package body Exp_Ch4 is begin -- If the expansion of the expression has been delayed, we wait for the - -- rewriting of its parent as an assignment statement; when that's done, - -- we optimize the assignment (the very purpose of the manipulation). + -- rewriting of its parent as an assignment or return statement; when + -- that's done, we optimize the assignment or the return statement (the + -- very purpose of the manipulation). if Expansion_Delayed (N) then - if Nkind (Par) /= N_Assignment_Statement then + if Nkind (Par) = N_Assignment_Statement then + Optimize_Assignment_Stmt := True; + + elsif Optimize_Return_Stmt then + null; + + else return; end if; - Optimize_Assignment_Stmt := True; - - else - Optimize_Assignment_Stmt := False; + Set_Expansion_Delayed (N, False); end if; -- Deal with non-standard booleans @@ -5652,15 +5667,33 @@ package body Exp_Ch4 is Process_Transients_In_Expression (N, Then_Actions (N)); Process_Transients_In_Expression (N, Else_Actions (N)); + New_Then := Relocate_Node (Thenx); + + -- If the expression is itself a conditional expression whose + -- expansion has been delayed, analyze it again and expand it. + + if Is_Delayed_Conditional_Expression (New_Then) then + Set_Analyzed (New_Then, False); + end if; + + New_Else := Relocate_Node (Elsex); + + -- If the expression is itself a conditional expression whose + -- expansion has been delayed, analyze it again and expand it. + + if Is_Delayed_Conditional_Expression (New_Else) then + Set_Analyzed (New_Else, False); + end if; + New_If := Make_Implicit_If_Statement (N, Condition => Relocate_Node (Cond), Then_Statements => New_List ( - Make_Simple_Return_Statement (Sloc (Thenx), - Expression => Relocate_Node (Thenx))), + Make_Simple_Return_Statement (Sloc (New_Then), + Expression => New_Then)), Else_Statements => New_List ( - Make_Simple_Return_Statement (Sloc (Elsex), - Expression => Relocate_Node (Elsex)))); + Make_Simple_Return_Statement (Sloc (New_Else), + Expression => New_Else))); -- Preserve the original context for which the if statement is -- being generated. This is needed by the finalization machinery From patchwork Thu Aug 1 15:17:17 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: 1967865 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=FnNvIgsC; 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 4WZYB71cmGz1ybV for ; Fri, 2 Aug 2024 01:42:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5DE98384B063 for ; Thu, 1 Aug 2024 15:42:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 5BCA8385ED71 for ; Thu, 1 Aug 2024 15:17:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5BCA8385ED71 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 5BCA8385ED71 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525495; cv=none; b=RqOxVmRC5Ykr5RCBTDz1Alg12NVhgO5XaBN8bI1ueH5GZtwraoyYu+M9Q4cTnvjsphpnk2kooU91lLHuapzoErlyCmqNXXDi4ibOWH8r7JLPecBlaGWSewhZNDJT91HgKhPqAi/J5IojsvJdAC1iB9JJ1RjakyaE5ScWU4WSl9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525495; c=relaxed/simple; bh=LU0KSIeQ7fB5gq7c5ml14RAPvdtxfgbqi7htBuanu8M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UcBdBrg9QUE0af2TgPlguLeMt35aPui49DtJ6loDGglGcggqTnXb4CDaKPkgS7nK/ghENfH2AIWSxdF+qhZhlM5m92zm11pbI72RboLuM03SfkxNyUtxBxvh9Zb9HbyrY6GBj2Hxz1IHjEkxbyNJutIgxOOdbW7foofUp97AVmg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-368663d7f80so3573165f8f.3 for ; Thu, 01 Aug 2024 08:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525478; x=1723130278; 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=Qj+4fjrmHZsKyNKX4x9uwGDNrRol9PQ8MYqVTH7+mrs=; b=FnNvIgsCh6OEI2/PwTW7skO16Yf3Upg3PEF+BQiEyBdhH24KGQKftXtjQEYZHRlPEE 0VN5AXzvhNpa5zkru4yG8qGt5f64qhJNiQuj63HKv9V2dLuUqtuGBo6spe4KK/6wdkc9 E1fzDwv31wjwP2Ix7SkBOWisbEXjh0688+Yhm0/VRmgl033mDvyoaNATxcWjZIEPicgm 5PEk7RyN8f90OWHgZGqANPPN7GRBFlmQrF+HRYRK2wDguHH3Dn3CbkmRrepCMS229Lw+ pnKpILox2B7474h8M61nxb8TYuGNc8wzFMiYZulXgUPVH95eWTzUOqgUqstBwPmCp/Ru 5PQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525478; x=1723130278; 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=Qj+4fjrmHZsKyNKX4x9uwGDNrRol9PQ8MYqVTH7+mrs=; b=I/IQlRlsD+3PA/yoCPIR6LD2JrtcrsNhY7nFQgqotHcLHcG6jQ0AwN5I7riZb/Rwe5 N2gKpEp88Cu/pLfn5t9YyqmtnE+/YDACW20WlmN0H6bTC2Ybe9GL0q03gX3rEpD5WU9k 1IMzSadnQeX/PRBYM79TII+oqbpL6x+t5YrqH4liOhHWMVcN75ODrKUiiHgZlW9RLEIh UOHz0qcpy9v2COP17QrO1Ad2fBhJsgbGLJTZ1O3ITZYbhm9uI4Tg5FcYpFphPlliAoSA 3KuNqRuUOq59T5CdK2EMYALFKG6ARVhV5vtR7BGEEKyzQRWW0yjn22GGa4NJsPfmrEgL F0iA== X-Gm-Message-State: AOJu0YziCGlK/NELEL5sk7T+mV11PFxL7h5hZLovMXN1m3Jd32gKzc3h TC4TdA/t5mGQAgBZrDJOfROAmK660+CCNZNh4vMOMz/kkAM+w/yKbli8RuEddPa1qkw0+QBneaz OYQ== X-Google-Smtp-Source: AGHT+IHLjO5xW3cWQtWR7Xp2aooN4nOhcASldniGX/uAbwldlBOnT8PB1ce3OQ8ogO6MgFECpGheLA== X-Received: by 2002:adf:e2cf:0:b0:367:909b:8281 with SMTP id ffacd0b85a97d-36bbc17c14amr120832f8f.59.1722525477817; Thu, 01 Aug 2024 08:17:57 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:57 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED 09/30] ada: Missing adjust of controlled component initialized from container aggregate Date: Thu, 1 Aug 2024 17:17:17 +0200 Message-ID: <20240801151738.400796-9-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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: Gary Dismukes In the case of controlled components initialized by a container aggregate, the compiler was suppressing the call to the needed Adjust operation, because it was suppressed for all aggregates. But container aggregates aren't built in place, so target adjustment should still be done in that case. gcc/ada/ * exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do the component adjustment in the case of initialization by a container aggregate. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch3.adb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 1eea062210a..6fee2b41bac 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -2700,10 +2700,12 @@ package body Exp_Ch3 is end if; -- Adjust the component if controlled except if it is an aggregate - -- that will be expanded inline. + -- that will be expanded inline (but note that the case of container + -- aggregates does require component adjustment). if Needs_Finalization (Typ) - and then Nkind (Exp_Q) not in N_Aggregate | N_Extension_Aggregate + and then (Nkind (Exp_Q) not in N_Aggregate | N_Extension_Aggregate + or else Is_Container_Aggregate (Exp_Q)) and then not Is_Build_In_Place_Function_Call (Exp) then Adj_Call := From patchwork Thu Aug 1 15:17:18 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: 1967856 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=Pd0QVqbJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZY6S2c4sz1ybX for ; Fri, 2 Aug 2024 01:39:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95CB0384B813 for ; Thu, 1 Aug 2024 15:39:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 16D78385ED72 for ; Thu, 1 Aug 2024 15:18:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16D78385ED72 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 16D78385ED72 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::329 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525495; cv=none; b=Gp5xWDcxpTji1bsxGlNDxGzJqLEeNKtAjKgcfo7dRAIAEvS42uzg6qdkARpmlDS8GcTEocGmtsivtBaue5gw7w7OBlE52XZT48FNfPHfI07EYQg8LxxYABB2c895pbvChnb0vjBriUN1GearwcorKYOQ1NOhzVt7DHkAeu/MMOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525495; c=relaxed/simple; bh=uJ92PGY2KuRnPlKxt3zBfTAkHwAqJ6YRA+O5z67MYao=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=A585NGUDq4DjKXwyW9SjBZUWssZgUgj8CzkZz0+zAh8SM04WkLOn7kxqt3I25L6TKQuYKeeah5D6QKQpmj+C/kv8yLE5a7TWvbBolOpIzaAhtpydSBpLRN4tKPjARFlYToUKL6WAgL9MscxefGbYULhW0t00JZTPNNFpWXG8Fys= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42819654737so41509485e9.1 for ; Thu, 01 Aug 2024 08:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525480; x=1723130280; 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=ZdayRQIZrGTWkmsU7aNeI9PBgEQkjjosblTdhxN3cvw=; b=Pd0QVqbJSSwNkMSIwK8f4Ddx939x3t7TL/jf+B8luKhyiqBMQ1XjK8ZiifUwzXxq/H ZtnthG3mBc3O8AmoJjp62xkLZYS5cxsJ4dKNA675hqD3cPtqzJm8GJZ4GmYZ3FQpXHEW 6VJHsuytnuFoXyQoRJUby8lWoGWlRDfaW2+0MUoU7mQ3dwe9z6RM4VH5rnw3ToDnfhPz syADxMBN2hhmwl+jdgTlLFTXwQEN7cwdvINHzErAWK6T542ao3qixufTNFsmhEZkMjEN xTbHGhICl67vCNslv5YBROsZSKaFf2DVVb9JZDvz/8mWqt1m6wH91uEZLTndaVHRUWmf kKIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525480; x=1723130280; 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=ZdayRQIZrGTWkmsU7aNeI9PBgEQkjjosblTdhxN3cvw=; b=Cj8S0exFUfZYQuuKbFLDuKcDGJRPEh6wtuwSMbitJsdoP7nwdTcTleRaHmrGJWAKMv vRm3ao4WGwigNkVto3lu6nM5wLfBzvVspZ144dXa8DSr19/QddIAW8SpGsiug91QwkQ/ KT23rB8QeW9qnYkpbl1rXkAKwTTBDOEB6M8avqT5vntrGkeh00F/wsbxVYRv/fSY3Ddj nJGwLPafQJOiTwUcDUJmZsVxvf0KL5DQhGkI2QG3AsUyUV7taQgpm7SqCDqvjjXSDKe3 eETTV+k7SGl1wiLfGXEY5P3gMjU4bihT8Ygfki2vJsm3Ux4mpQfG9yl92SIWPbTKEhAB V3DQ== X-Gm-Message-State: AOJu0YwX5Ro+EuZfLa8OVLXzA5yDso5/jdPi1K+6OD10N/wkasEMknxy r7JTUjvH512Nwlgxv2dLBJZlgUIk7+asEE8sQSxhHL6q11UG0TwISDJAsTeWkeya6CavEHIJsgM iiA== X-Google-Smtp-Source: AGHT+IFr1vyFjvEsZKPR3z4DvNlGlwn8L+046oBXhEngSzKcQcksaY6Q+J4bS06RLNDkm3+kAtD2GQ== X-Received: by 2002:a5d:6903:0:b0:368:6660:36df with SMTP id ffacd0b85a97d-36bbc0fcc21mr120010f8f.35.1722525479502; Thu, 01 Aug 2024 08:17:59 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:59 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Arnaud Charlet Subject: [COMMITTED 10/30] ada: Followup on previous change for -gnatceg Date: Thu, 1 Aug 2024 17:17:18 +0200 Message-ID: <20240801151738.400796-10-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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: Arnaud Charlet gcc/ada/ * osint-c.ads, osint-c.adb (Create_C_File, Close_C_File, Delete_C_File): Put back, needed by LLVM based CCG. * exp_unst.adb (Unnest_Subprogram): Complete previous change by removing now dead code and corresponding ??? comment. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_unst.adb | 195 +------------------------------------------ gcc/ada/osint-c.adb | 40 +++++++++ gcc/ada/osint-c.ads | 18 ++-- 3 files changed, 55 insertions(+), 198 deletions(-) diff --git a/gcc/ada/exp_unst.adb b/gcc/ada/exp_unst.adb index 19bb8948a89..7ff1ea621bb 100644 --- a/gcc/ada/exp_unst.adb +++ b/gcc/ada/exp_unst.adb @@ -2190,197 +2190,10 @@ package body Exp_Unst is end loop; end Subp_Loop; - -- Next step, process uplevel references. This has to be done in a - -- separate pass, after completing the processing in Sub_Loop because we - -- need all the AREC declarations generated, inserted, and analyzed so - -- that the uplevel references can be successfully analyzed. - - Uplev_Refs : for J in Urefs.First .. Urefs.Last loop - declare - UPJ : Uref_Entry renames Urefs.Table (J); - - begin - -- Ignore type references, these are implicit references that do - -- not need rewriting (e.g. the appearance in a conversion). - -- Also ignore if no reference was specified or if the rewriting - -- has already been done (this can happen if the N_Identifier - -- occurs more than one time in the tree). Also ignore references - -- with GNAT-LLVM (CCG_Mode), since it will handle the processing - -- for up-level refs). - -- ??? At this stage, only GNAT LLVM uses front-end unnesting, so - -- consider remove the code below. - - if No (UPJ.Ref) - or else not Is_Entity_Name (UPJ.Ref) - or else No (Entity (UPJ.Ref)) - or else Opt.CCG_Mode - then - goto Continue; - end if; - - -- Rewrite one reference - - Rewrite_One_Ref : declare - Loc : constant Source_Ptr := Sloc (UPJ.Ref); - -- Source location for the reference - - Typ : constant Entity_Id := Etype (UPJ.Ent); - -- The type of the referenced entity - - Atyp : Entity_Id; - -- The actual subtype of the reference - - RS_Caller : constant SI_Type := Subp_Index (UPJ.Caller); - -- Subp_Index for caller containing reference - - STJR : Subp_Entry renames Subps.Table (RS_Caller); - -- Subp_Entry for subprogram containing reference - - RS_Callee : constant SI_Type := Subp_Index (UPJ.Callee); - -- Subp_Index for subprogram containing referenced entity - - STJE : Subp_Entry renames Subps.Table (RS_Callee); - -- Subp_Entry for subprogram containing referenced entity - - Pfx : Node_Id; - Comp : Entity_Id; - SI : SI_Type; - - begin - Atyp := Etype (UPJ.Ref); - - if Ekind (Atyp) /= E_Record_Subtype then - Atyp := Get_Actual_Subtype (UPJ.Ref); - end if; - - -- Ignore if no ARECnF entity for enclosing subprogram which - -- probably happens as a result of not properly treating - -- instance bodies. To be examined ??? - - -- If this test is omitted, then the compilation of freeze.adb - -- and inline.adb fail in unnesting mode. - - if No (STJR.ARECnF) then - goto Continue; - end if; - - -- If this is a reference to a global constant, use its value - -- rather than create a reference. It is more efficient and - -- furthermore indispensable if the context requires a - -- constant, such as a branch of a case statement. - - if Ekind (UPJ.Ent) = E_Constant - and then Is_True_Constant (UPJ.Ent) - and then Present (Constant_Value (UPJ.Ent)) - and then Is_Static_Expression (Constant_Value (UPJ.Ent)) - then - Rewrite (UPJ.Ref, New_Copy_Tree (Constant_Value (UPJ.Ent))); - goto Continue; - end if; - - -- Push the current scope, so that the pointer type Tnn, and - -- any subsidiary entities resulting from the analysis of the - -- rewritten reference, go in the right entity chain. - - Push_Scope (STJR.Ent); - - -- Now we need to rewrite the reference. We have a reference - -- from level STJR.Lev to level STJE.Lev. The general form of - -- the rewritten reference for entity X is: - - -- Typ'Deref (ARECaF.ARECbU.ARECcU.ARECdU....ARECmU.X) - - -- where a,b,c,d .. m = - -- STJR.Lev - 1, STJR.Lev - 2, .. STJE.Lev - - pragma Assert (STJR.Lev > STJE.Lev); - - -- Compute the prefix of X. Here are examples to make things - -- clear (with parens to show groupings, the prefix is - -- everything except the .X at the end). - - -- level 2 to level 1 - - -- AREC1F.X - - -- level 3 to level 1 - - -- (AREC2F.AREC1U).X - - -- level 4 to level 1 - - -- ((AREC3F.AREC2U).AREC1U).X - - -- level 6 to level 2 - - -- (((AREC5F.AREC4U).AREC3U).AREC2U).X - - -- In the above, ARECnF and ARECnU are pointers, so there are - -- explicit dereferences required for these occurrences. - - Pfx := - Make_Explicit_Dereference (Loc, - Prefix => New_Occurrence_Of (STJR.ARECnF, Loc)); - SI := RS_Caller; - for L in STJE.Lev .. STJR.Lev - 2 loop - SI := Enclosing_Subp (SI); - Pfx := - Make_Explicit_Dereference (Loc, - Prefix => - Make_Selected_Component (Loc, - Prefix => Pfx, - Selector_Name => - New_Occurrence_Of (Subps.Table (SI).ARECnU, Loc))); - end loop; - - -- Get activation record component (must exist) - - Comp := Activation_Record_Component (UPJ.Ent); - pragma Assert (Present (Comp)); - - -- Do the replacement. If the component type is an access type, - -- this is an uplevel reference for an entity that requires a - -- fat pointer, so dereference the component. - - if Is_Access_Type (Etype (Comp)) then - Rewrite (UPJ.Ref, - Make_Explicit_Dereference (Loc, - Prefix => - Make_Selected_Component (Loc, - Prefix => Pfx, - Selector_Name => - New_Occurrence_Of (Comp, Loc)))); - - else - Rewrite (UPJ.Ref, - Make_Attribute_Reference (Loc, - Prefix => New_Occurrence_Of (Atyp, Loc), - Attribute_Name => Name_Deref, - Expressions => New_List ( - Make_Selected_Component (Loc, - Prefix => Pfx, - Selector_Name => - New_Occurrence_Of (Comp, Loc))))); - end if; - - -- Analyze and resolve the new expression. We do not need to - -- establish the relevant scope stack entries here, because we - -- have already set all the correct entity references, so no - -- name resolution is needed. We have already set the current - -- scope, so that any new entities created will be in the right - -- scope. - - -- We analyze with all checks suppressed (since we do not - -- expect any exceptions) - - Analyze_And_Resolve (UPJ.Ref, Typ, Suppress => All_Checks); - Pop_Scope; - end Rewrite_One_Ref; - end; - - <> - null; - end loop Uplev_Refs; + -- Note: we used to process uplevel references, in particular for the + -- old CCG (cprint.adb). With GNAT LLVM, processing of uplevel + -- references needs to be done directly there which is more reliable, so + -- we no longer need to do it here. -- Finally, loop through all calls adding extra actual for the -- activation record where it is required. diff --git a/gcc/ada/osint-c.adb b/gcc/ada/osint-c.adb index 0fef274217a..08abbae9464 100644 --- a/gcc/ada/osint-c.adb +++ b/gcc/ada/osint-c.adb @@ -44,6 +44,23 @@ package body Osint.C is -- output file and Suffix is the desired suffix (dg/rep/xxx for debug/ -- repinfo/list file where xxx is specified extension. + ------------------ + -- Close_C_File -- + ------------------ + + procedure Close_C_File is + Status : Boolean; + + begin + Close (Output_FD, Status); + + if not Status then + Fail + ("error while closing file " + & Get_Name_String (Output_File_Name)); + end if; + end Close_C_File; + ---------------------- -- Close_Debug_File -- ---------------------- @@ -173,6 +190,18 @@ package body Osint.C is return Result; end Create_Auxiliary_File; + ------------------- + -- Create_C_File -- + ------------------- + + procedure Create_C_File is + Dummy : Boolean; + begin + Set_File_Name ("c"); + Delete_File (Name_Buffer (1 .. Name_Len), Dummy); + Create_File_And_Check (Output_FD, Text); + end Create_C_File; + ----------------------- -- Create_Debug_File -- ----------------------- @@ -265,6 +294,17 @@ package body Osint.C is end if; end Debug_File_Eol_Length; + ------------------- + -- Delete_C_File -- + ------------------- + + procedure Delete_C_File is + Dummy : Boolean; + begin + Set_File_Name ("c"); + Delete_File (Name_Buffer (1 .. Name_Len), Dummy); + end Delete_C_File; + ------------------- -- Delete_H_File -- ------------------- diff --git a/gcc/ada/osint-c.ads b/gcc/ada/osint-c.ads index bde37c72723..583d9e4b433 100644 --- a/gcc/ada/osint-c.ads +++ b/gcc/ada/osint-c.ads @@ -160,22 +160,26 @@ package Osint.C is -------------------------- -- These routines are used by the compiler when the C translation option - -- is activated to write *.h files to the current object directory. - -- Note that the files are written via the Output package routines, using - -- Output_FD. + -- is activated to write *.c or *.h files to the current object directory. + -- Each routine exists in a C and an H form for the two kinds of files. + -- Only one of these files can be written at a time. Note that the files + -- are written via the Output package routines, using Output_FD. + procedure Create_C_File; procedure Create_H_File; - -- Creates the *.h file for the source file which is currently being + -- Creates the *.c/*.h file for the source file which is currently being -- compiled (i.e. the file which was most recently returned by -- Next_Main_Source). + procedure Close_C_File; procedure Close_H_File; - -- Closes the file created by Create_H file, flushing any buffers, etc. + -- Closes the file created by Create_C/H file, flushing any buffers, etc. -- from writes by Write_C_File and Write_H_File; + procedure Delete_C_File; procedure Delete_H_File; - -- Deletes the .h file corresponding to the source file which is currently - -- being compiled. + -- Deletes the .c/.h file corresponding to the source file which is + -- currently being compiled. ---------------------- -- List File Output -- From patchwork Thu Aug 1 15:17:19 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: 1967890 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=Kb2ITpn8; 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 4WZYKf5z87z1yZv for ; Fri, 2 Aug 2024 01:48:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4279384AB59 for ; Thu, 1 Aug 2024 15:48:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 3DD1F385E44D for ; Thu, 1 Aug 2024 15:18:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DD1F385E44D 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 3DD1F385E44D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::233 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525503; cv=none; b=pmGnb3o2hN9xEp++mCCihv6jkTBmRpTWdG89Z5WIRp7bq1PxWtFiWZFIRyBayPc7cT1cRR6w8DOy77S0z4JCpHQXHOVTuonskiuimgRaIr2k24KfjTbj47OYk5u+FyICA3/kQOgkXKO2TapcI6E/G/64NnMOlFfxOykR3KSLx+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525503; c=relaxed/simple; bh=POuQg2fCMrCZX4o0kW6C10SOjWk3fp/7pnDLivmpjd0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EPrbnUobsFXbSZOqaacNQ3luz3MTGZ820ZfuIOzuCJtt8ikY/lqO/TmOlb55Bs4spSsaqJElQW5r0BYC6WcBzrbpZEgZDREv7qV7cQCFJxE4uxSRI2eU2ytsSn1OQZYPF5UDEng73GzK2e9s6kxlu9lvsmJQwH41Qdb7IkhyUsc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ef2d582e31so84330891fa.2 for ; Thu, 01 Aug 2024 08:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525499; x=1723130299; 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=VHlG2PfjHS3kKOyga7VWOC6CEQO3TdCNGmHT9McLCNg=; b=Kb2ITpn8g7bN/r8sfw0gDj24yvTOl34Vjzqs+d/XlbGltSagIrgEnAT5XLN4hDqkO+ 4yNvUhjUjyg5oTL82POE1Ar1JUrrA4nZvgX7BsYgyOxAJfEJQwsZPIue3D3nB7WZS4VV /xVz20R1VUXONXyGp+6Ht+Uz1Cw4wcqmF6aY2zRu+beyUu4Uz/DG3h8/jId2rSNdu8vH enxfHb784ezYg30/ZUmITFiW3Jue2+HBufJkx68BsrCRumTng1/GDdBa+xrU185AIHwI TjvVQb9hJ6vlunIw2ufO+8RmxImSvw4/jvpwj5nd1doE6dPlSkz4b/zmDjQJih3CA9Pe cy3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525499; x=1723130299; 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=VHlG2PfjHS3kKOyga7VWOC6CEQO3TdCNGmHT9McLCNg=; b=Lzei+BG+V/BME4Fq3tBdYTDhtekfBQ7HeLCmXYFTk0XVyTo8xuTpl7c/P0Gsjutta1 f2oj/vz4ZUBATj+G33CESJ1Db99PmFN7duBkfBvJSEnDEFgQdRYLA171l+pFjEKuC6n3 VN3xmwgclXgpA56qfx20TtT8O5O+e6KCp16APNG4l8ZN3ZwJfS67d9ouBf7/faryGZl/ yc37WXkyj06jujkvdhdAAh6etR8H0Mv43n2e3ArBOOinX7HC3e2LOWZzRupRvtCaIlgV xCISHd9g0Tr7uCbErXhC0H5LDwrwaF/R7OSzP9TCpjaO5MShFTHWgAnILqH+wnf8kaW7 PUGA== X-Gm-Message-State: AOJu0Yy181IjXNUPV+FrPxIWb5zCBd7+7jG90pI+5zjzBfKb8YHqW4ky PUaYRr+aGl5Qk+shIAW3wYc6w/QqvFcjonjlIboMD4djeKoQv/DIGyMURsqZTciUVBFq7xGRZx2 9xQ== X-Google-Smtp-Source: AGHT+IF6yjNMInF3iun8gd1xq1S74btRHBnFLL3l/y7Cbpym7nYpe8wVv59tYE2Q6q7tWUInF4BwyQ== X-Received: by 2002:a2e:9296:0:b0:2f1:59ed:879d with SMTP id 38308e7fff4ca-2f15aa84d1bmr4867431fa.1.1722525480316; Thu, 01 Aug 2024 08:18:00 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:17:59 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 11/30] ada: Miscomputed bounds for inner null array aggregates Date: Thu, 1 Aug 2024 17:17:19 +0200 Message-ID: <20240801151738.400796-11-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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: Javier Miranda gcc/ada/ * sem_aggr.adb (Collect_Aggr_Bounds): Adjust previous patch to store the bounds of inner null aggregates in the itype; required generate the runtime check of ARM 4.3.3(30). Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index bddfbecf46d..5f7c7321f4f 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -569,10 +569,9 @@ package body Sem_Aggr is end if; -- For null aggregates, build the bounds of their inner dimensions - -- (if not previously done). They are required for building the - -- aggregate itype. + -- since they are required for building the aggregate itype. - elsif No (Aggr_Range (Dim + 1)) then + else declare Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); @@ -622,7 +621,6 @@ package body Sem_Aggr is Null_Range := Make_Range (Loc, New_Copy_Tree (Lo), Hi); Analyze_And_Resolve (Null_Range, Index_Typ); - pragma Assert (No (Aggr_Range (Num_Dim))); Aggr_Low (Num_Dim) := Low_Bound (Null_Range); Aggr_High (Num_Dim) := High_Bound (Null_Range); Aggr_Range (Num_Dim) := Null_Range; From patchwork Thu Aug 1 15:17:20 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: 1967893 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=i4SJo5ql; 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 4WZYNp387Pz1ybV for ; Fri, 2 Aug 2024 01:51:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A85943864818 for ; Thu, 1 Aug 2024 15:51:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id C4599385DDFC for ; Thu, 1 Aug 2024 15:18:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4599385DDFC 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 C4599385DDFC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; cv=none; b=UBJvdfgR760EH2oSzNcahU72qliXV0CQ/Wpe6SZhawrqQkn9V9qmG3nC1pfM+O+b5Nq4uNkFjfwnhErC4NXxmIgItGNO948GDv8LNurDsjmvrOmAPN9nrb6jQn3uh56SQgsjZ8Q8XEb4wXLqggnKeCypL8OtXnT8qYTM8vlrpjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; c=relaxed/simple; bh=SYBjYlVsiaHFFWYQwwCtZ+a9tc7qFnZbVc3VJz4f3Gc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TQwSkJrD/caRYCdBeVUvMXkko3rKaMpD3+0GQzB1x0rq8aS4YEE3XgGlm9StKIWvIN1AUn1zw0AoI+nPTuIDIs3LUbhwvXLoL8dw6Q66P3Mer5b6H2aJmha376VztEwnztw5O4kifbb5lrOoTIkoRP1SzD6TlEQHmGMLrxRz7Ko= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-368f92df172so3487210f8f.2 for ; Thu, 01 Aug 2024 08:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525499; x=1723130299; 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=FnW8t1mVb5YV/Eahz318LodGyJ5PgXj01WYNlUSbNAw=; b=i4SJo5qlwN7ZT5Go9Qp0ITDeJilGY/7rtkvNMvJqMS8hgOzI7o/WQXEs9oxcCk8K9O uFf8Frag2KNzeiXxLose88gfe3PwwtbbNJY4Y0b6EwNCI8Xj0+yqM8o00N/OGgZh7huQ 37IyLGiOhw6r/3ttDHsQvBjYWlrV+XdhS949QeeyCeHe8Lx9LCiXDhi1j3O5oLiYiUyJ hVp+ORJC9cvLRSFOYoowulp9loJ3k4fhDsU+H64lT5cv3r/+1641wX6HXh4PfW7ubKeu CGgl25Hzi37YqRMgls1szj+R7PHVRh6dYiviWy0qJYqn6UuvE3wXuQRZgSZX5XhmXhiO 9IqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525499; x=1723130299; 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=FnW8t1mVb5YV/Eahz318LodGyJ5PgXj01WYNlUSbNAw=; b=eGwBz2q8PUnvBnKzehgYCCnhTUSmakRV11UJT9AKZEHaNtA8jomSWd+yBlerTbbezS k7Px+WdPumFClveIYpSNYeVGkgYc2Y+0dx7oDW5uB+oTRbSzKlAgNDEs2yfNj7H41Rx6 X1ZQWSjfksX5FgcRQa46TD4sEG6vcuoKmJ6b9+SaR/BmTRhZg1K+scBhajpsgsxwFvmr 1fXkL8bUzNmdf6lU+p4JhCavMvZqk9U+Hy7D8yF0zYiwSKzi7X/hZf+lHrNcMDay9TyT KyTyEZZNABNBVFGtDM/oxPpdFHPLVeL+XV+bFEornbhEosBvVdSd3Ffjbt+XvLsFt+HD bVGg== X-Gm-Message-State: AOJu0YwUFfQP0IuM+dU28tweUxBBdtCAsaIteGoHPGUomYjn9U+Cl+HW 0IuuVQ/fu8KNKMYmt5DNQ9XNXH+BTmSPklyjFTE1CO5ZjZrJgbtylxBliB0FJmQel38trs0L8yX +EQ== X-Google-Smtp-Source: AGHT+IGTKTFVM00gz2Zn9DFaJ79Tb2xfUOHUiUU3o2hbaDei+Sa35VGUzfw92BowvTifYAXk8Xi7Qg== X-Received: by 2002:a5d:5101:0:b0:367:9575:2820 with SMTP id ffacd0b85a97d-36bbc14ada2mr113992f8f.45.1722525499471; Thu, 01 Aug 2024 08:18:19 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:19 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 12/30] ada: Change "missing overriding indicator" message from error to warning Date: Thu, 1 Aug 2024 17:17:20 +0200 Message-ID: <20240801151738.400796-12-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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: Steve Baird There is no RM rule requiring an overriding indicator in the case where this message is generated; such a rule was discussed many years ago in an AI, but that AI was never approved. So generate a warning message instead of an error message. And don't even do that if we are in an instance (warning a user they should change the source of an instance seems unlikely to be helpful, at least in this case). gcc/ada/ * sem_disp.adb (Check_Dispatching_Operation): When calling Error_Msg_NE to generate a "missing overriding indicator" message, generate a warning message instead of an error message (and update comment to describe this new behavior). Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_disp.adb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb index fe822290e45..3c1c49f7064 100644 --- a/gcc/ada/sem_disp.adb +++ b/gcc/ada/sem_disp.adb @@ -1666,13 +1666,14 @@ package body Sem_Disp is then Ovr_Subp := Find_Hidden_Overridden_Primitive (Subp); - -- Verify that the proper overriding indicator has been supplied. + -- Warn if the proper overriding indicator has not been supplied. if Present (Ovr_Subp) and then not Must_Override (Specification (Unit_Declaration_Node (Subp))) + and then not In_Instance then - Error_Msg_NE ("missing overriding indicator for&", Subp, Subp); + Error_Msg_NE ("missing overriding indicator for&??", Subp, Subp); end if; end if; From patchwork Thu Aug 1 15:17:21 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: 1967868 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=Mfhyxke+; 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 4WZYCN42Jsz1ybV for ; Fri, 2 Aug 2024 01:43:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C03493864C6A for ; Thu, 1 Aug 2024 15:43:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id AFAFA385DDF1 for ; Thu, 1 Aug 2024 15:18:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AFAFA385DDF1 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 AFAFA385DDF1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; cv=none; b=AAAur0NFLLq+GD2oK5dkDYIHI0MzbOV4YDL58xmmWfKFgboxsl0I1zDBnqlfMH6WvI76VWxNokh57xUCwdxgOCmxY6hwFJDm0G7HNZmfAs6FcmT/gV/CH3W/jOlugI1oyZ6p6DBqMWGLRW2wYs2GSBvzJhMHKw0VAHFnDkxWmi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; c=relaxed/simple; bh=40wSllkZDhrcYLSnAILblYP5gso/GuK7zRzQ6tHkqcg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pEXK8o4eS3q7Z7Y4L/uzgEz9TZ4gqMSvsfB8Tk1DCGLUv4Owwbhh1aw8KaJT76Zo1uo2rMb+iUS7oFCtSHKoyskeyUydFwBC7YP5eRzzTJ4Fezz4dY5UAC9v/n1sXZm7xvk7t9od123zVQgL+oQtrwvb1IUqBfy/DJiWEofSiHY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-36844375001so3250066f8f.0 for ; Thu, 01 Aug 2024 08:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525500; x=1723130300; 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=LsYBQ49H/el8diTueR3TiSL1lZZpelN0r1eWWz5JI+I=; b=Mfhyxke+UevZ2c3ygHK5O6P86ZTxgVBDGrH5T+GJmjSAUp+pinAhBoKVGmFie7k3ui SktmYP362JFyaYG98MzR7Tbt+X1ZoGvyTZ9jFzKEKv4Oir2lNnPaX5TJVBK3aqizThke wUEIlslhpUplJ7d0vfQAizGZLbnXZHmjJzN1Bgyh/EZHMAbLtLc/pYdh8xKVn4CffwNP RwA8S49PAXlm2HavWI9uCazRNc4Can/Id7uS47/xVy38WnBADQifyhD9nrAIufO4lvTt +Krk7Zff4NQGpA0ZbLL4a2tTg/eNBNmCpYDHP2C3/tMi4fapN86fQaXZKTPN4wtZTANG Vxkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525500; x=1723130300; 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=LsYBQ49H/el8diTueR3TiSL1lZZpelN0r1eWWz5JI+I=; b=gRnbzxEh1s8Ec/JXQwXkeF3mxRumx3OqRM9Hqwjyjt98cOzgz4bjL0m4PqDJB1mPNR 17zyCBz05/1wvJYxBYxzYMm7wqomszi/iK4vm1O0ecxehO/A4MvA3i9RsQuDnZo11okB IYellv0YlCtd9kvKw8WfiMpat47LtVW9eb4Y4ZZjco5Zu+S07M5qFLeUa73ci2vPYg3S ueyz35FQO/xO65Q3fvBRSLqdBqz7cnmiYkh5OnMfrTji0xfVWWKQzNlIjekHSWelda4y gIRgqMG02/ywqlPiCOaZTVeATrtnbAqXS0y24VpbKE1qUQUa0SV15KCl0G59cePsyk16 yX5w== X-Gm-Message-State: AOJu0YwuFoDLTtsg27nbs4iYsfbH1fdugr9QCWbSKPzy5S1h0Psj4zzt YdmDrXni/g54TkXrub7EfpbAByip3a5opXuy3CBMMYJptim8jUZQBu3PCZP1zSs/B11Yu/dCRUb Wcg== X-Google-Smtp-Source: AGHT+IH5jxi68iVUbECxuoZWgv6TrD97TOGus+5g8WNLZQA8V4Hl0KIzxGaGx5rWRJjnh6Oxz/FWVQ== X-Received: by 2002:a05:6000:4595:b0:362:b906:99c4 with SMTP id ffacd0b85a97d-36bbc1706f5mr104758f8f.58.1722525500347; Thu, 01 Aug 2024 08:18:20 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:19 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 13/30] ada: Remove Must_Not_Freeze flags from default value expressions Date: Thu, 1 Aug 2024 17:17:21 +0200 Message-ID: <20240801151738.400796-13-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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: Piotr Trojanek This is a code cleanup and apparently has no impact on the behavior. The Must_Not_Freeze is saved/set/restored by Preanalyze_Spec_Expression, so it doesn't need to be set before calling that routine and apparently doesn't need to be set after that calling that routine either. gcc/ada/ * sem_ch13.adb (Resolve_Aspect_Expression): Don't set Must_Not_Freeze before preanalyzing spec expressions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 2 -- 1 file changed, 2 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index a7936641d34..c8fe7d367c1 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -16060,7 +16060,6 @@ package body Sem_Ch13 is -- before the actual freeze point. when Aspect_Default_Value => - Set_Must_Not_Freeze (Expr); Preanalyze_Spec_Expression (Expr, E); when Aspect_CPU @@ -16076,7 +16075,6 @@ package body Sem_Ch13 is -- relevant to the misuse of deferred constants. when Aspect_Storage_Size => - Set_Must_Not_Freeze (Expr); Preanalyze_Spec_Expression (Expr, Any_Integer); when others => From patchwork Thu Aug 1 15:17: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: 1967892 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=QItZoLfp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZYMp5Z6nz1ybV for ; Fri, 2 Aug 2024 01:50:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01AC1384AB4C for ; Thu, 1 Aug 2024 15:50:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 86E48385DDDB for ; Thu, 1 Aug 2024 15:18:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86E48385DDDB 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 86E48385DDDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; cv=none; b=MI2N8I4lkmjk/HBxlQGOCnFXSiwsE5Hbo0LYThfVL6UhzkjmsskqvHoa/3aJc1fbNPhqxekfiBZ9HwGDkIs4FKzrDQrFKr+8QXn9PEhshw+HlMU8mUh767V4bvrUO53UnS2UZRyU8YwaEY6WDtZn5F5VRU6cdHqv1rqRbZWH8IY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; c=relaxed/simple; bh=QfPOAS+MH8PxmBARE1w2XwrT8RmARderG5HOsxdytBw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=i0pkevj9OfeoPxhwseDp6aZjfFsYWxwy8ZDzaN251NU8m1JhbOPSDF1TrQ9ph0M0vAa1rUcCNiyNBndX9o0BgViyjv548UbPdGx571RtCcS11v0u+nI+f8490ahOzqGeetRJ196c38kV8zY0M33CJxGWx4vZfuJkl4W70NHyLFA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4280b3a7efaso47678005e9.0 for ; Thu, 01 Aug 2024 08:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525501; x=1723130301; 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=wdIi3eJH4MCcM7/HcLdAuFJXDsGxvx4HCTidl4bCGFg=; b=QItZoLfpmBj/VYJWE198HZ0nFUeuiMaEVVvvx/+f9vyS2LLKAUCdaN+JMj6Utvv/2I JKXutffGjNxbjSr7aeKmokp23dCGcpL7iUm2IAMI/4qkZUvXZtr2S3myiuGhfzIQZF0w KFDMSjzx4O47RjU2/C/xL5qaY4+U2eUCoK/08Mfz56cW6HPeCuXqj/Gn5YrpOJpydIp3 z1hL4IwJLpznPVQUBwuZWaNnmnM/atf2i2QV5XvojIDlLGDfuKY8lOD4V5kO7srv8Cvt /uiZPqK9AVBo/gq2fWhXnZekUsowEoG8/miTu35bcYGVnqDvpb11KKcGD6CIRJsa/vXH xTxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525501; x=1723130301; 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=wdIi3eJH4MCcM7/HcLdAuFJXDsGxvx4HCTidl4bCGFg=; b=WnIa+/hqiw3A3i9J0BFtOJdT9jVqOv8Hj6bTihr1gew6sKii5weQKYIKmWPK92AGBc QorEbPgSrFV3DQxNO0AUkxwhXQCg1O+Guo4IeHREvA82RUw+Sy/puYJmwVCQ0rNEUy5Q +QQ9YIjhVhdyD7K+HGyg/Uw4qKQrr012HtM0jxpHy6n/VYCd9x4aitg1/HKVsRouZCJW A1ehhsGGDExOt3mZdgA0+pAYFSd7j6aiNjsyJ8xWncZHmhOM9t6BleTVsJ4yQTPc/8N4 cqhryZivlMX1eat8PycybVYzILIb+/WSNxbW8zHRhriLVZ5Bv9EOaTDWbLtwcStNP0Wv uiKA== X-Gm-Message-State: AOJu0YyVNbcM6tq6mmVHsI2jIiofJFt4Iw7QTqzJdGhI0sryu49Fq/oZ KpKCZ+ZyClM4zntGEIDJeGrSfMax6JscDolAXX/+h+s/WYslyRRYxMQhwMwWWz4Vpt8uv2gIJUx 04Q== X-Google-Smtp-Source: AGHT+IGIWus+GZN6pujDT1QVOll63z8OgB3O5lIo8Tovf7s97TqbBMlrWwwUXdhuNZYK/SVD/byEcw== X-Received: by 2002:a05:600c:4711:b0:428:1fa1:7b92 with SMTP id 5b1f17b1804b1-428e6b0fa47mr1492335e9.19.1722525501088; Thu, 01 Aug 2024 08:18:21 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:20 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 14/30] ada: Fix freezing of Default_Value expressions Date: Thu, 1 Aug 2024 17:17:22 +0200 Message-ID: <20240801151738.400796-14-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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: Piotr Trojanek This patch fixes an infinite loop in freezing that occurred when expression of the Default_Value aspect includes a declare expression with an object of the annotated type. gcc/ada/ * sem_ch13.adb (Check_Aspect_Too_Late): Prevent freezing during preanalysis. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index c8fe7d367c1..3784f831410 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1049,17 +1049,21 @@ package body Sem_Ch13 is Parent_Type : Entity_Id; Save_In_Spec_Expression : constant Boolean := In_Spec_Expression; + Save_Must_Not_Freeze : constant Boolean := Must_Not_Freeze (Expr); begin -- Ensure Expr is analyzed so that e.g. all types are properly -- resolved for Find_Type_Reference. We preanalyze this expression - -- as a spec expression (to avoid recursive freezing), while skipping - -- resolution (to not fold type self-references, e.g. T'Last). + -- (to avoid expansion), handle it as a spec expression (like default + -- expression), disable freezing and skip resolution (to not fold + -- type self-references, e.g. T'Last). In_Spec_Expression := True; + Set_Must_Not_Freeze (Expr); Preanalyze (Expr); + Set_Must_Not_Freeze (Expr, Save_Must_Not_Freeze); In_Spec_Expression := Save_In_Spec_Expression; -- A self-referential aspect is illegal if it forces freezing the From patchwork Thu Aug 1 15:17:23 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: 1967861 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=kPuc+aP0; 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 4WZY8248g5z1ybV for ; Fri, 2 Aug 2024 01:40:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C040F3865C24 for ; Thu, 1 Aug 2024 15:40:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 628BF3861009 for ; Thu, 1 Aug 2024 15:18:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 628BF3861009 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 628BF3861009 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525508; cv=none; b=dOjHcLGTpchMxbUjJlW8w+sQL7cuItKbgRZK2RC2p+BxxPnrk7e1OpxWUQgdzPsfyu5jzaxrcSaI1vSn+SL87fE9KgH4sTM25mm7ya3RuoTCJXlD09+VIhvp/nndWXsyQtz9EhrrcZ7Iv9ScZuD3XXC5+2uAd3oifMOQkK+ORNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525508; c=relaxed/simple; bh=BJyBfDUTwuJ/A1cmbBjW+DDfpVtYHb3xGvsOcyatgyw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=X8VdLjjn13YgR72gHZpecGFfpwFd6NHahNuWyoZBTqmTuJSs3yYr+bvobi98qKPL+lIrT5CqB7MTgXg4th+Ho9ltOKyUcW51PR8+0nbT8nIOPl6QbWCe5VT37XLJapWBD8LppM5nfCLPZJSSvKk733RRTI3i6QXN/NvSxum6yB4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3687fb526b9so3455660f8f.0 for ; Thu, 01 Aug 2024 08:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525502; x=1723130302; 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=GnM7NwMPpnDctHukdId8mkA4adCr1jbUGR5ZxehyZI0=; b=kPuc+aP00C9cMklCHM9a7pasK+7XheyJjEw/V1fapvUxH4IQZlgZ/8KMi9HSTskeBi GNURKU160NKOaxjG1ondtamMnEmWgIFDDJ4mXlRI299OAni9DCM7BEhCBGNQ41+/MahV GmpkYZR+XNrwlrLns7SvMHjoFGCLvWHsy/OD0O+WMksett55WGnyKiPJce3VhRf5y2BW sqX8DJckkvrcYlAEP+RBskFDN5hRlrA1Cridpir8AZgp86Q9jBfzP17jwIevX9225TxW xehBZnsvSSgvmvyN2lItlWIn4BkYO7UPDw/kOYy9k+zPT5uh4Ho6lIgh9fcWBp3GZHRO Vykg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525502; x=1723130302; 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=GnM7NwMPpnDctHukdId8mkA4adCr1jbUGR5ZxehyZI0=; b=o+iiZkqS52OFhMqtydFTmAv9gaBrpms2SfMSrxlwzm9+twNcPqq4zl0brJ1lCJkOIV Ms1P7BokkMNVKPvyf5cXMs3FKSP1tmM9xdSbajXNhgb3Omb9hK0O2c/p+hruYZTfR0vy oxOEf28/a3Js3uV+lRj4Sc3MNmIGU4DqffPUIDcbGaqkkfaA1IZBN1gJ72OdBfrELYhg jCe65qhtfXgtg5ogLZpcVHLZgu08QHlXUPPMrti2ZlrnwTIzp88PBhUt9OQLNUlXm2H/ I138tf9ri8OlmXf789hEaKs3R3cLN/azVGvQS05QJVyP+3G6lW+uDskXhVc7i8mZPT4l 5SaQ== X-Gm-Message-State: AOJu0YzktStkmjRG9DRoMSnmhwdx10QsC29/6BXH/dsBov6ej3IATAdB rGMwo1Kq0bHSWCBqNYxqxWbvinehf7/eh5HnyZlZZkisjFXDV+sTQuJHHJRel7Ys/Pw2p1lRd3j zLg== X-Google-Smtp-Source: AGHT+IGq/89rJEteW5NcxzHcjPAEh1fTXjcEdDFyDl4yRJEU2RSjH45UAVji69sFcRZXCY1lZSAigQ== X-Received: by 2002:adf:b195:0:b0:368:5b78:c92e with SMTP id ffacd0b85a97d-36bbc0e468dmr118648f8f.24.1722525501975; Thu, 01 Aug 2024 08:18:21 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:21 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 15/30] ada: Check default value aspects before resolving their expressions Date: Thu, 1 Aug 2024 17:17:23 +0200 Message-ID: <20240801151738.400796-15-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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: Piotr Trojanek Check expressions of aspects Default_Value and Default_Component_Value for references to the annotated types just before resolving these expressions. This patch fixes both an asymmetry in processing of those aspects and adds a missing check in GNATprove on aspect Default_Component_Value. gcc/ada/ * sem_ch13.adb (Check_Aspect_Too_Late): Move routine to top-level. (Resolve_Aspect_Expressions): Check aspects Default_Value and Default_Component_Value before resolving their expressions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 229 ++++++++++++++++++++++--------------------- 1 file changed, 117 insertions(+), 112 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 3784f831410..b903381e5de 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -160,6 +160,14 @@ package body Sem_Ch13 is -- Performs the processing of an aspect at the freeze point. ASN is the -- N_Aspect_Specification node for the aspect. + procedure Check_Aspect_Too_Late (N : Node_Id); + -- This procedure is similar to Rep_Item_Too_Late for representation + -- aspects that apply to type and that do not have a corresponding pragma. + -- + -- Used to check in particular that the expression associated with aspect + -- node N for the given type (entity) of the aspect does not appear too + -- late according to the rules in RM 13.1(9) and 13.1(10). + procedure Check_Pool_Size_Clash (Ent : Entity_Id; SP, SS : Node_Id); -- Called if both Storage_Pool and Storage_Size attribute definition -- clauses (SP and SS) are present for entity Ent. Issue error message. @@ -967,14 +975,6 @@ package body Sem_Ch13 is -- This routine analyzes an Aspect_Default_[Component_]Value denoted by -- the aspect specification node ASN. - procedure Check_Aspect_Too_Late (N : Node_Id); - -- This procedure is similar to Rep_Item_Too_Late for representation - -- aspects that apply to type and that do not have a corresponding - -- pragma. - -- Used to check in particular that the expression associated with - -- aspect node N for the given type (entity) of the aspect does not - -- appear too late according to the rules in RM 13.1(9) and 13.1(10). - procedure Make_Pragma_From_Boolean_Aspect (ASN : Node_Id); -- Given an aspect specification node ASN whose expression is an -- optional Boolean, this routines creates the corresponding pragma @@ -1000,110 +1000,6 @@ package body Sem_Ch13 is Check_Aspect_Too_Late (ASN); end Analyze_Aspect_Default_Value; - --------------------------- - -- Check_Aspect_Too_Late -- - --------------------------- - - procedure Check_Aspect_Too_Late (N : Node_Id) is - Typ : constant Entity_Id := Entity (N); - Expr : constant Node_Id := Expression (N); - - function Find_Type_Reference - (Typ : Entity_Id; Expr : Node_Id) return Boolean; - -- Return True if a reference to type Typ is found in the expression - -- Expr. - - ------------------------- - -- Find_Type_Reference -- - ------------------------- - - function Find_Type_Reference - (Typ : Entity_Id; Expr : Node_Id) return Boolean - is - function Find_Type (N : Node_Id) return Traverse_Result; - -- Set Found to True if N refers to Typ - - --------------- - -- Find_Type -- - --------------- - - function Find_Type (N : Node_Id) return Traverse_Result is - begin - if N = Typ - or else (Nkind (N) in N_Identifier | N_Expanded_Name - and then Present (Entity (N)) - and then Entity (N) = Typ) - then - return Abandon; - else - return OK; - end if; - end Find_Type; - - function Search_Type_Reference is new Traverse_Func (Find_Type); - - begin - return Search_Type_Reference (Expr) = Abandon; - end Find_Type_Reference; - - Parent_Type : Entity_Id; - - Save_In_Spec_Expression : constant Boolean := In_Spec_Expression; - Save_Must_Not_Freeze : constant Boolean := Must_Not_Freeze (Expr); - - begin - -- Ensure Expr is analyzed so that e.g. all types are properly - -- resolved for Find_Type_Reference. We preanalyze this expression - -- (to avoid expansion), handle it as a spec expression (like default - -- expression), disable freezing and skip resolution (to not fold - -- type self-references, e.g. T'Last). - - In_Spec_Expression := True; - Set_Must_Not_Freeze (Expr); - - Preanalyze (Expr); - - Set_Must_Not_Freeze (Expr, Save_Must_Not_Freeze); - In_Spec_Expression := Save_In_Spec_Expression; - - -- A self-referential aspect is illegal if it forces freezing the - -- entity before the corresponding aspect has been analyzed. - - if Find_Type_Reference (Typ, Expr) then - Error_Msg_NE - ("aspect specification causes premature freezing of&", N, Typ); - end if; - - -- For representation aspects, check for case of untagged derived - -- type whose parent either has primitive operations (pre Ada 2022), - -- or is a by-reference type (RM 13.1(10)). - -- Strictly speaking the check also applies to Ada 2012 but it is - -- really too constraining for existing code already, so relax it. - -- ??? Confirming aspects should be allowed here. - - if Is_Representation_Aspect (Get_Aspect_Id (N)) - and then Is_Derived_Type (Typ) - and then not Is_Tagged_Type (Typ) - then - Parent_Type := Etype (Base_Type (Typ)); - - if Ada_Version <= Ada_2012 - and then Has_Primitive_Operations (Parent_Type) - then - Error_Msg_N - ("|representation aspect not permitted before Ada 2022: " & - "use -gnat2022!", N); - Error_Msg_NE - ("\parent type & has primitive operations!", N, Parent_Type); - - elsif Is_By_Reference_Type (Parent_Type) then - No_Type_Rep_Item (N); - Error_Msg_NE - ("\parent type & is a by-reference type!", N, Parent_Type); - end if; - end if; - end Check_Aspect_Too_Late; - ------------------------------------- -- Make_Pragma_From_Boolean_Aspect -- ------------------------------------- @@ -11637,6 +11533,110 @@ package body Sem_Ch13 is end if; end Check_Aspect_At_Freeze_Point; + --------------------------- + -- Check_Aspect_Too_Late -- + --------------------------- + + procedure Check_Aspect_Too_Late (N : Node_Id) is + Typ : constant Entity_Id := Entity (N); + Expr : constant Node_Id := Expression (N); + + function Find_Type_Reference + (Typ : Entity_Id; Expr : Node_Id) return Boolean; + -- Return True if a reference to type Typ is found in the expression + -- Expr. + + ------------------------- + -- Find_Type_Reference -- + ------------------------- + + function Find_Type_Reference + (Typ : Entity_Id; Expr : Node_Id) return Boolean + is + function Find_Type (N : Node_Id) return Traverse_Result; + -- Set Found to True if N refers to Typ + + --------------- + -- Find_Type -- + --------------- + + function Find_Type (N : Node_Id) return Traverse_Result is + begin + if N = Typ + or else (Nkind (N) in N_Identifier | N_Expanded_Name + and then Present (Entity (N)) + and then Entity (N) = Typ) + then + return Abandon; + else + return OK; + end if; + end Find_Type; + + function Search_Type_Reference is new Traverse_Func (Find_Type); + + begin + return Search_Type_Reference (Expr) = Abandon; + end Find_Type_Reference; + + Parent_Type : Entity_Id; + + Save_In_Spec_Expression : constant Boolean := In_Spec_Expression; + Save_Must_Not_Freeze : constant Boolean := Must_Not_Freeze (Expr); + + begin + -- Ensure Expr is analyzed so that e.g. all types are properly + -- resolved for Find_Type_Reference. We preanalyze this expression + -- (to avoid expansion), handle it as a spec expression (like default + -- expression), disable freezing and skip resolution (to not fold + -- type self-references, e.g. T'Last). + + In_Spec_Expression := True; + Set_Must_Not_Freeze (Expr); + + Preanalyze (Expr); + + Set_Must_Not_Freeze (Expr, Save_Must_Not_Freeze); + In_Spec_Expression := Save_In_Spec_Expression; + + -- A self-referential aspect is illegal if it forces freezing the + -- entity before the corresponding aspect has been analyzed. + + if Find_Type_Reference (Typ, Expr) then + Error_Msg_NE + ("aspect specification causes premature freezing of&", N, Typ); + end if; + + -- For representation aspects, check for case of untagged derived + -- type whose parent either has primitive operations (pre Ada 2022), + -- or is a by-reference type (RM 13.1(10)). + -- Strictly speaking the check also applies to Ada 2012 but it is + -- really too constraining for existing code already, so relax it. + -- ??? Confirming aspects should be allowed here. + + if Is_Representation_Aspect (Get_Aspect_Id (N)) + and then Is_Derived_Type (Typ) + and then not Is_Tagged_Type (Typ) + then + Parent_Type := Etype (Base_Type (Typ)); + + if Ada_Version <= Ada_2012 + and then Has_Primitive_Operations (Parent_Type) + then + Error_Msg_N + ("|representation aspect not permitted before Ada 2022: " & + "use -gnat2022!", N); + Error_Msg_NE + ("\parent type & has primitive operations!", N, Parent_Type); + + elsif Is_By_Reference_Type (Parent_Type) then + No_Type_Rep_Item (N); + Error_Msg_NE + ("\parent type & is a by-reference type!", N, Parent_Type); + end if; + end if; + end Check_Aspect_Too_Late; + ----------------------------------- -- Check_Constant_Address_Clause -- ----------------------------------- @@ -16064,8 +16064,13 @@ package body Sem_Ch13 is -- before the actual freeze point. when Aspect_Default_Value => + Check_Aspect_Too_Late (ASN); Preanalyze_Spec_Expression (Expr, E); + when Aspect_Default_Component_Value => + Check_Aspect_Too_Late (ASN); + Preanalyze_Spec_Expression (Expr, Component_Type (E)); + when Aspect_CPU | Aspect_Interrupt_Priority | Aspect_Priority From patchwork Thu Aug 1 15:17:24 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: 1967891 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=b3bEmpnu; 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 4WZYLt4mKFz1yZv for ; Fri, 2 Aug 2024 01:49:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DD1E03864835 for ; Thu, 1 Aug 2024 15:49:56 +0000 (GMT) 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 2B92B385F018 for ; Thu, 1 Aug 2024 15:18:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B92B385F018 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 2B92B385F018 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=1722525510; cv=none; b=dHhi0VKAUx0yT0lzDPtC+9Eqvql5wRn7UVkN8D1hEh9twmeS9MRmgJn0GAs7m+oMIm3oF225lFM8AClmQEu5akBaT2Df3Dc4DHwUG4X0rMzFxcFgeXUqZKDaIEd/W9R2cJjRjKN9ZoCop6BwsgCSp2fKauwYScmqnHz3vV1VDAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525510; c=relaxed/simple; bh=XZn+hTQJ91l0yPcfS9C1bGpamDaHVKo5s0rZPH6mGMY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t9ZgIcq4NM4f+zfkpkdD9A/NaDUwN7/9P1OFPYFMn1NHRw9KuDyv1PPry2F40qK9nyzuQKkuKYRJnXN5CYIElecLAqdZuu3K4H6mQhxpfrJxnQW0ewCf6WF2wUlyqXCLqkujzTM41qyeppD/3nqb6vo1UCM/iTXTckPsrCHqb2o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-368663d7f80so3573425f8f.3 for ; Thu, 01 Aug 2024 08:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525503; x=1723130303; 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=BjswmohaYij33QNjcDgfo1qYHnRVFv0Vxahi63p+U6Q=; b=b3bEmpnu1j0H9zmGf6FP5FpJaldirnAs4DYQi5ff0TqEYhIUydWKTHGSB02XjKjx2l tAfz2tPuOhtcCCL2k4em51FVtji3Ys0Y8ZWfnAgep3rRa4HXnM3aTQDBaEEzgtOmsjVy G7/gzHjb5GTRg+w15gEaFJ+zVs9tqWYSVrLNZDDhUXjvBWkqheDNzv9XK5Iqrq7KlX9m Pe65274BT51hMQzJ60phZKD4nkWEe/lYEUeqw9z7P0f9x/6MrsiCHipoS6tCLbmQy6Pt ZDP/txzw34Q9KacMT414Z+d4Ko/d8nDweNvjzY3c1dksIr/cLykxLJn4A8S/19xSpHPI Th1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525503; x=1723130303; 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=BjswmohaYij33QNjcDgfo1qYHnRVFv0Vxahi63p+U6Q=; b=VkND6vrEwRd8KR/9MIgxkCpWDmw7T/IZVSJ1f3yRj7QoOql1LWhpeaytnjPsSseEgl OfVJFBWwJVMH5h4tKRwguS+v582Og7mYLoMR8cr4m4MkyekI45y2zAZuP1sQIy13Ctuh Beg0S6DZyFkOO9f19zcmsCgSLdQ1r8mVO+xuqOWSO5t3qXCMLH4BCe9ebxeZE3nOqnUL B1OIe0IKRkA2R/3hz8iW3JisJ86EQXAcxQhdsNb55P5TVseXzF8DO5ZOQq4CnCDYwdYr cNCLvLK6n89jxbqVINb/utWv46ZXDuN7mrQG5JxWnEd5X7FFE4e7+/mQWkc7N3OKmjtN ek4g== X-Gm-Message-State: AOJu0YzApaRSZ6xFWeUTFOUvUvArc/QlcPQt8K5nBXqj48H5l4bfCiTq UnAs4uJfiYktxSB54+y3/fh14BUnZYxGZYZkgHT6CDRW7hySX/55XPemz/9CdYNw6kGSPYPrfl3 wKA== X-Google-Smtp-Source: AGHT+IFuFs84O/7OU6nuGqhtpEGN4BCkXsUHltWf/N/72kNL4bwK9ugYI5wcIQC3mn7VWgzL48l+jg== X-Received: by 2002:a5d:5003:0:b0:368:3b1a:8350 with SMTP id ffacd0b85a97d-36bbc0c9a9amr161676f8f.19.1722525502762; Thu, 01 Aug 2024 08:18:22 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:22 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ghjuvan Lacambre Subject: [COMMITTED 16/30] ada: exp_pakd.adb: disable packed expansions in CodePeer_Mode Date: Thu, 1 Aug 2024 17:17:24 +0200 Message-ID: <20240801151738.400796-16-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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: Ghjuvan Lacambre A previous commit disabled the removal of the Component_Size aspect from GNAT's tree when in CodePeer_Mode. This effectively resulted in CodePeer not ignoring Component_Size anymore. As a side effect, GNAT started expanding packed operations on array types from their high-level representations to operations operating on bits. It wasn't caught during the original testing, but this actually confuses CodePeer. We thus need to disable expansion of packed operations while in CodePeer_Mode. gcc/ada/ * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Disable expansion in CodePeerMode. (Expand_Packed_Address_Reference): Likewise. (Expand_Packed_Bit_Reference): Likewise. (Expand_Packed_Boolean_Operator): Likewise. (Expand_Packed_Element_Reference): Likewise. (Expand_Packed_Eq): Likewise. (Expand_Packed_Not): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_pakd.adb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index 59dfe5df8df..00bf60ae406 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -1121,6 +1121,10 @@ package body Exp_Pakd is begin pragma Assert (Is_Bit_Packed_Array (Etype (Prefix (Lhs)))); + if CodePeer_Mode then + return; + end if; + Obj := Relocate_Node (Prefix (Lhs)); Convert_To_Actual_Subtype (Obj); Atyp := Etype (Obj); @@ -1507,6 +1511,11 @@ package body Exp_Pakd is Offset : Node_Id; begin + + if CodePeer_Mode then + return; + end if; + -- We build an expression that has the form -- outer_object'Address @@ -1546,6 +1555,11 @@ package body Exp_Pakd is Offset : Node_Id; begin + + if CodePeer_Mode then + return; + end if; + -- We build an expression that has the form -- (linear-subscript * component_size for each array reference @@ -1581,6 +1595,11 @@ package body Exp_Pakd is PAT : Entity_Id; begin + + if CodePeer_Mode then + return; + end if; + Convert_To_Actual_Subtype (L); Convert_To_Actual_Subtype (R); @@ -1744,6 +1763,11 @@ package body Exp_Pakd is Arg : Node_Id; begin + + if CodePeer_Mode then + return; + end if; + -- If the node is an actual in a call, the prefix has not been fully -- expanded, to account for the additional expansion for in-out actuals -- (see expand_actuals for details). If the prefix itself is a packed @@ -1907,6 +1931,11 @@ package body Exp_Pakd is PAT : Entity_Id; begin + + if CodePeer_Mode then + return; + end if; + Convert_To_Actual_Subtype (L); Convert_To_Actual_Subtype (R); Ltyp := Underlying_Type (Etype (L)); @@ -2004,6 +2033,11 @@ package body Exp_Pakd is Size : Unat; begin + + if CodePeer_Mode then + return; + end if; + Convert_To_Actual_Subtype (Opnd); Rtyp := Etype (Opnd); From patchwork Thu Aug 1 15:17:25 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: 1967863 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=JPDrqdtH; 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 4WZY9j2zKVz1ybV for ; Fri, 2 Aug 2024 01:42:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8F82E386546B for ; Thu, 1 Aug 2024 15:41:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id EEAF73861822 for ; Thu, 1 Aug 2024 15:18:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EEAF73861822 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 EEAF73861822 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; cv=none; b=dUGPsWm0WVGYwC1u+txOGrywlNQhqYJRwQlcgue37ReT9o0bpsFhwG19Flm2Qfxgbi8aKPn19yNJ8amlMzOlEAoiikakjOYmoPRWR+aJ5WVWDOdyVdlUWBZhtKZiUDfI935THPYOITIhUbE7A0TDZV2ZJ0VvoZLUv4FYEsYW8o4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525514; c=relaxed/simple; bh=O6EFumWvgSJTht9u+etN8d3EWAB6oRwQIsS8gI0rYwE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uE6S4WCq8eoWjvY/BM1KX5KVzMV0pw0/3ZtsxYkgNCMSE/PrDL73ygwB/uJ502zq6VMZ4uP4yMK+eJKoMyGW3iUdJ9h0/csO6f67DmV3LkSy+1k1terzXZRoz9gFFVNyWN5Uwc3itAYiR8HvysjIxj+jZIgSHgSgFHXmJcIBHYY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3687fb526b9so3455671f8f.0 for ; Thu, 01 Aug 2024 08:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525503; x=1723130303; 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=oiJq7kzQWv4FJjKgZQ8uTHzWGvrrGTlczTcr3dKT8Gs=; b=JPDrqdtHdIlgo/+4Gt9X6vRLqS0H2dNPp5SSKu2UYcMKbYN6G2vOhGPf4PWWZkR4do 5ij5hxFPOjbCofP9Dkpe5CCvxfZNsm1mD1Q9KuhvdatqMLYd1Yw5OAI3ZvfACq6Q5iEH EFIEfxbsK47mDdGx28XhekQxmcfxhK3R+zTkNDcoW28atM+tar9J2NtOhn9TxGAjtFOC qrNhcmnVCut8bcRvvV/1UG6aJNZoJu2dVdgGv1NcHNEZPK2UtovqX1c7kt+vEh8nQlOf n5eGU6F2C/4twfYB95PPCEG6w7vwE6dC2Bl8lasJljY9sROSabvSC0wrUUq0JfBJTGZC DltA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525503; x=1723130303; 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=oiJq7kzQWv4FJjKgZQ8uTHzWGvrrGTlczTcr3dKT8Gs=; b=p0xfpW0Bes30pt11odaWER7RaVteBWPS3p34Hkg+YtdvOZz+4dNHkKr2Dq5xqLoKQ8 y8sdAm9x16oc2ZWFkHwog7OocQGaQPy3WElRcMu+VUWW3G1/KsP7wnCvfgMAH331F+kR dBfm+CYEQilKuSD59JLJVkXEcGYUoKvZxV2Z8sW9SJ11ACyxB/Z24DZOMEnH/xNam4Lu Ch/fkqwCpFTTvqyGNxU8dlYFqlByfP6UuKMELDSEgeTMP1dSSo6KyY8mO68/KIFa0f6G 8qB40KkOzwVxGSwhrBV5QsMg3Owdn4dnwHF/79VepfIXIn3nER6rbBeer9AxPk2X22tn kx7w== X-Gm-Message-State: AOJu0Yyz7dhoFjrO65guMQHQ7wiKzMyIH4uVZBmten+vc7Jjid/nCY9j 6cVdrrd5b+W7LCI7MsKfRwKFgTJysm1bnzfiBOhqOkFnmR7K4PX+0e05hbUxxGCWmY0XP3y7dzU mOg== X-Google-Smtp-Source: AGHT+IHz+dGLhhZ6DWzFeKQ3jGGeHAILOb9R8jEbufLKR2xiI4gD1bmkk9woLLFX0jl2RlrkKHbOSg== X-Received: by 2002:a5d:5274:0:b0:367:8ff5:5858 with SMTP id ffacd0b85a97d-36bbc1d346dmr119894f8f.56.1722525503586; Thu, 01 Aug 2024 08:18:23 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:23 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Arnaud Charlet Subject: [COMMITTED 17/30] ada: Put back -G for binder Date: Thu, 1 Aug 2024 17:17:25 +0200 Message-ID: <20240801151738.400796-17-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> 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: Arnaud Charlet gcc/ada/ * bindgen.adb (Gen_Main): Put back support for -G * bindusg.adb (Display): Put back line for -G * opt.ads (CCG_Mode): Update doc * switch-b.adb (Scan_Binder_Switches): Put back support for -G Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/bindgen.adb | 1 + gcc/ada/bindusg.adb | 5 +++++ gcc/ada/opt.ads | 4 +++- gcc/ada/switch-b.adb | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb index cdfaa08d8a6..57c97d966c9 100644 --- a/gcc/ada/bindgen.adb +++ b/gcc/ada/bindgen.adb @@ -2113,6 +2113,7 @@ package body Bindgen is if Bind_Main_Program and then not Minimal_Binder and then not CodePeer_Mode + and then not CCG_Mode then WBI (" Ensure_Reference : aliased System.Address := " & "Ada_Main_Program_Name'Address;"); diff --git a/gcc/ada/bindusg.adb b/gcc/ada/bindusg.adb index e870c5f0e22..855fd16c930 100644 --- a/gcc/ada/bindusg.adb +++ b/gcc/ada/bindusg.adb @@ -133,6 +133,11 @@ package body Bindusg is Write_Line (" -F Force checking of elaboration Flags"); + -- Line for -G switch + + Write_Line + (" -G Generate binder file suitable for CCG"); + -- Line for -h switch Write_Line diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index cc3723e1daa..dd0c8b38954 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -261,7 +261,9 @@ package Opt is -- (switch -B) CCG_Mode : Boolean := False; - -- Set to True when running as CCG (either via -gnatceg or via -emit-c) + -- GNAT, GNATBIND + -- Set to True when running as CCG (implicitly, via -emit-c, or -G for the + -- binder) Check_Aliasing_Of_Parameters : Boolean := False; -- GNAT diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb index 7cc0b8f0e3d..729855bd5fe 100644 --- a/gcc/ada/switch-b.adb +++ b/gcc/ada/switch-b.adb @@ -362,6 +362,12 @@ package body Switch.B is Debugger_Level := 2; end if; + -- Processing for G switch + + when 'G' => + Ptr := Ptr + 1; + CCG_Mode := True; + -- Processing for h switch when 'h' => From patchwork Thu Aug 1 15:17:26 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: 1967866 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=TpSA0ex3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZYBq50Sbz1ybV for ; Fri, 2 Aug 2024 01:42:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F2F94386486F for ; Thu, 1 Aug 2024 15:42:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 62BF4385DDF8 for ; Thu, 1 Aug 2024 15:18:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 62BF4385DDF8 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 62BF4385DDF8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525515; cv=none; b=HXZwYBxHgmJHQYt0xWsYpBeDXcrafd6kyJ8hGx1Y0/ONa600lxKDNCy3J4ZLxTYuq8/8K18aIUy5cwKV45ZHRySQWcwsaIo3pFtyWjpquKHp/ucAT0dP7PFbUe2dTIY2nip9KA1vr2LqP9OX+t9edOPeXVHPpbfZbGDQ5a3Js+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525515; c=relaxed/simple; bh=OolCf0LQeJADVzSwnmeCXr9lLQB4EUzKL3kNos7kM4I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t5M70ryY6u2T9R0OJeToNfSSWKC3D3O3UL2dOabqqsG5KvSifoilDFo7hfStdIgeVfq1WAS8q/ytv0+/Dvw65eNsHozWsypkK1rRsRo01PQ2wJFj2XKGiNFnG5rGJg6asEoemMRNDbMg7Gh9FFSzEJvr7ZwuWV4p3JCbBHPafXU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3683178b226so3385325f8f.1 for ; Thu, 01 Aug 2024 08:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525505; x=1723130305; 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=mg4zfY0xtjJiXXT01/JC28gcaKUCdy6wNRsm8kWvWPU=; b=TpSA0ex3gNzOHjZzXRl1wxQ/40S33SeSu9OESlc4+qgCzvSt1g5LiE7nlUH9Or+5/T NeN/iHe3AK9LG8kGb5+Or5pDaWwu0OTt9MV83Bs3eVSFdrZlScCkOUee18xH6zN9H98m 8j/F7F278BZrQf4nwbbBtMqOZEGdRM1flecVlbkP+pk77z5nNGEHNLyvqhqcn56h2DER rMRri8lr+IIo+WemY23//9507F9buSH+i8krwrteH3zfnLXMcSmddXYvYbeytRReiFXt ySt6oxGJXpoqYdDdZ3rG579hSy16IvQ5eZf4dfTTQ1hVjNnbNcbnWhg3sfQFuE1AXDyK BRfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525505; x=1723130305; 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=mg4zfY0xtjJiXXT01/JC28gcaKUCdy6wNRsm8kWvWPU=; b=wcd26ncNj+a2J44zWTdtZwtpQAWldW5i0yMYuqNhub+zLXzb4qIeBW5ToaUP3Gh2N0 R2n2UoRHE3E51BnZKABVtSwfXtmeO4YJVwosCSajypzyWUKN7yQ12K6q4Mi7PXV3zuOG SjP/4FtDT28cVJtlKRHqito+HZG3ZpJKvO8r+PjIO0JsUXi8lLwb8C27Da4VTrfDFZpi 3zOk8Vrme8DxksDuYgKA2jhPf/yhmrTE4/G1ZmhmR/iGdlrwXlnbQ3xUfQ695LX7K/dj /SpFwN0pz9pwVx4zB4EQFye4wgmC2dB1mxn7jMazMk3631PShQmM73UBhpX9WVueIQ0d LyKg== X-Gm-Message-State: AOJu0YwhHlTHL3X/munNB0wZLLyw1umFpibQX1zH6kj039nxZwA3ZYBi 5Hdw6ZcOIELypNbd3VRQn/F96ZWR7T70TqrXJsD4oeC4AEEDPOrHDTYq7wUAmw5S9jSUmwFOeqA MwA== X-Google-Smtp-Source: AGHT+IGzbC+YUXLUPRa6hUCpiVwYdHwZqZ2HH1shd1IVMK0hCEgd7ZIH/d+Cv74YkJY4CXLT+kh1Pw== X-Received: by 2002:a5d:5f49:0:b0:368:6620:20ec with SMTP id ffacd0b85a97d-36bbc161330mr114692f8f.43.1722525504600; Thu, 01 Aug 2024 08:18:24 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:24 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 18/30] ada: Implement full relaxed finalization semantics for controlled objects Date: Thu, 1 Aug 2024 17:17:26 +0200 Message-ID: <20240801151738.400796-18-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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 These semantics state that the compiler is permitted to enforce none of the guarantees specified by the RM 7.6.1(14/1) and following subclauses, and to instead just let the exception be propagated upward. The guarantees impose a significant overhead in terms of complexity and run-time performance compared to similar constructs in other languages, and the goal is to reduce it significantly, if not eliminate it totally: for example, untagged record types declared with the Finalizable aspect, the relaxed finalization semantics and inline Initialize/Adjust/Finalize primitives, and used with abort disabled: pragma Restrictions (No_Abort_Statements); pragma Restrictions (Max_Asynchronous_Select_Nesting => 0); pragma Restrictions (No_Asynchronous_Control); should behave like simple C++ classes. The implementation morally boils down to undoing the changes made a few months ago to the support of finalization for controlled objects, i.e. to getting rid of the added linked list and the associated indirection for controlled objects with relaxed finalization semantics. But, in order to keep a unified processing for both kinds of controlled objects and not to bring back the issues addressed by the aforementioned changes, the work is split between the front-end and the code generator: the front-end drops the linked list and the code generator is in charge of eliminating the indirection with the help of the optimizer. gcc/ada/ * doc/gnat_rm/gnat_language_extensions.rst (Generalized Finalization): Update status. * einfo.ads (Has_Relaxed_Finalization): Add more details. * exp_ch4.adb (Process_Transients_In_Expression): Invoke Make_Finalize_Call_For_Node instead of building the call. * exp_ch5.adb (Expand_N_Assignment_Statement): Do not set up an exception handler around the assignment for a controlled type with relaxed finalization semantics. Streamline the code implementing the protection against aborts and do not use an At_End handler for a controlled type with relaxed finalization semantics. * exp_ch7.ads (Make_Finalize_Call_For_Node): New function. * exp_ch7.adb (Finalize_Address_For_Node): New function renaming. (Set_Finalize_Address_For_Node): New procedure renaming. (Attach_Object_To_Master_Node): Also attach the Finalize_Address primitive to the Master_Node statically. (Build_Finalizer): Add Has_Strict_Ctrl_Objs local variable. Insert back the body of the finalizer at the end of the statement list in the non-package case and restore the associated support code to that effect. When all the controlled objects have the relaxed finalization semantics, do not create a Finalization_Master and finalize the objects directly instead. (Processing_Actions): Add Strict parameter and use it to set the Has_Strict_Ctrl_Objs variable. (Process_Declarations): Make main loop more robust and adjust calls to Processing_Actions. (Make_Finalize_Address_Body): Mark the primitive as inlined if the type has relaxed finalization semantics. (Make_Finalize_Call_For_Node): New function. * sem_ch6.adb (Check_Statement_Sequence): Skip subprogram bodies. * libgnat/s-finpri.ads (Finalize_Object): Add Finalize_Address parameter. (Master_Node): Remove superfluous qualification. * libgnat/s-finpri.adb (Attach_Object_To_Node): Likewise. (Finalize_Master): Adjust calls to Finalize_Object. (Finalize_Object): Add Finalize_Address parameter and assert that it is equal to the component of the node. Use the Object_Address component as guard. (Suppress_Object_Finalize_At_End): Clear Object_Address component. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate. Tested on x86_64-pc-linux-gnu, committed on master. --- .../doc/gnat_rm/gnat_language_extensions.rst | 3 +- gcc/ada/einfo.ads | 18 +- gcc/ada/exp_ch4.adb | 6 +- gcc/ada/exp_ch5.adb | 39 +-- gcc/ada/exp_ch7.adb | 260 ++++++++++++++---- gcc/ada/exp_ch7.ads | 5 + gcc/ada/gnat_rm.texi | 5 +- gcc/ada/gnat_ugn.texi | 4 +- gcc/ada/libgnat/s-finpri.adb | 24 +- gcc/ada/libgnat/s-finpri.ads | 14 +- gcc/ada/sem_ch6.adb | 4 + 11 files changed, 287 insertions(+), 95 deletions(-) diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst index fc3ca5f7adf..feceff24e21 100644 --- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst +++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst @@ -590,8 +590,7 @@ Example: procedure Finalize (Obj : in out Ctrl); procedure Initialize (Obj : in out Ctrl); -As of this writing, the relaxed semantics for finalization operations are -only implemented for dynamically allocated objects. +As of this writing, the RFC is implemented except for the `No_Raise` aspect. Link to the original RFC: https://github.com/AdaCore/ada-spark-rfcs/blob/topic/finalization-rehaul/considered/rfc-generalized-finalization.md diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 0d839b9b691..e51ab691860 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -2026,8 +2026,22 @@ package Einfo is -- checks for infinite recursion. -- Has_Relaxed_Finalization [base type only] --- Defined in all type entities. Indicates that the type is subject to --- relaxed semantics for the finalization operations. +-- Defined in all type entities. Set only for controlled types and types +-- with controlled components. Indicates that the type is subject to the +-- relaxed semantics for the finalization operations. These semantics are +-- made up of two independent parts: +-- +-- 1. The compiler is permitted to perform no automatic finalization of +-- heap-allocated objects: Finalize is only called when the object is +-- explicitly deallocated, or when the object is assigned a new value. +-- As a consequence, no finalization collection is created for access +-- types designating the type, and no header is allocated in front of +-- heap-allocated objects of the type. +-- +-- 2. If an exception is raised out of the Adjust or Finalize procedures, +-- the compiler is permitted to enforce none of the guarantees given +-- by the RM 7.6.1(14/1) and following subclauses, and to instead just +-- let the exception be propagated upward. -- Has_Shift_Operator [base type only] -- Defined in integer types. Set in the base type of an integer type for diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 50c3cd430ce..371cb118243 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -14363,11 +14363,7 @@ package body Exp_Ch4 is pragma Assert (Present (Fin_Context)); Insert_Action_After (Fin_Context, - Make_Procedure_Call_Statement (Loc, - Name => - New_Occurrence_Of (RTE (RE_Finalize_Object), Loc), - Parameter_Associations => New_List ( - New_Occurrence_Of (Master_Node_Id, Loc)))); + Make_Finalize_Call_For_Node (Loc, Master_Node_Id)); end if; -- Mark the transient object to avoid double finalization diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 35c2628fe25..7ff54cb2c40 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -3203,14 +3203,12 @@ package body Exp_Ch5 is end if; -- We need to set up an exception handler for implementing - -- 7.6.1(18). The remaining adjustments are tackled by the - -- implementation of adjust for record_controllers (see - -- s-finimp.adb). - - -- This is skipped if we have no finalization + -- 7.6.1(18), but this is skipped if the type has relaxed + -- semantics for finalization. if Expand_Ctrl_Actions and then not Restriction_Active (No_Finalization) + and then not Has_Relaxed_Finalization (Typ) then L := New_List ( Make_Block_Statement (Loc, @@ -3245,29 +3243,32 @@ package body Exp_Ch5 is and then Abort_Allowed then declare - Blk : constant Entity_Id := - New_Internal_Entity - (E_Block, Current_Scope, Sloc (N), 'B'); AUD : constant Entity_Id := RTE (RE_Abort_Undefer_Direct); + HSS : constant Node_Id := Handled_Statement_Sequence (N); + + Blk_Id : Entity_Id; begin Set_Is_Abort_Block (N); - - Set_Scope (Blk, Current_Scope); - Set_Etype (Blk, Standard_Void_Type); - Set_Identifier (N, New_Occurrence_Of (Blk, Sloc (N))); + Add_Block_Identifier (N, Blk_Id); Prepend_To (L, Build_Runtime_Call (Loc, RE_Abort_Defer)); - Set_At_End_Proc (Handled_Statement_Sequence (N), - New_Occurrence_Of (AUD, Loc)); - -- Present the Abort_Undefer_Direct function to the backend - -- so that it can inline the call to the function. + -- Like above, no need to deal with exception propagation + -- if the type has relaxed semantics for finalization. - Add_Inlined_Body (AUD, N); + if Has_Relaxed_Finalization (Typ) then + Append_To (L, Build_Runtime_Call (Loc, RE_Abort_Undefer)); - Expand_At_End_Handler - (Handled_Statement_Sequence (N), Blk); + else + Set_At_End_Proc (HSS, New_Occurrence_Of (AUD, Loc)); + Expand_At_End_Handler (HSS, Blk_Id); + + -- Present Abort_Undefer_Direct procedure to the back end + -- so that it can inline the call to the procedure. + + Add_Inlined_Body (AUD, N); + end if; end; end if; diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index a6912f7ad48..044b14ad305 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -45,6 +45,7 @@ with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with GNAT_CUDA; use GNAT_CUDA; +with Inline; use Inline; with Lib; use Lib; with Nlists; use Nlists; with Nmake; use Nmake; @@ -574,6 +575,11 @@ package body Exp_Ch7 is -- conversion to the class-wide type in the case where the operation is -- abstract. + function Finalize_Address_For_Node (Node : Entity_Id) return Entity_Id + renames Einfo.Entities.Finalization_Master_Node; + -- Return the Finalize_Address primitive for the object that has been + -- attached to a finalization Master_Node. + function Make_Call (Loc : Source_Ptr; Proc_Id : Entity_Id; @@ -621,6 +627,11 @@ package body Exp_Ch7 is -- [Deep_]Finalize (Acc_Typ (V).all); -- end; + procedure Set_Finalize_Address_For_Node (Node, Fin_Id : Entity_Id) + renames Einfo.Entities.Set_Finalization_Master_Node; + -- Set the Finalize_Address primitive for the object that has been + -- attached to a finalization Master_Node. + ---------------------------------- -- Attach_Object_To_Master_Node -- ---------------------------------- @@ -915,6 +926,8 @@ package body Exp_Ch7 is Attribute_Name => Name_Unrestricted_Access), New_Occurrence_Of (Master_Node, Loc))); + Set_Finalize_Address_For_Node (Master_Node, Fin_Id); + Insert_After_And_Analyze (Master_Node_Ins, Master_Node_Attach, Suppress => All_Checks); end Attach_Object_To_Master_Node; @@ -1734,6 +1747,10 @@ package body Exp_Ch7 is Finalizer_Stmts : List_Id := No_List; -- The statement list of the finalizer body + Has_Strict_Ctrl_Objs : Boolean := False; + -- A general flag which indicates whether N has at least one controlled + -- object with strict semantics for finalization. + Has_Tagged_Types : Boolean := False; -- A general flag which indicates whether N has at least one library- -- level tagged type declaration. @@ -1805,11 +1822,12 @@ package body Exp_Ch7 is begin pragma Assert (Present (Decls)); - -- If the context contains controlled objects, then we create the - -- finalization master, unless there is a single such object: in - -- this common case, we'll directly finalize the object. + -- If the context contains controlled objects with strict semantics + -- for finalization, then we create the finalization master, unless + -- there is a single such object: in this common case, we'll directly + -- finalize the object. - if Has_Ctrl_Objs then + if Has_Strict_Ctrl_Objs then if Count > 1 then if For_Package_Spec then Master_Name := @@ -1900,15 +1918,41 @@ package body Exp_Ch7 is -- The default name is _finalizer else - -- Generation of a finalization procedure exclusively for 'Old - -- interally generated constants requires different name since - -- there will need to be multiple finalization routines in the - -- same scope. See Build_Finalizer for details. - Fin_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Name_uFinalizer)); + -- The visibility semantics of At_End handlers force a strange + -- separation of spec and body for stack-related finalizers: + + -- declare : Enclosing_Scope + -- procedure _finalizer; + -- begin + -- + -- procedure _finalizer is + -- ... + -- at end + -- _finalizer; + -- end; + + -- Both spec and body are within the same construct and scope, but + -- the body is part of the handled sequence of statements. This + -- placement confuses the elaboration mechanism on targets where + -- At_End handlers are expanded into "when all others" handlers: + + -- exception + -- when all others => + -- _finalizer; -- appears to require elab checks + -- at end + -- _finalizer; + -- end; + + -- Since the compiler guarantees that the body of a _finalizer is + -- always inserted in the same construct where the At_End handler + -- resides, there is no need for elaboration checks. + + Set_Kill_Elaboration_Checks (Fin_Id); + -- Inlining the finalizer produces a substantial speedup at -O2. -- It is inlined by default at -O3. Either way, it is called -- exactly twice (once on the normal path, and once for @@ -1974,7 +2018,7 @@ package body Exp_Ch7 is -- Abort_Undefer; -- Added if abort is allowed -- end Fin_Id; - -- If there are controlled objects to be finalized, generate: + -- If there are strict controlled objects to be finalized, generate: -- procedure Fin_Id is -- Abort : constant Boolean := Triggered_By_Abort; @@ -1991,7 +2035,10 @@ package body Exp_Ch7 is -- -- end Fin_Id; - if Has_Ctrl_Objs and then Count > 1 then + -- If there are only controlled objects with relaxed semantics for + -- finalization, only the are generated. + + if Has_Strict_Ctrl_Objs and then Count > 1 then Fin_Call := Make_Procedure_Call_Statement (Loc, Name => @@ -2099,7 +2146,7 @@ package body Exp_Ch7 is -- Raise_From_Controlled_Operation (E); -- end if; - if Has_Ctrl_Objs and Exceptions_OK and not For_Package then + if Has_Strict_Ctrl_Objs and Exceptions_OK and not For_Package then Append_To (Finalizer_Stmts, Build_Raise_Statement (Finalizer_Data)); end if; @@ -2149,10 +2196,53 @@ package body Exp_Ch7 is -- Non-package case else + -- Insert the spec for the finalizer. The At_End handler must be + -- able to call the body which resides in a nested structure. + + -- declare + -- procedure Fin_Id; -- Spec + -- begin + -- + -- procedure Fin_Id is ... -- Body + -- + -- at end + -- Fin_Id; -- At_End handler + -- end; + pragma Assert (Present (Decls)); Append_To (Decls, Fin_Spec); - Append_To (Decls, Fin_Body); + + -- When the finalizer acts solely as a cleanup routine, the body + -- is inserted right after the spec. + + if Acts_As_Clean and not Has_Ctrl_Objs then + Insert_After (Fin_Spec, Fin_Body); + + -- In other cases the body is inserted after the last statement + + else + -- Manually freeze the spec. This is somewhat of a hack because + -- a subprogram is frozen when its body is seen and the freeze + -- node appears right before the body. However, in this case, + -- the spec must be frozen earlier since the At_End handler + -- must be able to call it. + -- + -- declare + -- procedure Fin_Id; -- Spec + -- [Fin_Id] -- Freeze node + -- begin + -- ... + -- at end + -- Fin_Id; -- At_End handler + -- end; + + Ensure_Freeze_Node (Fin_Id); + Insert_After (Fin_Spec, Freeze_Node (Fin_Id)); + Set_Is_Frozen (Fin_Id); + + Append_To (Stmts, Fin_Body); + end if; end if; Analyze (Fin_Spec, Suppress => All_Checks); @@ -2227,11 +2317,13 @@ package body Exp_Ch7 is procedure Processing_Actions (Decl : Node_Id; - Is_Protected : Boolean := False); + Is_Protected : Boolean := False; + Strict : Boolean := False); -- Depending on the mode of operation of Process_Declarations, either -- increment the controlled object count or process the declaration. -- The Flag Is_Protected is set when the declaration denotes a simple - -- protected object. + -- protected object. The flag Strict is true when the declaration is + -- for a controlled object with strict semantics for finalization. -------------------------- -- Process_Package_Body -- @@ -2256,7 +2348,8 @@ package body Exp_Ch7 is procedure Processing_Actions (Decl : Node_Id; - Is_Protected : Boolean := False) + Is_Protected : Boolean := False; + Strict : Boolean := False) is begin -- Library-level tagged type @@ -2277,6 +2370,9 @@ package body Exp_Ch7 is else if Preprocess then Count := Count + 1; + if Strict then + Has_Strict_Ctrl_Objs := True; + end if; else Process_Object_Declaration (Decl, Is_Protected); @@ -2291,6 +2387,7 @@ package body Exp_Ch7 is Obj_Id : Entity_Id; Obj_Typ : Entity_Id; Pack_Id : Entity_Id; + Prev : Node_Id; Spec : Node_Id; Typ : Entity_Id; @@ -2301,10 +2398,13 @@ package body Exp_Ch7 is return; end if; - -- Process all declarations in reverse order + -- Process all declarations in reverse order and be prepared for them + -- to be moved during the processing. Decl := Last_Non_Pragma (Decls); while Present (Decl) loop + Prev := Prev_Non_Pragma (Decl); + -- Library-level tagged types if Nkind (Decl) = N_Full_Type_Declaration then @@ -2385,7 +2485,8 @@ package body Exp_Ch7 is and then not Has_Completion (Obj_Id) and then No (BIP_Initialization_Call (Obj_Id))) then - Processing_Actions (Decl); + Processing_Actions + (Decl, Strict => not Has_Relaxed_Finalization (Obj_Typ)); -- The object is of the form: -- Obj : Access_Typ := Non_BIP_Function_Call'reference; @@ -2403,7 +2504,10 @@ package body Exp_Ch7 is (Is_Non_BIP_Func_Call (Expr) and then not Is_Related_To_Func_Return (Obj_Id))) then - Processing_Actions (Decl); + Processing_Actions + (Decl, + Strict => not Has_Relaxed_Finalization + (Available_View (Designated_Type (Obj_Typ)))); -- Simple protected objects which use the type System.Tasking. -- Protected_Objects.Protection to manage their locks should @@ -2445,7 +2549,8 @@ package body Exp_Ch7 is and then Has_Simple_Protected_Object (Obj_Typ) and then not Restricted_Profile then - Processing_Actions (Decl, Is_Protected => True); + Processing_Actions + (Decl, Is_Protected => True, Strict => True); end if; -- Inspect the freeze node of an access-to-controlled type and @@ -2513,7 +2618,7 @@ package body Exp_Ch7 is Process_Package_Body (Proper_Body (Unit (Library_Unit (Decl)))); end if; - Prev_Non_Pragma (Decl); + Decl := Prev; end loop; end Process_Declarations; @@ -2556,15 +2661,15 @@ package body Exp_Ch7 is Obj_Typ := Available_View (Designated_Type (Obj_Typ)); end if; - -- If the object is a Master_Node, then nothing to do, except if it - -- is the only object, in which case we move its declaration, call - -- marker (if any) and initialization call, as well as mark it to - -- avoid double processing. + -- If the object is a Master_Node, then nothing to do, unless there + -- is no or a single controlled object with strict semantics, in + -- which case we move its declaration, call marker (if any) and + -- initialization call, and also mark it to avoid double processing. if Is_RTE (Obj_Typ, RE_Master_Node) then Master_Node_Id := Obj_Id; - if Count = 1 then + if not Has_Strict_Ctrl_Objs or else Count = 1 then if Nkind (Next (Decl)) = N_Call_Marker then Prepend_To (Decls, Remove_Next (Next (Decl))); end if; @@ -2575,15 +2680,16 @@ package body Exp_Ch7 is end if; -- Create the declaration of the Master_Node for the object and - -- insert it before the declaration of the object itself, except - -- for the case where it is the only object because it will play - -- the role of a degenerated master and therefore needs to be - -- inserted at the same place the master would have been. + -- insert it before the declaration of the object itself, unless + -- there is no or a single controlled object with strict semantics, + -- because it will effectively play the role of a degenerated master + -- and therefore needs to be inserted at the same place the master + -- would have been. else pragma Assert (No (Finalization_Master_Node (Obj_Id))); - -- For one object, use the Sloc the master would have had + -- In the latter case, use the Sloc the master would have had - if Count = 1 then + if not Has_Strict_Ctrl_Objs or else Count = 1 then Master_Node_Loc := Sloc (N); else Master_Node_Loc := Loc; @@ -2597,7 +2703,7 @@ package body Exp_Ch7 is Master_Node_Id, Obj_Id); Push_Scope (Scope (Obj_Id)); - if Count = 1 then + if not Has_Strict_Ctrl_Objs or else Count = 1 then Prepend_To (Decls, Master_Node_Decl); else Insert_Before (Decl, Master_Node_Decl); @@ -2839,9 +2945,9 @@ package body Exp_Ch7 is -- Now build the attachment call that will initialize the object's -- Master_Node using the object's address and type's finalization -- procedure and then attach the Master_Node to the master, unless - -- there is a single controlled object. + -- there is no or a single controlled object with strict semantics. - if Count = 1 then + if not Has_Strict_Ctrl_Objs or else Count = 1 then -- Finalize_Address is not generated in CodePeer mode because the -- body contains address arithmetic. So we don't want to generate -- the attach in this case. Ditto if the object is a Master_Node. @@ -2860,16 +2966,13 @@ package body Exp_Ch7 is Prefix => New_Occurrence_Of (Fin_Id, Loc), Attribute_Name => Name_Unrestricted_Access), New_Occurrence_Of (Master_Node_Id, Loc))); + + Set_Finalize_Address_For_Node (Master_Node_Id, Fin_Id); end if; -- We also generate the direct finalization call here - Fin_Call := - Make_Procedure_Call_Statement (Loc, - Name => - New_Occurrence_Of (RTE (RE_Finalize_Object), Loc), - Parameter_Associations => New_List ( - New_Occurrence_Of (Master_Node_Id, Loc))); + Fin_Call := Make_Finalize_Call_For_Node (Loc, Master_Node_Id); -- For CodePeer, the exception handlers normally generated here -- generate complex flowgraphs which result in capacity problems. @@ -2882,7 +2985,10 @@ package body Exp_Ch7 is -- to be live. That is what we are interested in, not what -- happens after the exception is raised. - if Exceptions_OK and not CodePeer_Mode then + if Has_Strict_Ctrl_Objs + and then Exceptions_OK + and then not CodePeer_Mode + then Fin_Call := Make_Block_Statement (Loc, Handled_Statement_Sequence => @@ -5079,11 +5185,7 @@ package body Exp_Ch7 is -- Then add the finalization call for the object Insert_After_And_Analyze (Insert_Nod, - Make_Procedure_Call_Statement (Loc, - Name => - New_Occurrence_Of (RTE (RE_Finalize_Object), Loc), - Parameter_Associations => New_List ( - New_Occurrence_Of (Master_Node_Id, Loc)))); + Make_Finalize_Call_For_Node (Loc, Master_Node_Id)); -- Otherwise generate a direct finalization call for the object @@ -7936,6 +8038,14 @@ package body Exp_Ch7 is Make_Handled_Sequence_Of_Statements (Loc, Statements => Stmts))); + -- If the type has relaxed semantics for finalization, the indirect + -- calls to Finalize_Address may be turned into direct ones and, in + -- this case, inlining them is generally profitable. + + if Has_Relaxed_Finalization (Typ) then + Set_Is_Inlined (Proc_Id); + end if; + Set_TSS (Typ, Proc_Id); end Make_Finalize_Address_Body; @@ -8134,6 +8244,62 @@ package body Exp_Ch7 is return New_List (Fin_Block); end Make_Finalize_Address_Stmts; + --------------------------------- + -- Make_Finalize_Call_For_Node -- + --------------------------------- + + function Make_Finalize_Call_For_Node + (Loc : Source_Ptr; + Node : Entity_Id) return Node_Id + is + Fin_Id : constant Entity_Id := Finalize_Address_For_Node (Node); + + Fin_Call : Node_Id; + Fin_Ref : Node_Id; + + begin + -- Finalize_Address is not generated in CodePeer mode because the + -- body contains address arithmetic. So we don't want to generate + -- the call in this case. + + if CodePeer_Mode then + return Make_Null_Statement (Loc); + end if; + + -- The Finalize_Address primitive may be missing when the Master_Node + -- is written down in the source code for testing purposes. + + if Present (Fin_Id) then + Fin_Ref := + Make_Attribute_Reference (Loc, + Prefix => New_Occurrence_Of (Fin_Id, Loc), + Attribute_Name => Name_Unrestricted_Access); + + else + Fin_Ref := + Make_Selected_Component (Loc, + Prefix => New_Occurrence_Of (Node, Loc), + Selector_Name => Make_Identifier (Loc, Name_Finalize_Address)); + end if; + + Fin_Call := + Make_Procedure_Call_Statement (Loc, + Name => + New_Occurrence_Of (RTE (RE_Finalize_Object), Loc), + Parameter_Associations => New_List ( + New_Occurrence_Of (Node, Loc), + Fin_Ref)); + + -- Present Finalize_Address procedure to the back end so that it can + -- inline the call to the procedure made by Finalize_Object. + + if Present (Fin_Id) and then Is_Inlined (Fin_Id) then + Add_Inlined_Body (Fin_Id, Fin_Call); + end if; + + return Fin_Call; + end Make_Finalize_Call_For_Node; + ------------------------------------- -- Make_Handler_For_Ctrl_Operation -- ------------------------------------- diff --git a/gcc/ada/exp_ch7.ads b/gcc/ada/exp_ch7.ads index 70b0a06af4b..22303d4c22f 100644 --- a/gcc/ada/exp_ch7.ads +++ b/gcc/ada/exp_ch7.ads @@ -222,6 +222,11 @@ package Exp_Ch7 is -- an address into a pointer and subsequently calls Deep_Finalize on the -- dereference. + function Make_Finalize_Call_For_Node + (Loc : Source_Ptr; + Node : Entity_Id) return Node_Id; + -- Create a call to finalize the object attached to the given Master_Node + function Make_Init_Call (Obj_Ref : Node_Id; Typ : Entity_Id) return Node_Id; diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 4feef7e1f9f..24c2fdd4f97 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -19,7 +19,7 @@ @copying @quotation -GNAT Reference Manual , Jun 27, 2024 +GNAT Reference Manual , Jul 29, 2024 AdaCore @@ -29529,8 +29529,7 @@ procedure Finalize (Obj : in out Ctrl); procedure Initialize (Obj : in out Ctrl); @end example -As of this writing, the relaxed semantics for finalization operations are -only implemented for dynamically allocated objects. +As of this writing, the RFC is implemented except for the @cite{No_Raise} aspect. Link to the original RFC: @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/topic/finalization-rehaul/considered/rfc-generalized-finalization.md} diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 80cfb41b983..ea1d2f9d71a 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -19,7 +19,7 @@ @copying @quotation -GNAT User's Guide for Native Platforms , Jun 24, 2024 +GNAT User's Guide for Native Platforms , Jul 29, 2024 AdaCore @@ -29670,8 +29670,8 @@ to permit their use in free software. @printindex ge -@anchor{d1}@w{ } @anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{ } +@anchor{d1}@w{ } @c %**end of body @bye diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb index 9767090cb4a..a6c9db341a4 100644 --- a/gcc/ada/libgnat/s-finpri.adb +++ b/gcc/ada/libgnat/s-finpri.adb @@ -138,7 +138,7 @@ package body System.Finalization_Primitives is Node : in out Master_Node) is begin - pragma Assert (Node.Object_Address = System.Null_Address + pragma Assert (Node.Object_Address = Null_Address and then Node.Finalize_Address = null); Node.Object_Address := Object_Address; @@ -310,7 +310,7 @@ package body System.Finalization_Primitives is if Master.Exceptions_OK then while Node /= null loop begin - Finalize_Object (Node.all); + Finalize_Object (Node.all, Node.Finalize_Address); exception when Exc : others => @@ -337,7 +337,7 @@ package body System.Finalization_Primitives is else while Node /= null loop - Finalize_Object (Node.all); + Finalize_Object (Node.all, Node.Finalize_Address); Node := Node.Next; end loop; @@ -361,16 +361,18 @@ package body System.Finalization_Primitives is -- Finalize_Object -- --------------------- - procedure Finalize_Object (Node : in out Master_Node) is - FA : constant Finalize_Address_Ptr := Node.Finalize_Address; + procedure Finalize_Object + (Node : in out Master_Node; + Finalize_Address : Finalize_Address_Ptr) + is + Addr : constant System.Address := Node.Object_Address; begin - if FA /= null then - pragma Assert (Node.Object_Address /= System.Null_Address); - - Node.Finalize_Address := null; + if Addr /= Null_Address then + Node.Object_Address := Null_Address; - FA (Node.Object_Address); + pragma Assert (Node.Finalize_Address = Finalize_Address); + Finalize_Address (Addr); end if; end Finalize_Object; @@ -407,7 +409,7 @@ package body System.Finalization_Primitives is procedure Suppress_Object_Finalize_At_End (Node : in out Master_Node) is begin - Node.Finalize_Address := null; + Node.Object_Address := Null_Address; end Suppress_Object_Finalize_At_End; ----------------------- diff --git a/gcc/ada/libgnat/s-finpri.ads b/gcc/ada/libgnat/s-finpri.ads index 851917b5924..a61a7d772ec 100644 --- a/gcc/ada/libgnat/s-finpri.ads +++ b/gcc/ada/libgnat/s-finpri.ads @@ -102,9 +102,15 @@ package System.Finalization_Primitives with Preelaborate is -- reverse of the order in which they were attached. Calls to the procedure -- with a Master that has already been finalized have no effects. - procedure Finalize_Object (Node : in out Master_Node); - -- Finalizes the controlled object attached to Node. Calls to the procedure - -- with a Node that has already been finalized have no effects. + procedure Finalize_Object + (Node : in out Master_Node; + Finalize_Address : Finalize_Address_Ptr); + -- Finalizes the controlled object attached to Node by generating a call to + -- Finalize_Address on it, which has to be equal to Node.Finalize_Address. + -- The weird redundancy is intended to help the optimizer turn an indirect + -- call to Finalize_Address into a direct one and then inline it if needed, + -- after having inlined Finalize_Object itself. Calls to the procedure with + -- a Node that has already been finalized have no effects. procedure Suppress_Object_Finalize_At_End (Node : in out Master_Node); -- Changes the state of Node to effectively suppress a call to Node's @@ -179,7 +185,7 @@ private type Master_Node is record Finalize_Address : Finalize_Address_Ptr := null; - Object_Address : System.Address := System.Null_Address; + Object_Address : System.Address := Null_Address; Next : Master_Node_Ptr := null; end record; diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 9b85d65862b..852055a3586 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -7103,6 +7103,10 @@ package body Sem_Ch6 is and then Exception_Junk (Last_Stm)) or else Nkind (Last_Stm) in N_Push_xxx_Label | N_Pop_xxx_Label + -- Don't count subprogram bodies, for example finalizers + + or else Nkind (Last_Stm) = N_Subprogram_Body + -- Inserted code, such as finalization calls, is irrelevant; we -- only need to check original source. If we see a transfer of -- control, we stop. From patchwork Thu Aug 1 15:17:27 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: 1967872 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=UDRhTSX3; 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 4WZYDb6rMCz1ybV for ; Fri, 2 Aug 2024 01:44:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 39058386484B for ; Thu, 1 Aug 2024 15:44:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id EDDF13858C78 for ; Thu, 1 Aug 2024 15:18:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EDDF13858C78 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 EDDF13858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525524; cv=none; b=sZ4BRvsTmGUW+nPAVdzG/E7u2H4mGuxjhVRvgNHx01HBFjc0+pPDCEHB8io5V0RkZh5xPNyBOMdDstamJbah8vva+YVEKVpKzfGZI/gUSBNszKEcujusTla2x3NL1hM0DMblPJnHsSVOfbxXjzZX81I/d/LMg9DsXZSSMJ4/dw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525524; c=relaxed/simple; bh=MkKiY+UxEJ6ezF75cNFEZw7gYIwMUPcs5pClPBRG3rc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MXEnAAVuGpEPCiaenA62zMaFmqd/0vwzPMjdHF02J3dHlTkOoNMn8HZ+ppWgQ0VPuzDlN/bEBTU6P+Rq6X1fuLXxixYle1R6VI45WIxISmrzCbtSywNY249EMFJTkFWNgPVTmabv0coZPfF0vpw0fVFvr/ca2pszKXy8hq1yce4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3687f8fcab5so3505027f8f.3 for ; Thu, 01 Aug 2024 08:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525505; x=1723130305; 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=N3ZkjFcL/z9sINf04e1bxbOn470tL9/TkSmz2JVHJlI=; b=UDRhTSX3/SHyqp0dItqCEdYJpxeCdjJ7r9m8kj75nXmnkzpL16XhIuWmi7HJ/kOdiF JNPO+f45N/JRb9QuFOMYDgvy+V4vI1lmx2gDT/LUCLdVHlIIYk1JVGFDgdjf0XM441fY kl5oUHV8pfFE9heUKCoNQEAu8cysBqSTdppDZZmaNx9i7TgZ088YBZi1wjpPzmUJT69j L+6sEtUQipL9vkT2UKmVJeA4G+O3z9axyR1sm7iiemgLJ3/jrd6RGTrugW14d1XnFSbh 7oLAgQphAGHVL53Qf3IQ1p9/FLG/dp4Wh4daU0gMCwv1UAj+JQMOjIPysZ8+YuowXqpK j7jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525505; x=1723130305; 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=N3ZkjFcL/z9sINf04e1bxbOn470tL9/TkSmz2JVHJlI=; b=sOhQFcP5fe8HVU3td6Tb9C8nySre+CJHcjoFCcEKXsYEcZo0c9jA1XB4y3cT/qXwN8 Y9djg3NZlXy0Pf3zxZ+wSoSuX7dNQ0tEGNf0iF83Jx/WkabEgoFysF1Nf73ZbAwlUh98 sw50pLgJVfB27tdBjrclKu+ZH0x4bCfMGqDuXz481VEkKVb81S6AOkJW7a6Z+LIHPuTZ 7N4kfeaOjjbIoxzr1U4q+QzaRq+RJ3JxIlMYuzKW6FWjpgghUDWYFhWnOndWPAMatNyU AFj216/Rl0ybHO83XEe60Kvlm4uGsdDV5wvg/vmF+It45h7IRBo7MmQ/oGhcZAuSNePE rj2g== X-Gm-Message-State: AOJu0Ywp2a6W/DJqV8FvpNl7S4qmybbYozV8iCdkQXiJPwBwPo18vHzt D1mcGwlrCDdO2/O201oXL21gWLu2Pqazrw/Cc9VJgkpwWOmJkVyQSXURNlxYeEIjxlRC+4bcLP/ BEw== X-Google-Smtp-Source: AGHT+IEDYV/5v9ywDsQeExZcuJPn5Odln+iyKmR528weCcKHh8FCLr9uuF0VX3eMeYeWOnIxcFJHWw== X-Received: by 2002:a5d:494f:0:b0:36b:8f94:e206 with SMTP id ffacd0b85a97d-36bbc0a84e6mr164808f8f.5.1722525505531; Thu, 01 Aug 2024 08:18:25 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:25 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 19/30] ada: Define No_Return flag only for subprograms Date: Thu, 1 Aug 2024 17:17:27 +0200 Message-ID: <20240801151738.400796-19-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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 ...instead of defining it for all entities. gcc/ada/ * einfo.ads (No_Return): Change description and adjust accordingly. * gen_il-gen-gen_entities.adb (Entity_Kind): Remove No_Return. (Subprogram_Kind): Add No_Return. (Generic_Subprogram_Kind): Likewise. * sem_ch6.adb (Analyze_Return_Statement): Adjust No_Return test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/einfo.ads | 6 +++--- gcc/ada/gen_il-gen-gen_entities.adb | 3 ++- gcc/ada/sem_ch6.adb | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index e51ab691860..95f524e6c21 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -3799,8 +3799,8 @@ package Einfo is -- pragma No_Component_Reordering applies. -- No_Return --- Defined in all entities. Set for subprograms and generic subprograms --- to which a valid aspect or pragma No_Return applies. +-- Defined in subprograms and generic subprograms. Set if a valid aspect +-- or pragma No_Return applies. -- No_Strict_Aliasing [base type only] -- Defined in access types. Set to direct the backend to avoid any @@ -4969,7 +4969,6 @@ package Einfo is -- Materialize_Entity -- Needs_Debug_Info -- Never_Set_In_Source - -- No_Return -- Overlays_Constant -- Referenced -- Referenced_As_LHS @@ -5579,6 +5578,7 @@ package Einfo is -- Is_Visible_Lib_Unit -- Is_Wrapper -- Needs_No_Actuals + -- No_Return -- Requires_Overriding (non-generic case only) -- Return_Present -- Returns_By_Ref diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb index 80b5925ebb8..2e0d51f6592 100644 --- a/gcc/ada/gen_il-gen-gen_entities.adb +++ b/gcc/ada/gen_il-gen-gen_entities.adb @@ -215,7 +215,6 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Needs_Activation_Record, Flag), Sm (Needs_Debug_Info, Flag), Sm (Never_Set_In_Source, Flag), - Sm (No_Return, Flag), Sm (Overlays_Constant, Flag), Sm (Prev_Entity, Node_Id), Sm (Referenced, Flag), @@ -985,6 +984,7 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Linker_Section_Pragma, Node_Id), Sm (Overridden_Operation, Node_Id), Sm (Protected_Body_Subprogram, Node_Id), + Sm (No_Return, Flag), Sm (Scope_Depth_Value, Unat), Sm (Static_Call_Helper, Node_Id), Sm (SPARK_Pragma, Node_Id), @@ -1193,6 +1193,7 @@ begin -- Gen_IL.Gen.Gen_Entities (Sm (Has_Out_Or_In_Out_Parameter, Flag), Sm (Is_Primitive, Flag), Sm (Next_Inlined_Subprogram, Node_Id), + Sm (No_Return, Flag), Sm (Overridden_Operation, Node_Id))); Cc (E_Generic_Function, Generic_Subprogram_Kind, diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 852055a3586..0988fad97e8 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -1937,8 +1937,8 @@ package body Sem_Ch6 is -- Check that pragma No_Return is obeyed. Don't complain about the -- implicitly-generated return that is placed at the end. - if No_Return (Scope_Id) - and then Kind in E_Procedure | E_Generic_Procedure + if Kind in E_Procedure | E_Generic_Procedure + and then No_Return (Scope_Id) and then Comes_From_Source (N) then Error_Msg_N From patchwork Thu Aug 1 15:17:28 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: 1967869 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=QTOxhjWk; 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 4WZYD01s77z1ybV for ; Fri, 2 Aug 2024 01:44:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4E12384AB67 for ; Thu, 1 Aug 2024 15:43:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 10E0F386102D for ; Thu, 1 Aug 2024 15:18:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10E0F386102D 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 10E0F386102D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::232 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525525; cv=none; b=X6Q0fRcsqCjEqpB04JX2Dpszo6PXPHek+AoDVAYfiJ+mgfQnwfFfK8AiniRyZBM8iYnVOHHJN27chxhjLzjalVFoorfSQ6uAYP9DgqQ3l0AVUAmDf8f7Gnke8Ib8l7IdXkNKkqj8KFScNFKlNYLVYEuOoUszSi3LIzZ/QnMlJpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525525; c=relaxed/simple; bh=adHY36GXP/dKwi6zjhcczGuvNZEI7uc74Zp/wABv4qw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=fVzPgxWW7Q1O1ue0IPRoouh9hH4FQeqUI0O01UPkAcHmJ7FAtrOaQvtDIBzJyplRcMUE5ooLv1mRcdklTumpYqCqhA6RRjSYrzRqjzBH8oa7lsdYY4qp4mM2wUaueGo2SCpKxsjDN3YkcmmXJbZ1TnkTMFbtEnomi1pJ1aN/zBc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2f035ae0fe0so82673561fa.3 for ; Thu, 01 Aug 2024 08:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525506; x=1723130306; 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=bk95nOA3j84b88bNM2e+NEXmPsznD57WTmyiHLpBIUo=; b=QTOxhjWkF1d0WFr03+PbnJeK/9/2GCfJH+Mq73eKOujM0d5K4QwrbRrVm77jHzsZvy NfgoNeIXKPuOxlQhl/gclU+cPddxHl6RFrUQt2bndJFYKPTVYgrOIMkkctW/TIG7wy6W WfjPWrHds2WtDa6IHmu82xmYmucSkoGquaOZXUFJku3LWE9wEotatYsKbo8109YoiJaa EJVNJN/lAa+zVFFMkLvvcJ0y55NBNt/YkLeyY5N9jo83x253kATypjrXhDuLIUjUMoMl /4o8ZvGUYYmjJ55A5Dt6BXUvWz80qc2XuQaEtX2jXyd7XBIfUX1FycN3sSvTZPwLVDmi XzjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525506; x=1723130306; 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=bk95nOA3j84b88bNM2e+NEXmPsznD57WTmyiHLpBIUo=; b=TLhi2xYzfrG6v+HewaN+raW7+y8Dxw1CUvspFDwMN9D00V8RRn25XOVIlwg7OmLIzl QO8IL0ay50TIkR1h5Ja39VyoPJ4gLTNkgHxPdqPN+V9WCBKYe+NKLt34ksOBrpc+2TlJ +vX4LzH37U1kuUrXsGqRhOitpxrZM9fowqZbuGotQeoi2l2hqtr8xmuFhYP4XlkOFFiR uAGKYlrV4OfN8rDM3SpLBGKT59hK3L8TqL6mshqD/LaxqHyLpes65ARLGkgfi/LkpPY4 0kOEikO4CV8c0ge6F56uJdS8xBwZTVCuPbuiE+zou/NMY6jm9NKptJFF+Qs8gykHdGDv BMag== X-Gm-Message-State: AOJu0Yxtnas06qA3qJKgLSABpt/GLhMMAdNDHMgWlPpRtOndnyftGWSU bNmG+VA9zla4ZkzCd0qHdQrbhGYNd3fgKfKScVahtcXcsciDd+OBlWs8vqw1C8a456Odw+63DyQ Ymw== X-Google-Smtp-Source: AGHT+IGumrBYd9JnfyuUmy4uq9iMLplIx5t76bp7viloeCL9W3NSpbnQ+deBtCwFvd5YrQQOlQ6kpw== X-Received: by 2002:a2e:90ca:0:b0:2ef:18a2:9deb with SMTP id 38308e7fff4ca-2f15aa95c5emr4118011fa.16.1722525506412; Thu, 01 Aug 2024 08:18:26 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:25 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 20/30] ada: Fix bug in resolution of Ghost_Predicate Date: Thu, 1 Aug 2024 17:17:28 +0200 Message-ID: <20240801151738.400796-20-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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: Bob Duff This patch fixes a failure of name resolution when a range attribute reference appears in a Ghost_Predicate and the ghost policy is Ignore. gcc/ada/ * sem_ch13.adb (Add_Predicate): Remove the premature "return;". Ghost code needs to be processed by later code in this procedure even when ignored; otherwise the second pass of name resolution fails much later. However, protect Set_SCO_Pragma_Enabled and Add_Condition with "if not Is_Ignored_Ghost_Pragma"; these parts should not happen if the ghost code is Ignored. * libgnat/interfac__2020.ads (Unsigned_8): Minor reformatting. * libgnat/interfac.ads (IEEE_Extended_Float): Minor comment improvement. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/interfac.ads | 2 +- gcc/ada/libgnat/interfac__2020.ads | 1 + gcc/ada/sem_ch13.adb | 12 +++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gcc/ada/libgnat/interfac.ads b/gcc/ada/libgnat/interfac.ads index b57264deb26..fe130d016ba 100644 --- a/gcc/ada/libgnat/interfac.ads +++ b/gcc/ada/libgnat/interfac.ads @@ -62,7 +62,7 @@ is -- such as SPARK or CodePeer. In the normal case Long_Long_Integer is -- always 64-bits so we get the desired 64-bit type. - type Unsigned_8 is mod 2 ** 8; + type Unsigned_8 is mod 2 ** 8; for Unsigned_8'Size use 8; type Unsigned_16 is mod 2 ** 16; diff --git a/gcc/ada/libgnat/interfac__2020.ads b/gcc/ada/libgnat/interfac__2020.ads index 0b5cc7d4339..cb20f34b0d7 100644 --- a/gcc/ada/libgnat/interfac__2020.ads +++ b/gcc/ada/libgnat/interfac__2020.ads @@ -227,6 +227,7 @@ is -- Note: it is harmless, and explicitly permitted, to include additional -- types in interfaces, so it is not wrong to have IEEE_Extended_Float -- defined even if the extended format is not available. + -- See RM-B.2(11). type IEEE_Extended_Float is new Long_Long_Float; diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index b903381e5de..171e516bf3d 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -10218,12 +10218,12 @@ package body Sem_Ch13 is if Is_Ignored_Ghost_Pragma (Prag) then Add_Condition (New_Occurrence_Of (Standard_True, Sloc (Prag))); - return; - end if; - -- Mark corresponding SCO as enabled + else + -- Mark corresponding SCO as enabled - Set_SCO_Pragma_Enabled (Sloc (Prag)); + Set_SCO_Pragma_Enabled (Sloc (Prag)); + end if; -- Extract the arguments of the pragma @@ -10257,7 +10257,9 @@ package body Sem_Ch13 is -- "and"-in the Arg2 condition to evolving expression - Add_Condition (Arg2_Copy); + if not Is_Ignored_Ghost_Pragma (Prag) then + Add_Condition (Arg2_Copy); + end if; end; end if; end Add_Predicate; From patchwork Thu Aug 1 15:17:29 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: 1967845 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=gcqzY08C; 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 4WZY443ZfBz1ybX for ; Fri, 2 Aug 2024 01:37:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 902B3386183A for ; Thu, 1 Aug 2024 15:37:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 9369D386181E for ; Thu, 1 Aug 2024 15:18:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9369D386181E 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 9369D386181E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525516; cv=none; b=G1EQfhDbw5Ni+QxslxrDwhG1oSQ84PwvGcdUasq7nsiqBMyBqJll7QC+MJ1MnqnpN7qGLEFHQUSAV7SQouygrd6yg/0RKlWcuGV9xptA1XQ+dvTxQy7TK0re6GAuAaf+TUAhwpqWo6T8i8zU7U0RBQ5n9gx/RTsUWdSUYlG+RRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525516; c=relaxed/simple; bh=y66Oqz9Ur2Rln+zS6iNONX9zeGiDyVSgrn4O9GHoB9Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AAIzDy6QqNA9Xz8LJamYldyC8ud/Y3ovIMslFXsLoRgPtg8V+slxfIiTbN33rhVGdfEPHRx/dYehMLsF6r7HITJHyDTQj1VFsE8G1sa0fNzLPNgC7Jq744YqjQWgsUoyUl07iqCpSrJrC4EZO34CDpttajg9sei/WOpVY49Ho2s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3686b285969so3549530f8f.0 for ; Thu, 01 Aug 2024 08:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525507; x=1723130307; 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=UIpBZhSXMx2wZaW20BhTia1O17cY6/RPNbkrxclPO0g=; b=gcqzY08CIFy0GeEkZhPSRTKHt45mxbgW6ehFVq/S5dwiBNEyx0W7NrIXuZUjqo2hzz 9QiSAaxeuXdJKzwX6jXIZXsyrFewaCjE1LtrqJN4Zn05u8nK96M6slDZVPorTGSdmn4x 3LiWnhyccdyspLFTYsZwEZSnfbYRrSeqDLUZ8fECgzP1ZLtt2RpZ/vkDHsXjZMR+ju1+ hLjeaIirLnpFjkW/OwGxcW4wjVt6XiI9n3MPR1Ey8yTtaWoAIGzZLZEZfzAoyG4/88wP ktDymRFEfEnLVGvMtHWiuMFGipCaIxshrIK551AIk0ZWdnrtE4/eVWiAOpQcYXbsZxdz vIsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525507; x=1723130307; 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=UIpBZhSXMx2wZaW20BhTia1O17cY6/RPNbkrxclPO0g=; b=Ou0BzN8noobtaTFPJgxLCBe8c3Hlbya9ffosH9TsIL4MxCHC+BGifOO0K34i74jlWw swUuSv67WLBPOHlAUrZCt78xbGrEPafr5+Om5xt2RGnCEam3mjb/cah2nE+2qqekD7Ra haoRl2dRktEcqKKryvetoZ9kiyoSsogBEdamnOrCyrizN3R2xCkDiMKj9FGFre84OjF+ KngyVTVCQ6a01VM9yIQrX8DhKeKeYfMuWNo3/+2qY0f3XiFYJ07q/+5z5Rp/ydJJaegd l2FBbKGcE0qAXehcUg4HEbFQGSChRr8udbipL09kS1hfCDiDAieOqAFASk4qZ0z5lPZT DKXg== X-Gm-Message-State: AOJu0Yydw83OOG6+jW68lkapomtObqMMGLPYmRdGoAn4Q//32O1xKkKi xohkubCcd7MzmXyA/u0Sv8frj8Fo5PX4JMX3qsX0FblRNpYHZ+XZg5PIb2AJn2Rvp6BWBMM7Qjn 2MA== X-Google-Smtp-Source: AGHT+IGoohWfcD9shnmuuiWzF7aoXsvAGsQsSrYKwAcIQv5fqnIM3rDuRQ5lwJHcgtLyPE/1ddKGMw== X-Received: by 2002:a5d:4844:0:b0:367:918e:a106 with SMTP id ffacd0b85a97d-36bbc1724e1mr128903f8f.59.1722525507230; Thu, 01 Aug 2024 08:18:27 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:26 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED 21/30] ada: Fix crash in quantified expression expansion Date: Thu, 1 Aug 2024 17:17:29 +0200 Message-ID: <20240801151738.400796-21-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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: Ronan Desplanques Before this patch, the compiler failed to handle the case where the for loop created by expansion of a quantified expression required cleanup handlers. gcc/ada/ * sem_ch5.adb (Analyze_Loop_Parameter_Specification): Fix test for expanded quantified expression context. (Is_Expanded_Quantified_Expr): New function. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch5.adb | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index ac8cd0821ff..6a479726e86 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -2823,6 +2823,9 @@ package body Sem_Ch5 is -- forms. In this case it is not sufficient to check the static -- predicate function only, look for a dynamic predicate aspect as well. + function Is_Expanded_Quantified_Expr (N : Node_Id) return Boolean; + -- Return Whether N comes from the expansion of a quantified expression. + procedure Process_Bounds (R : Node_Id); -- If the iteration is given by a range, create temporaries and -- assignment statements block to capture the bounds and perform @@ -2908,6 +2911,16 @@ package body Sem_Ch5 is end if; end Check_Predicate_Use; + --------------------------------- + -- Is_Expanded_Quantified_Expr -- + --------------------------------- + + function Is_Expanded_Quantified_Expr (N : Node_Id) return Boolean is + begin + return Nkind (N) = N_Expression_With_Actions + and then Nkind (Original_Node (N)) = N_Quantified_Expression; + end Is_Expanded_Quantified_Expr; + -------------------- -- Process_Bounds -- -------------------- @@ -3081,6 +3094,16 @@ package body Sem_Ch5 is DS_Copy : Node_Id; + Is_Loop_Of_Expanded_Quantified_Expr : constant Boolean := + Present (Loop_Nod) + and then (Is_Expanded_Quantified_Expr (Parent (Loop_Nod)) + -- We also have to consider the case where the loop was wrapped with + -- Wrap_Loop_Statement. + or else (Present (Parent (Loop_Nod)) + and then Present (Parent (Parent (Loop_Nod))) + and then Is_Expanded_Quantified_Expr + (Parent (Parent (Parent (Loop_Nod)))))); + -- Start of processing for Analyze_Loop_Parameter_Specification begin @@ -3271,10 +3294,7 @@ package body Sem_Ch5 is or else (Present (Etype (Id)) and then Is_Itype (Etype (Id)) - and then Present (Loop_Nod) - and then Nkind (Parent (Loop_Nod)) = N_Expression_With_Actions - and then Nkind (Original_Node (Parent (Loop_Nod))) = - N_Quantified_Expression) + and then Is_Loop_Of_Expanded_Quantified_Expr) then Set_Etype (Id, Etype (DS)); end if; From patchwork Thu Aug 1 15:17:30 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: 1967894 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=bA1Md37I; 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 4WZYQ20TGyz1ybV for ; Fri, 2 Aug 2024 01:52:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2BEFC3864818 for ; Thu, 1 Aug 2024 15:52:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 9EE7A385E441 for ; Thu, 1 Aug 2024 15:18:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9EE7A385E441 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 9EE7A385E441 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::232 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525525; cv=none; b=voLceMr7KkqtcBpOJyS+irzPb+m6n8KlscpLwxwBmc0NRUL71FQ0HStU763drXcQWG915EFP0F8gUuPIcGuhob0DDeecmB8dXsv3glicAzR1pL5mKLfOpuVfMx1cIFKw5A8xTVscwiGPkdnvSbYaxSDV1/8g7p1rtkBW3oVNsZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525525; c=relaxed/simple; bh=MsNRdWQc1tERvVnl4b07Wd7UwKq9i8QyeMGAILTqkec=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rKllxBuOHH4XtVQmY3BT2nyzwJFnig9CifOiIA+EUXXchZvf4u/GCDgvD3Pdwp3N1wfOIpGTkqL+gGcZEtCaHYgA+FdpvUTWjLej3Dio/8aUVQtGP+1X56YJ3znHnLomPkI8JYXMsWUqbN1NwTlDWLu5A3ota3Of2G5/tv//dO4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2f029e9c9cfso107826481fa.2 for ; Thu, 01 Aug 2024 08:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525508; x=1723130308; 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=sNRhagWmQFRCcZLuFZ8BBuMkiBLb46q998NQHJ91Uns=; b=bA1Md37IVfhb9llcTymYZc70kUkb+x8dEzrq0+ce/Mg/77WDZlljzmwiLHWbmu19jb /YxMMXMbusHbKGVGEc8bNzu/PFIqTr6S99IL7xAu5yGqdlaw2URwuY58krPgeORXcYyK HX7OF9OmlzgK7dYE72r1qrw/9AXMOPhJk7Yj2tf8wkkh6Psc3R3URzINGfvdHcKCeMTr OF1sqV4NVHKMJQJh3AbOAZx3i7ox6qPDkf4eqbdhDiX/hQqnPY82ktg/kjJD4td4IXt2 q+aZXtL5Ore1e6xbF/vBodqqswuIXJldmmvvMC+G+I0EvBOk8qr31sD/HckjHzoLqm9z ijcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525508; x=1723130308; 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=sNRhagWmQFRCcZLuFZ8BBuMkiBLb46q998NQHJ91Uns=; b=lmAGC5kBzc7RjzI958t4wN/f0RCu04rBVQZFMoZCDAT3v43fl7KP0x1X6Gbu7z6s1G ZV7pFCc2ZOYuGi6IcaOE95Lr1HpWAC06pRkq8wQ5N5DlLIa1IQ87LmtqCkfq5mfb2hPt ONdNoeYOKe+JQ99gejbp+yAf6bTULCvSKn6TzNESSPFy+yZmC0OD9N+UDRaLf+WG1hlB PKg0rUJ9k7vBTBTZ7yuslHW7Jaxwjq4ap63MZkKZU6JYrcmLFDmvT5V1FgAlpwJVDX5U wXo+dgiEMK+SROwuwnYnv9h9HMzgMmDo0Z8ck30LOuFM0e642yedGPCN9PbTeTiviwWO G9Jg== X-Gm-Message-State: AOJu0YxY/CtjpO+DrlZP6bLbXb3PrXH0WKJ5lAzddutXKBJA4DjIqyH9 X/UzgLf+CUsW29KpoBvT95PvOCngVcIvVtUsNEqCwr77KkkvNNF3c9INCemVmNUYO6KzBJEGMNs LNw== X-Google-Smtp-Source: AGHT+IHXYjnlgXotiaChfdzPPd18T0IOx2po5xJC/oMzUmNE7lbvCC49wKi5xB7kBC/ly2Zrugo93Q== X-Received: by 2002:a2e:9f16:0:b0:2ef:23af:f202 with SMTP id 38308e7fff4ca-2f15ab5d3b7mr4700151fa.46.1722525507992; Thu, 01 Aug 2024 08:18:27 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:27 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 22/30] ada: Use ?j? in Output_Obsolescent_Entity_Warnings messages Date: Thu, 1 Aug 2024 17:17:30 +0200 Message-ID: <20240801151738.400796-22-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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: Viljar Indus These messages are conditionally activated only when -gnatwj (Warn_On_Obsolescent_Feature) is activated. They should use the switch specific insertion character instead. gcc/ada/ * sem_warn.adb (Output_Obsolescent_Entity_Warnings): use the ?j? in warning messages. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_warn.adb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 91a57d521d1..ca385154cb4 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -3161,49 +3161,50 @@ package body Sem_Warn is elsif Nkind (P) = N_Procedure_Call_Statement then Error_Msg_NE - ("??call to obsolescent procedure& declared#", N, E); + ("?j?call to obsolescent procedure& declared#", N, E); -- Function call elsif Nkind (P) = N_Function_Call then Error_Msg_NE - ("??call to obsolescent function& declared#", N, E); + ("?j?call to obsolescent function& declared#", N, E); -- Reference to obsolescent type elsif Is_Type (E) then Error_Msg_NE - ("??reference to obsolescent type& declared#", N, E); + ("?j?reference to obsolescent type& declared#", N, E); -- Reference to obsolescent component elsif Ekind (E) in E_Component | E_Discriminant then Error_Msg_NE - ("??reference to obsolescent component& declared#", N, E); + ("?j?reference to obsolescent component& declared#", N, E); -- Reference to obsolescent variable elsif Ekind (E) = E_Variable then Error_Msg_NE - ("??reference to obsolescent variable& declared#", N, E); + ("?j?reference to obsolescent variable& declared#", N, E); -- Reference to obsolescent constant elsif Ekind (E) = E_Constant or else Ekind (E) in Named_Kind then Error_Msg_NE - ("??reference to obsolescent constant& declared#", N, E); + ("?j?reference to obsolescent constant& declared#", N, E); -- Reference to obsolescent enumeration literal elsif Ekind (E) = E_Enumeration_Literal then Error_Msg_NE - ("??reference to obsolescent enumeration literal& declared#", N, E); + ("?j?reference to obsolescent enumeration literal& declared#", + N, E); -- Generic message for any other case we missed else Error_Msg_NE - ("??reference to obsolescent entity& declared#", N, E); + ("?j?reference to obsolescent entity& declared#", N, E); end if; -- Output additional warning if present @@ -3213,7 +3214,7 @@ package body Sem_Warn is String_To_Name_Buffer (Obsolescent_Warnings.Table (J).Msg); Error_Msg_Strlen := Name_Len; Error_Msg_String (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); - Error_Msg_N ("\\??~", N); + Error_Msg_N ("\\?j?~", N); exit; end if; end loop; From patchwork Thu Aug 1 15:17:31 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: 1967877 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=iWAqvrXm; 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 4WZYFF5MQsz1ybV for ; Fri, 2 Aug 2024 01:45:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA03B384B063 for ; Thu, 1 Aug 2024 15:45:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 003D63861004 for ; Thu, 1 Aug 2024 15:18:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 003D63861004 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 003D63861004 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525534; cv=none; b=GTQtcaWux5mmZ1gpejbCmInaLXUePmiFtdIz+q9bE+R32zFyG7lR7ds7jjZ9vqUYRabmvuEgvJHk7ftkOMuCXzptLAJSXOzSGeYtFqx+WuOiCoYKexeh+f3AgCaVUD53Bou3n42iaR76nZ40fUgKR4lxBILyuGP00U1B/ywSd6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525534; c=relaxed/simple; bh=WEWAnnkr/qRZEh6qXp+ajMtiZS7NixLLZE31jI83hrM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=A0QpQl6eFKEdOWr/I9jTBCY4BNB5M0zwR9WPF4I0UDPs0IxEWD9x9kDbSdHXBa/LH7YeH6LFPanxcu6fGGVPu67BvkgyR1B3cqfEuUCf6bA0dUIBLpapBmhJYbXYP95w4zQ28B8/e1wmtXJViaThoB00kaGNdvEYJV7veRQqwlM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-368526b1333so1393370f8f.1 for ; Thu, 01 Aug 2024 08:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525510; x=1723130310; 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=nRzdxIa/QA0NdijEJN3jUJ6NKQlyBd0dtQugTdfWTC0=; b=iWAqvrXmD1RssZ7YKMUJodEdgujctOPedy/UzroCas1M8eVyYX1fUO6tbATti0hS0W TG28LaZgmRdRFViDUOPbnwKgYH/D44XrZ5p4f/7PfC58Ak0u9vsS4qGLw8+NTETdtejW jDuB2DsR7co+WYT2CB1OJJXlcZW9QJ7+z5FPrClQYKgt4P2ZWmrME1wFXUJZvbwfM1eS ttehzhDK4N3+3+xpGjhl8lxpbyXaL+KyYCWrMEY0Wg7c/LF44mzjShdB/j4O/G9cb2YF 72P8FC+udGva34lxvf38ZQUVDfO3X0hbYzDL7CQkZFUnj+E0/gjpFj7sqUon8uLjZLJO +05g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525510; x=1723130310; 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=nRzdxIa/QA0NdijEJN3jUJ6NKQlyBd0dtQugTdfWTC0=; b=ChWnJAh+zj7naev59fJgscdmKfYw8LNcAD0D4Mq04XF3mIjAEVLWrr2VqYnAIuMi4m FUZ+nWHFw1EYCKbgMIIKQRkbVZVTwLIjY0uBanbMZgnolRSw1Az8hZvp6OWrfw1BC+4y aEFfEd3oLFwTEI+VuOlvE38Hmckwh/iDHfQnj+I+FncZeapoktm4uF9+9Gg5PmYh2wso WAB2aGYUg2hBX3WL/aMMPwpmDQm+WvSBzRGwvPJ22JVnobjsyUHDi5zQWwJShMQmj/8S oLIoQK8WqY7CeDYLH4rp0YveKxNRvVzKbMYUfy38HVWbKfY4TJwPoPGEX3amGUedItnL 9M8A== X-Gm-Message-State: AOJu0YwUn3OO0eDlpw4mkaA1FE3wbR2gcUOPv8Q6c4hE4Q4WtAuKfwdA Jcz+OzwE5G+ltx37Q+B0sLf1CJJgczIMaLJ5w7xG9nyyQxg+yHNYWUrLLaAuK8etRbu2LthbIwv Q1w== X-Google-Smtp-Source: AGHT+IFbOn/XBH6zXLq/uPDEcPuzaorRZ7gq7oAEXoBHOwxRzEGizRKexC7rWw5LUc4lqQNvECrwkg== X-Received: by 2002:a5d:6d0f:0:b0:367:940b:b662 with SMTP id ffacd0b85a97d-36bbbeefe1cmr321779f8f.31.1722525509560; Thu, 01 Aug 2024 08:18:29 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:29 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 23/30] ada: Restrict string interpolation to single string literal Date: Thu, 1 Aug 2024 17:17:31 +0200 Message-ID: <20240801151738.400796-23-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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: Javier Miranda gcc/ada/ * par-ch2.adb (P_Interpolated_String_Literal): remove support of multi-line string literals. * doc/gnat_rm/gnat_language_extensions.rst: Update documentation. * gnat_rm.texi: Regenerate. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/doc/gnat_rm/gnat_language_extensions.rst | 16 ++-------------- gcc/ada/gnat_rm.texi | 16 ++-------------- gcc/ada/par-ch2.adb | 12 ++---------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst index feceff24e21..0f001c4aca9 100644 --- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst +++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst @@ -323,20 +323,8 @@ For example: f" a double quote is \" and" & f" an open brace is \{"); -Finally, a syntax is provided for creating multi-line string literals, -without having to explicitly use an escape sequence such as ``\n``. For -example: - -.. code-block:: ada - - Put_Line - (f"This is a multi-line" - "string literal" - "There is no ambiguity about how many" - "spaces are included in each line"); - -Here is a link to the original RFC : -https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.rst +Link to the original RFC: +https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.md Constrained attribute for generic objects ----------------------------------------- diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 24c2fdd4f97..b27bd627c17 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -29223,20 +29223,8 @@ Put_Line f" an open brace is \@{"); @end example -Finally, a syntax is provided for creating multi-line string literals, -without having to explicitly use an escape sequence such as @code{\n}. For -example: - -@example -Put_Line - (f"This is a multi-line" - "string literal" - "There is no ambiguity about how many" - "spaces are included in each line"); -@end example - -Here is a link to the original RFC : -@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.rst} +Link to the original RFC: +@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.md} @node Constrained attribute for generic objects,Static aspect on intrinsic functions,String interpolation,Curated Extensions @anchor{gnat_rm/gnat_language_extensions constrained-attribute-for-generic-objects}@anchor{448} diff --git a/gcc/ada/par-ch2.adb b/gcc/ada/par-ch2.adb index f09daeaba69..f249ae76023 100644 --- a/gcc/ada/par-ch2.adb +++ b/gcc/ada/par-ch2.adb @@ -224,7 +224,6 @@ package body Ch2 is function P_Interpolated_String_Literal return Node_Id is Elements_List : constant List_Id := New_List; - NL_Node : Node_Id; Saved_State : constant Boolean := Inside_Interpolated_String_Literal; String_Node : Node_Id; @@ -258,15 +257,8 @@ package body Ch2 is T_Right_Curly_Bracket; end; else - if Prev_Token = Tok_String_Literal then - NL_Node := New_Node (N_String_Literal, Token_Ptr); - Set_Has_Wide_Character (NL_Node, False); - Set_Has_Wide_Wide_Character (NL_Node, False); - - Start_String; - Store_String_Char (Get_Char_Code (ASCII.LF)); - Set_Strval (NL_Node, End_String); - Append_To (Elements_List, NL_Node); + if Prev_Token /= Tok_Right_Curly_Bracket then + Error_Msg_SC ("unexpected string literal"); end if; Append_To (Elements_List, Token_Node); From patchwork Thu Aug 1 15:17:32 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: 1967896 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=KHYYt86n; 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 4WZYS17202z1ybV for ; Fri, 2 Aug 2024 01:54:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 364493858408 for ; Thu, 1 Aug 2024 15:54:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id D272C385DDF7 for ; Thu, 1 Aug 2024 15:18:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D272C385DDF7 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 D272C385DDF7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525530; cv=none; b=WGI+YFMubnb5Wi3/v1iBWF8Gb4iEE9m+BvvNViBDIRigqpN5r8kcK8d/l6zX/jx1wOOjkOp29kSvjLK3s7SwjpsALYxBEoWGDbQ3kTNW42Kx/bdSadtgEYylPlm0NyvcYvx4G2HZLYkMcj75ztx9tshM3zz4YMlBwv7rtX150m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525530; c=relaxed/simple; bh=Lm7UxH9ilTpZlX0KL6gaCcbpsHCngZpY7MbjA7STq14=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=chhEm5ieSnCxJhNje2d3FCyYh+zF9likkyxTEUFczVUv2GwqXgeEY9CtT7JxzUt/yRc/G2tacRzn2+ZaeA/e3B/xrGlhaTguHvioxa4Yq8nz1L4bix21nDuE9xvSH7gaPBbfu237hF4pSQMjEv1FDkP87hGT5THwMLaMqfdK0gk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42817bee9e8so43783425e9.3 for ; Thu, 01 Aug 2024 08:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525510; x=1723130310; 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=65k0R1crsqwhUrUvk2w268l+EXbrlU6GHSruqte/f+A=; b=KHYYt86nSIL7vAaVptlkoldgsROu0NMA0Td58dKlOUUCnelLUZ9+NhdCVZkrkVoOgA 5RlElVQ6HtrB9XTcHUcxTW0XgCfEyi1/AX3I7kR9bL4ITsDR7b8pw3QQAMfyKtGtCm1N 0v5CWgIf2ShmgsNoAmOxQiNT+pzdCgFmiO3YKxddA7O/CAnX7D+lS2Ay89kHSiZB8v1q EIODiASlFX+W2B6WMltFRZZpfPJoBhnCsyZS0kzNgy12M/Sm3IevAy2YMU1tbmJ6Ur7R lbXVVZI/MBrfbiNPFXtg2kpfFitp3jqdBCW09rwiVZqpOVnp/0UUyxINSeCpuHXb7Le0 Si+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525510; x=1723130310; 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=65k0R1crsqwhUrUvk2w268l+EXbrlU6GHSruqte/f+A=; b=JBMxt+mfWZ5wKu/vz/EFxpNbroFukbN1UDGAQb0/Ofrrhi6m7FuyqOgZuEjGBafG6k z+7iM/C9QYIyLa1sZDlWTdb9EtjmCJfxByBCkXXlHVhp6geSSCFR2p3gfwJqST9XOSNc u3GBoI2qEDQPirQZ+krPkk+KUIbExWwkvOWWxaaY2Zptxp4yruWrIeiGPWrmwdg65DFk RsW0N+gayHqi69FPF7ZaqMawzfS+6Wd9WUSw8STw53ao8U2lJpC2ZAmB+ctfxgBhbJF0 DjcdegKRTvPyCQGWeJH5CGaVXakymmQHMJ8RWTZVxvnykIH5qjAUkhgQmM1YDw6VW4cr Z4Kw== X-Gm-Message-State: AOJu0YxjiGAOfHH6s8XujRa0vmuQSFRsoY98xIvujzutJ2+KpDv9ZBuT BC5q0DSu2Ma/9kpULlE/pE6B7mr70ICkm1D9hxohDAWe0LbNs9iFYlCO9h1PhRo9ZirE8jNKJVQ x9A== X-Google-Smtp-Source: AGHT+IHscVsBPLYKENRZJCAXePa56i9gHCDxV5adalAs4WWXRMCcJaZ1JhhXIPzWbFVfoICoDsrvew== X-Received: by 2002:a05:600c:3144:b0:426:51dc:f6cd with SMTP id 5b1f17b1804b1-428e6b3210emr1667695e9.18.1722525510392; Thu, 01 Aug 2024 08:18:30 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:29 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ghjuvan Lacambre Subject: [COMMITTED 24/30] ada: Style fixes: remove blank lines following 'begin' keywords Date: Thu, 1 Aug 2024 17:17:32 +0200 Message-ID: <20240801151738.400796-24-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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, WEIRD_QUOTING 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: Ghjuvan Lacambre The GNAT style guide specifies that there must not be blank lines after 'begin' keywords. gcc/ada/ * backend_utils.adb (Scan_Common_Back_End_Switch): Remove blank line. * errout.adb (Output_JSON_Message): Likewise. * erroutc.adb (Set_Msg_Char): Likewise. * exp_aggr.adb (Two_Dim_Packed_Array_Handled): Likewise. * exp_pakd.adb (Expand_Packed_Address_Reference): Likewise. (Expand_Packed_Bit_Reference): Likewise. (Expand_Packed_Boolean_Operator): Likewise. (Expand_Packed_Element_Reference): Likewise. (Expand_Packed_Eq): Likewise. (Expand_Packed_Not): Likewise. * exp_prag.adb (Build_Dim3_Declaration): Likewise. * exp_strm.adb (Build_Elementary_Input_Call): Likewise. * freeze.adb (Find_Aspect_No_Parts): Likewise. (Get_Aspect_No_Parts_Value): Likewise. * gen_il-gen.adb (Compile): Likewise. * gnat1drv.adb (Adjust_Global_Switches): Likewise. * gnat_cuda.adb (Expand_CUDA_Package): Likewise. * gnatchop.adb (Read_File): Likewise. * gnatls.adb (Get_Runtime_Path): Likewise. * make.adb (Binding_Phase): Likewise. * par-ch11.adb (P_Exception_Choice): Likewise. * par-ch5.adb (P_Loop_Parameter_Specification): Likewise. * par-ch6.adb (Is_Extended): Likewise. * sem_attr.adb (Check_Dereference): Likewise. * sem_ch12.adb (Build_Subprogram_Decl_Wrapper): Likewise. * sem_ch3.adb (Build_Itype_Reference): Likewise. * sem_prag.adb (Validate_Compile_Time_Warning_Errors): Likewise. * sem_res.adb (Resolve_Declare_Expression): Likewise. * sem_util.adb (Build_Default_Subtype): Likewise. * sprint.adb (Sprint_Paren_Comma_List): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/backend_utils.adb | 1 - gcc/ada/errout.adb | 1 - gcc/ada/erroutc.adb | 1 - gcc/ada/exp_aggr.adb | 1 - gcc/ada/exp_pakd.adb | 6 ------ gcc/ada/exp_prag.adb | 1 - gcc/ada/exp_strm.adb | 1 - gcc/ada/freeze.adb | 2 -- gcc/ada/gen_il-gen.adb | 1 - gcc/ada/gnat1drv.adb | 1 - gcc/ada/gnat_cuda.adb | 1 - gcc/ada/gnatchop.adb | 1 - gcc/ada/gnatls.adb | 1 - gcc/ada/make.adb | 1 - gcc/ada/par-ch11.adb | 1 - gcc/ada/par-ch5.adb | 1 - gcc/ada/par-ch6.adb | 1 - gcc/ada/sem_attr.adb | 1 - gcc/ada/sem_ch12.adb | 1 - gcc/ada/sem_ch3.adb | 1 - gcc/ada/sem_prag.adb | 1 - gcc/ada/sem_res.adb | 1 - gcc/ada/sem_util.adb | 1 - gcc/ada/sprint.adb | 1 - 24 files changed, 30 deletions(-) diff --git a/gcc/ada/backend_utils.adb b/gcc/ada/backend_utils.adb index 6f4b5878acb..3591cd19bbf 100644 --- a/gcc/ada/backend_utils.adb +++ b/gcc/ada/backend_utils.adb @@ -38,7 +38,6 @@ package body Backend_Utils is First : constant Positive := Switch_Chars'First + 1; Last : constant Natural := Switch_Last (Switch_Chars); begin - -- Recognize -gxxx switches if Switch_Chars (First) = 'g' then diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 1d82386099c..c6534fe2a76 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -2498,7 +2498,6 @@ package body Errout is -- Start of processing for Output_JSON_Message begin - -- Print message kind Write_Str ("{""kind"":"); diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb index aa9aac4774f..7a823cefe56 100644 --- a/gcc/ada/erroutc.adb +++ b/gcc/ada/erroutc.adb @@ -1162,7 +1162,6 @@ package body Erroutc is procedure Set_Msg_Char (C : Character) is begin - -- The check for message buffer overflow is needed to deal with cases -- where insertions get too long (in particular a child unit name can -- be very long). diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 2031d042fa5..59ed75e8d69 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -9636,7 +9636,6 @@ package body Exp_Aggr is -- One-dimensional subaggregate begin - -- For now, only deal with cases where an integral number of elements -- fit in a single byte. This includes the most common boolean case. diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index 00bf60ae406..3674d31bbab 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -1511,7 +1511,6 @@ package body Exp_Pakd is Offset : Node_Id; begin - if CodePeer_Mode then return; end if; @@ -1555,7 +1554,6 @@ package body Exp_Pakd is Offset : Node_Id; begin - if CodePeer_Mode then return; end if; @@ -1595,7 +1593,6 @@ package body Exp_Pakd is PAT : Entity_Id; begin - if CodePeer_Mode then return; end if; @@ -1763,7 +1760,6 @@ package body Exp_Pakd is Arg : Node_Id; begin - if CodePeer_Mode then return; end if; @@ -1931,7 +1927,6 @@ package body Exp_Pakd is PAT : Entity_Id; begin - if CodePeer_Mode then return; end if; @@ -2033,7 +2028,6 @@ package body Exp_Pakd is Size : Unat; begin - if CodePeer_Mode then return; end if; diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb index a9379025a6b..2c054d1b967 100644 --- a/gcc/ada/exp_prag.adb +++ b/gcc/ada/exp_prag.adb @@ -955,7 +955,6 @@ package body Exp_Prag is Third_Component : Entity_Id := Next_Entity (Second_Component); begin - -- Sem_prag.adb ensured that Init_Val is either a Dim3, an aggregate -- of three Any_Integers or Any_Integer. diff --git a/gcc/ada/exp_strm.adb b/gcc/ada/exp_strm.adb index 43deead525b..75b9d3c845b 100644 --- a/gcc/ada/exp_strm.adb +++ b/gcc/ada/exp_strm.adb @@ -455,7 +455,6 @@ package body Exp_Strm is Lib_RE : RE_Id; begin - -- Check first for Boolean and Character. These are enumeration types, -- but we treat them specially, since they may require special handling -- in the transfer protocol. However, this special handling only applies diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 9c533722985..cf7a22efcae 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -3168,7 +3168,6 @@ package body Freeze is Find_Aspect (Typ, Aspect_No_Parts); Curr_Aspect_Spec : Entity_Id; begin - -- Examine Typ's associated node, when present, since aspect -- specifications do not get transferred when nodes get rewritten. @@ -3235,7 +3234,6 @@ package body Freeze is Aspect_Spec : constant Entity_Id := Find_Aspect_No_Parts (Typ); begin - -- Return the value of the aspect when present if Present (Aspect_Spec) then diff --git a/gcc/ada/gen_il-gen.adb b/gcc/ada/gen_il-gen.adb index b4e10b91d3b..7e58a2c60f2 100644 --- a/gcc/ada/gen_il-gen.adb +++ b/gcc/ada/gen_il-gen.adb @@ -1022,7 +1022,6 @@ package body Gen_IL.Gen is -- Start of processing for Compute_Field_Offsets begin - -- Compute the number of types that have each field, weighted by the -- frequency of such nodes. diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index 6b6fbf3a174..b532aefcaaa 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -145,7 +145,6 @@ procedure Gnat1drv is -- Start of processing for Adjust_Global_Switches begin - -- -gnatd_U disables prepending error messages with "error:" if Debug_Flag_Underscore_UU then diff --git a/gcc/ada/gnat_cuda.adb b/gcc/ada/gnat_cuda.adb index b531c15d380..f601dd3ceb0 100644 --- a/gcc/ada/gnat_cuda.adb +++ b/gcc/ada/gnat_cuda.adb @@ -191,7 +191,6 @@ package body GNAT_CUDA is procedure Expand_CUDA_Package (N : Node_Id) is begin - -- If not compiling for the host, do not do anything. if not Debug_Flag_Underscore_C then diff --git a/gcc/ada/gnatchop.adb b/gcc/ada/gnatchop.adb index 6bb91b17615..3fbb751874e 100644 --- a/gcc/ada/gnatchop.adb +++ b/gcc/ada/gnatchop.adb @@ -984,7 +984,6 @@ procedure Gnatchop is Read_Ptr : File_Offset := 1; begin - loop This_Read := Read (FD, A => Buffer (Read_Ptr)'Address, diff --git a/gcc/ada/gnatls.adb b/gcc/ada/gnatls.adb index c52c1aea9c3..1e8dc858e29 100644 --- a/gcc/ada/gnatls.adb +++ b/gcc/ada/gnatls.adb @@ -1573,7 +1573,6 @@ procedure Gnatls is Last : Natural; begin - if Is_Absolute_Path (Path) then if Is_Directory (Path) then return new String'(Path); diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index cef24341135..19f20945986 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -3022,7 +3022,6 @@ package body Make is -- when gnatbind is invoked with -shared. begin - -- Check now for switch -shared for J in Binder_Switches.First .. Last_Arg loop diff --git a/gcc/ada/par-ch11.adb b/gcc/ada/par-ch11.adb index d4eefe817df..8b51fc7e5b3 100644 --- a/gcc/ada/par-ch11.adb +++ b/gcc/ada/par-ch11.adb @@ -163,7 +163,6 @@ package body Ch11 is function P_Exception_Choice return Node_Id is begin - if Token = Tok_Others then Scan; -- past OTHERS return New_Node (N_Others_Choice, Prev_Token_Ptr); diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb index 68c3025e3a0..6de9ef0089e 100644 --- a/gcc/ada/par-ch5.adb +++ b/gcc/ada/par-ch5.adb @@ -1745,7 +1745,6 @@ package body Ch5 is Scan_State : Saved_Scan_State; begin - Save_Scan_State (Scan_State); ID_Node := P_Defining_Identifier (C_In); diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb index 830e6bec83e..7fe43373535 100644 --- a/gcc/ada/par-ch6.adb +++ b/gcc/ada/par-ch6.adb @@ -1911,7 +1911,6 @@ package body Ch6 is Is_Extended : Boolean := False; begin - if Token = Tok_Identifier then Save_Scan_State (Scan_State); -- at identifier Scan; -- past identifier diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index d742e1075c0..5720e5e9357 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -2092,7 +2092,6 @@ package body Sem_Attr is procedure Check_Dereference is begin - -- Case of a subtype mark if Is_Entity_Name (P) and then Is_Type (Entity (P)) then diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 8714efe1461..6b98343aeeb 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -6296,7 +6296,6 @@ package body Sem_Ch12 is New_F : Entity_Id; begin - Subp := Make_Defining_Identifier (Loc, Chars (Formal_Subp)); Mutate_Ekind (Subp, Ekind (Formal_Subp)); Set_Is_Generic_Actual_Subprogram (Subp); diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 8787a904e9f..ce3fe18080d 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -10952,7 +10952,6 @@ package body Sem_Ch3 is is IR : constant Node_Id := Make_Itype_Reference (Sloc (Nod)); begin - -- Itype references are only created for use by the back-end if Inside_A_Generic then diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 784c9a49ae3..52d63cf4492 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -33950,7 +33950,6 @@ package body Sem_Prag is -- Start of processing for Validate_Compile_Time_Warning_Errors begin - -- These error/warning messages were deferred because they could not be -- evaluated in the front-end and they needed additional information -- from the back-end. There is no reason to run these checks again if diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 19e52260661..8a18430ff58 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -7687,7 +7687,6 @@ package body Sem_Res is -- Start of processing for Resolve_Declare_Expression begin - Decl := First (Actions (N)); while Present (Decl) loop diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 19941ae3060..032684f3ddb 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -1784,7 +1784,6 @@ package body Sem_Util is function Build_Default_Subtype_OK (T : Entity_Id) return Boolean is begin - if Is_Constrained (T) then -- We won't build a new subtype if T is constrained diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint.adb index 3f73006ad6e..ea16591608b 100644 --- a/gcc/ada/sprint.adb +++ b/gcc/ada/sprint.adb @@ -3780,7 +3780,6 @@ package body Sprint is Node_Exists : Boolean := False; begin - if Is_Non_Empty_List (List) then if Dump_Original_Only then From patchwork Thu Aug 1 15:17:33 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: 1967860 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=d+dM0eey; 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 4WZY7v4XLJz1ybV for ; Fri, 2 Aug 2024 01:40:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D2CE5384DEE3 for ; Thu, 1 Aug 2024 15:40:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 052AD3858430 for ; Thu, 1 Aug 2024 15:18:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 052AD3858430 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 052AD3858430 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525535; cv=none; b=d64Fa2OB5vchfCvAkdhWmHbi3+7qTbndL55x0ij1NFqG1EvVqS1JKA7S6jNphophak8ITJQRkUAOtEM5Yz4Anr1S4dqDcm79AotWn6LM94DqihFFJeX7L0S1Ya9/75vOyxdT1fbgheiml2D6rHoLBKF6ito35v3Am+7FnfKV8wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525535; c=relaxed/simple; bh=U1FhOFPElcaGZcgJOZgcXETufc0gQ3w7vnCHTx0TxhM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hmlkEGXHLQ+3kLcusWh9OeMJTUzLa3wzTdsssL2fnDkLa72Uc38djVUSWccB0BurJ/ZR40kuxlOpYYJUbbH8hChodivdLD2Z2myLQPeV6dAExURw/u0Q8kftV48b9n4HH0RiUH+e8UX6VZ7XgjGDp15bYQi/uB/zrqy6k1zsDRo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52f04150796so11642673e87.3 for ; Thu, 01 Aug 2024 08:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525511; x=1723130311; 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=RbPh7DVVo1KM5PLxS6ayGvb+LEogvz9Cp2JDezs71kU=; b=d+dM0eey/9hBxs0ZboO4ib6+OSZ+Zjvt/XN8ixBGv+nRvPpP6ZkNmZYdZm7GkEQ97r 4J79fVlaIIsLlmBdw4as9Y7SlYf9RXVqf1skF7SV//qK1TlIvjA5LfdxkZ9Po1eATMXX gLTbYWQK8FetTBSQzbrhiwNhotDVF74+wc59zzI+WEI6DxKRMB6uXYstGPDQj7WxYzyn bw9LtaaJ8+k2EUCuZVouMoU/S1+u6s0evpOEKiTfz4BnDOa3Lk4Hu41aRGtaI3rNROpQ kot6tAJlIl1JIjJ3DNM2M0+Nz+ycP7CX2eIxWUFbZXH5xyGIMHmHK4HePybyJ2aChFmt Z8qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525511; x=1723130311; 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=RbPh7DVVo1KM5PLxS6ayGvb+LEogvz9Cp2JDezs71kU=; b=wHCiiinMyGpNmHMIqy8zNtl8xAV2sUdwUCoSbmlnE1XFzS7+dvysZ5gmLD4zCkBtV4 QNNSgPcci4O9UBwtGpEylmKu3K1ath4zdI0cn6NCPQ2Qkqsbs22iHNaK2luwxClswznW ngWF6UCvBBFxpBgY7vv4+52vpojSEHyhUInQfg04uvEygEtFJ0WtsukyT3hfpK/963VF mW1DvgsjjaxHoByCYR1+v3eP9fBUNVtNJBMM0Z/g42C4nSq2JAXCfYI60Uyn1VTTsTGX n7vks+beu1R2CIbB+gr4KaHvnPLmdMa67+faWpoG4VhKsNDNX9wdnX1E75klx6FcRq0/ fXDQ== X-Gm-Message-State: AOJu0YwghNwFA2MtymJceSFfCDsmYImAJJ0hW1xjo1AO9zIfMB2RYtVl hh9NMRTqQTdz3VaciwhMS91d/Zy+Je/1mmDKZ+YGBwZb83ogM7pFUz0ba9CbCUmgaWi1FO71K4X rvQ== X-Google-Smtp-Source: AGHT+IF0OfH/PQSn/AVbkhf60nmlCX+9qICxDj6jOCZT7SaPn1v4poccrH17CI4rRqmRwywhkEXmQg== X-Received: by 2002:a05:6512:3502:b0:52e:7656:a0f4 with SMTP id 2adb3069b0e04-530bb3a35a9mr173587e87.41.1722525511269; Thu, 01 Aug 2024 08:18:31 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:30 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 25/30] ada: Deconstruct workarounds for quantified expressions in contracts Date: Thu, 1 Aug 2024 17:17:33 +0200 Message-ID: <20240801151738.400796-25-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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: Piotr Trojanek Apparently we can always safely set the type of a loop parameter from its discrete subtype definition. It looks like the conditional setting was only necessary when preconditions were expanded into dedicated procedures, but we no longer use this expansion. gcc/ada/ * sem_ch5.adb (Analyze_Loop_Parameter_Specification): Unconditionally set the type of loop parameter. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch5.adb | 46 ++------------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 6a479726e86..e4506036cc2 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -2823,9 +2823,6 @@ package body Sem_Ch5 is -- forms. In this case it is not sufficient to check the static -- predicate function only, look for a dynamic predicate aspect as well. - function Is_Expanded_Quantified_Expr (N : Node_Id) return Boolean; - -- Return Whether N comes from the expansion of a quantified expression. - procedure Process_Bounds (R : Node_Id); -- If the iteration is given by a range, create temporaries and -- assignment statements block to capture the bounds and perform @@ -2911,16 +2908,6 @@ package body Sem_Ch5 is end if; end Check_Predicate_Use; - --------------------------------- - -- Is_Expanded_Quantified_Expr -- - --------------------------------- - - function Is_Expanded_Quantified_Expr (N : Node_Id) return Boolean is - begin - return Nkind (N) = N_Expression_With_Actions - and then Nkind (Original_Node (N)) = N_Quantified_Expression; - end Is_Expanded_Quantified_Expr; - -------------------- -- Process_Bounds -- -------------------- @@ -3094,16 +3081,6 @@ package body Sem_Ch5 is DS_Copy : Node_Id; - Is_Loop_Of_Expanded_Quantified_Expr : constant Boolean := - Present (Loop_Nod) - and then (Is_Expanded_Quantified_Expr (Parent (Loop_Nod)) - -- We also have to consider the case where the loop was wrapped with - -- Wrap_Loop_Statement. - or else (Present (Parent (Loop_Nod)) - and then Present (Parent (Parent (Loop_Nod))) - and then Is_Expanded_Quantified_Expr - (Parent (Parent (Parent (Loop_Nod)))))); - -- Start of processing for Analyze_Loop_Parameter_Specification begin @@ -3276,28 +3253,9 @@ package body Sem_Ch5 is end if; Mutate_Ekind (Id, E_Loop_Parameter); - Set_Is_Not_Self_Hidden (Id); + Set_Etype (Id, Etype (DS)); - -- A quantified expression which appears in a pre- or post-condition may - -- be analyzed multiple times. The analysis of the range creates several - -- itypes which reside in different scopes depending on whether the pre- - -- or post-condition has been expanded. Update the type of the loop - -- variable to reflect the proper itype at each stage of analysis. - - -- Loop_Nod might not be present when we are preanalyzing a class-wide - -- pre/postcondition since preanalysis occurs in a place unrelated to - -- the actual code and the quantified expression may be the outermost - -- expression of the class-wide condition. - - if No (Etype (Id)) - or else Etype (Id) = Any_Type - or else - (Present (Etype (Id)) - and then Is_Itype (Etype (Id)) - and then Is_Loop_Of_Expanded_Quantified_Expr) - then - Set_Etype (Id, Etype (DS)); - end if; + Set_Is_Not_Self_Hidden (Id); -- Treat a range as an implicit reference to the type, to inhibit -- spurious warnings. From patchwork Thu Aug 1 15:17:34 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: 1967884 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=XaC3zGNb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZYGS4Y9Tz1yZv for ; Fri, 2 Aug 2024 01:46:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB8EB3864C6A for ; Thu, 1 Aug 2024 15:46:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id AA68E3857000 for ; Thu, 1 Aug 2024 15:18:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA68E3857000 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 AA68E3857000 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525535; cv=none; b=IEyBbeuvegaI0Bv4l3LogCrBAwZL0jcBtXmGV3YstSEdF0OOPeHljvvmLn+/4Cg6KxOw3d9C1ONfXUp3fK7LGiguFfoWJDDcXxK43unr9eziQclvZE113Vw+C2o4WNlampeaddzYGgxUAca5PtBNHS/A0QbFiBc001vdcUQtPLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525535; c=relaxed/simple; bh=Dk04Cqoq+ujX4NzxDxKcxP7EMpnH4Ze5ojGT4GIJN5E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=K8x/H/rX2+YTww8kJivNQPbmZdP+EX7YACt5KeIbbHUcDnNwl2c9poUAJYI7MVV1PT0ryLwCvTW3yyx1dlUs/soQK9wiMRApw2A45F1h35vmgj7+vFjn1S8+miwmrO4Gdau6+yVcMnsXWR1kaTko0Y4/5IMYCt62TTC1crZiMXs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2eeb1051360so78999911fa.0 for ; Thu, 01 Aug 2024 08:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525512; x=1723130312; 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=kqmOTNoCixyulKqaVuht9gzHT/sODshnz9m4EIGZmMc=; b=XaC3zGNbfF+nvNZ2y9F2ZPzDfkZlBmE1ns2O+Omh/u/gI5gPyQ4W0Jrrtdamp5Aqff RYcEL+DAnCmbMhMZjZ7C2DgQkfGf0CfjfJm3PS0xdFxap71znAqdRNEcKK7VO7zehZch DtkY/L3RhjELdZ8QZV0LxjvCY/fTXPVO8G1hJSXGyZk5H7TEFGTAVPKHyGkAJ22gcTdl rrSfbsZDL2+g+3VG4Wt6ye1Sgshg7z/z1GUqHW7Baeqcrp9bT1erKT/1W/+N4s/v+ijR kZ5uj7KgoJ03e5uak75jOBB6zMeCBEaf8KeSWfXgg1cblzQleN8vQ9/l/GjgfL71tVgi A3Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525512; x=1723130312; 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=kqmOTNoCixyulKqaVuht9gzHT/sODshnz9m4EIGZmMc=; b=g3QfcHMHFMNnZJhGE+2z5VXOkCAySakA9+KQ4vpPhy+xKj0cj57VbDY3/pNDX+NMEd MPzjR0B9wpebZpPLbqgVDPUj60wuoEgyhjRr/rSx2GUX14KEuaeDmyB51T66WA7U8e25 exhZfp7DHClCelTHnwxsqauCeyd5EKG4wiY4sroQdopvG0DqdSP/SVXf0Jg0OCcDDspf wUsX2s+f/UfXgeNH0k6m4k19yjQBSG7EK/TF0g7r8114rDTqnW+5jlNHjVY9h5WQAJJV J4TqpYejSGfnL3gYeQYht9DTqcvuF8ZRcIBtZ6h2vLMm50ljy2O45/k9iZKYNLCz3qAd PiGQ== X-Gm-Message-State: AOJu0Yz2gB3u5orY5oPV853pPJMig8sbm+TP1/YlEbKZT5XMPs4MjRby N+ij5zruLTIHcNoJb33kXzvuiBOpbQSWUXWnKjdKLM/9qWop7xWVpDOUlBv3x+UZiS3I3J9vo0C zDA== X-Google-Smtp-Source: AGHT+IEeAFxYAHQIRClHWgCq9XE/o7lOXpj1j42kZBZscMY1zfHyoJfrrRGGUxRw1hJjr2XZ1NtCwQ== X-Received: by 2002:a2e:868e:0:b0:2ef:2b08:1747 with SMTP id 38308e7fff4ca-2f15aa91609mr4741531fa.13.1722525512064; Thu, 01 Aug 2024 08:18:32 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:31 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 26/30] ada: Fix oversight in documentation of At_End_Proc Date: Thu, 1 Aug 2024 17:17:34 +0200 Message-ID: <20240801151738.400796-26-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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 It is documented for N_Subprogram_Body_Stub instead of N_Subprogram_Body. gcc/ada/ * sinfo.ads (N_Block_Statement): Move At_End_Proc to the end of slot list and alphabetize flag list. (N_Subprogram_Body): Add At_End_Proc. (N_Package_Body): Move At_End_Proc to the end of slot list. (N_Subprogram_Body_Stub): Remove At_End_Proc. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sinfo.ads | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 768bcc0de82..95fceb5b71b 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -5174,14 +5174,14 @@ package Sinfo is -- Handled_Statement_Sequence -- Activation_Chain_Entity -- Cleanup_Actions - -- Has_Created_Identifier - -- Is_Asynchronous_Call_Block - -- Is_Task_Allocation_Block + -- At_End_Proc (set to Empty if no clean up procedure) -- Exception_Junk + -- Has_Created_Identifier -- Is_Abort_Block + -- Is_Asynchronous_Call_Block -- Is_Initialization_Block + -- Is_Task_Allocation_Block -- Is_Task_Master - -- At_End_Proc (set to Empty if no clean up procedure) ------------------------- -- 5.7 Exit Statement -- @@ -5456,6 +5456,7 @@ package Sinfo is -- Handled_Statement_Sequence -- Activation_Chain_Entity -- Corresponding_Spec + -- At_End_Proc (set to Empty if no clean up procedure) -- Acts_As_Spec -- Bad_Is_Detected used only by parser -- Do_Storage_Check @@ -5693,8 +5694,8 @@ package Sinfo is -- Declarations -- Handled_Statement_Sequence (set to Empty if no HSS present) -- Corresponding_Spec - -- Was_Originally_Stub -- At_End_Proc (set to Empty if no clean up procedure) + -- Was_Originally_Stub -- Note: if a source level package does not contain a handled sequence -- of statements, then the parser supplies a dummy one with a null @@ -6726,7 +6727,6 @@ package Sinfo is -- Corresponding_Spec_Of_Stub -- Library_Unit points to the subunit -- Corresponding_Body - -- At_End_Proc (set to Empty if no clean up procedure) ------------------------------- -- 10.1.3 Package Body Stub -- From patchwork Thu Aug 1 15:17:35 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: 1967895 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=jI3reJzM; 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 4WZYR05DhTz1ybV for ; Fri, 2 Aug 2024 01:53:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0199B3861812 for ; Thu, 1 Aug 2024 15:53:31 +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 9039A385E82D for ; Thu, 1 Aug 2024 15:18:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9039A385E82D 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 9039A385E82D 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=1722525529; cv=none; b=HiThC7/E4sIC3ZPYauglidGnSHWWxbQ5Ue65rx1Kc5PfU1K8+TO2R+IOaD+LNWR9od2Xr0ySvlCFHdHrRV+V3/PCSlSvx6Z+z8p9OFqb7UhhtM9TQxRBTbUMc0MVxAisn5bHJiRzmRH+mOQ6f+PWUvGOLHmtX36mP75ONPH+0/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525529; c=relaxed/simple; bh=VbN41Y+oyeVhuVvpjNkyf1h/lrk3LTF4JQDcSn0NiHM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XBPIVQzXkyFjpnzsIFGv3pomHMmZ0GQru78CwO/jhgPaXYLizYT1s4FosASmIos/ie9H4DTa8vJQKHxIlb++w8K8oJ7Y4R0Rk23u6e4UMSk12iBQaSy7sHhHXG8X8YP50VXeGcf3Czmscf/boMk7EHKcY5Tmv92ye9S3OikZ9rk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2eeb1ba040aso114675191fa.1 for ; Thu, 01 Aug 2024 08:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525513; x=1723130313; 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=SroStRwg63+OIlIKoniJyssExedXkoVp33hjbpR9pFw=; b=jI3reJzM5olDRFsIKm/4Xs9lbsIPc/XYDvr01Ll7v4p16arl89g53NFolOLKDjuHeY AL5PHKHlwD2hS6KgFvNRiuNorLP9v4rWKamR6q+HTMFcLeUrmHAZk+3iMLzzeBpOQIG+ NfEG0TByzPGpeBLu5tl63Mj8nHb50dvAOJ7YYRNqE+jH0BLlRNAWHOoOLp+82hDz3o6x C0kCZpdCkC+7W6hs1Om10Z17sm2QjAs6OR4rFJS0gpFgMyIRU+KVbqrwXpYxXcNiZQPG gaPuBkn8DUBU460GloTmtXKhRzgs32gn0sSKs+IrCT0rLcddwxDvsJZvjAjVEcfdChy9 lPYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525513; x=1723130313; 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=SroStRwg63+OIlIKoniJyssExedXkoVp33hjbpR9pFw=; b=a+s4JRtc4q7NUZpmvZ07F+lIYZEQkSxkzW3ospqXm00gzR7WcSRMdplXCUwvPNkW+k hhw3/6OQ8WJHZYiFlMr/LjroXKmdhHgrK7FO7vbC/XMYxAgNXdz/VKXZBtPjWQH/OYn5 j5EGVSCR6SJO0o85wiZrjpqI0s+WGX590gwnBIfVxUTS7PQIsxmS9841SzOG9/PDQp25 RR1i5kUDQ4w/PPSgdd6f8sX8XIq9nx2E6sRrF3G4lP1LPl67/GdIRKjCFnUIbBc/BFfj 4Q6EaXCKvjvG5KH5zxW94N3bLWJbgfYRa02jB83kqR4cD/E+fFwabQ8R4fpiSEGUukcA t4yQ== X-Gm-Message-State: AOJu0YxtNs81oMFLdhSF6aQ8lpPsV96i98F8KXYahjZRhPGBmpsl1ZfS gLw/CUAT6Fr1CDCOo9/yxqwTCb4x3GG2NZlmZ26b1fgtC2Romnpji9Xy45saOUf9B1cx7EXRBbF 1Ng== X-Google-Smtp-Source: AGHT+IG9ACu61j3pp0aPDdzsHXxdEWzCyv7EfNZss63LgRxaopKqyGnNf7j+G+l/1eDOPMliiBDrbw== X-Received: by 2002:a2e:934b:0:b0:2ef:2dfd:15dc with SMTP id 38308e7fff4ca-2f15aa7191fmr4511091fa.9.1722525512908; Thu, 01 Aug 2024 08:18:32 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:32 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED 27/30] ada: Crash on access attribute with overloaded prefix denoting reference object Date: Thu, 1 Aug 2024 17:17:35 +0200 Message-ID: <20240801151738.400796-27-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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: Gary Dismukes The compiler fails to accept an access attribute where the prefix is the name of an object of a user-defined reference type, and is not prepared to deal with the possibility of overloaded prefixes other than subprogram cases. Such a prefix can either represent the reference object directly, or it can be interpreted as an implicit dereferencing of the object's reference value, depending on the expected type. Special handling for this kind of prefix is added alongside the normal handling for overloaded prefixes of access attributes. gcc/ada/ * sem_attr.adb (Resolve_Attribute, Attribute_*Access): Resolve overloaded prefixes that denote objects of reference types, determining whether to use the prefix object directly, or expand it as an explicit dereference. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_attr.adb | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 5720e5e9357..a5c90e3f36d 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -11267,7 +11267,42 @@ package body Sem_Attr is if Is_Overloaded (P) then Get_First_Interp (P, Index, It); while Present (It.Nam) loop - if Type_Conformant (Designated_Type (Typ), It.Nam) then + + -- Overloaded object names can occur when user-defined + -- references are involved. The prefix can be interpreted + -- as either just an object of the reference type, or an + -- implicit dereferencing of such an object. + + if Is_Object (It.Nam) then + if Covers (Designated_Type (Typ), Etype (It.Typ)) then + + -- If the interpretation is a discriminant for an + -- implicit dereference, then build the dereference + -- and resolve the rewritten attribute recursively. + + if Ekind (It.Nam) = E_Discriminant + and then Has_Implicit_Dereference (It.Nam) + then + Build_Explicit_Dereference + (P, Get_Reference_Discriminant (Etype (P))); + Resolve_Attribute (N, Typ); + + return; + end if; + + -- The prefix is definitely NOT overloaded anymore + -- at this point, so we reset the Is_Overloaded + -- flag to avoid any confusion when reanalyzing + -- the node. + + Set_Is_Overloaded (P, False); + Set_Is_Overloaded (N, False); + Generate_Reference (Entity (P), P); + + exit; + end if; + + elsif Type_Conformant (Designated_Type (Typ), It.Nam) then Set_Entity (P, It.Nam); -- The prefix is definitely NOT overloaded anymore at From patchwork Thu Aug 1 15:17:36 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: 1967889 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=VcLIk5Jt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZYHW5m3sz1yZv for ; Fri, 2 Aug 2024 01:47:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C485384AB72 for ; Thu, 1 Aug 2024 15:47:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 162D23860769 for ; Thu, 1 Aug 2024 15:18:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 162D23860769 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 162D23860769 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525541; cv=none; b=f6kuHz5fwDw1YSeuWT9S9bAHdVatnRZ7wP6HBpaUpIzoAVFnzqS18z2Twgdlyp/3V8Wd5pVLN5kVp84X/0HJ3mPve0DNeYNcjrjLBu360d8fq11o+E+AsYyNr64gRX1wiPPlRo1CGVEw0CS6Pfm6Gdi9HmbLINI1zvzdAta/uVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525541; c=relaxed/simple; bh=Ayrhf3oH7VTl9CxXLn+78yudrnOt+KRxJ1t7pMplxFg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=T8ZY4xkjbTkuJ2WCTerlT2Ycdwlfr6+aA8dFA3bwK2qo/wiKgMaw/tgff8aoHAfzeJZYMlJBN2Cc3Vb27j7tn3M6VojamI2jj1dfRCmN6iz2/LWkquPSUbHDSY+ETWKUatH1PW+1RjhEuVGAwEU8aUEARISwdn9x6JZ62aKl8Cw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3683178b226so3385430f8f.1 for ; Thu, 01 Aug 2024 08:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525514; x=1723130314; 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=oWqYrLfWlCgO1EiU/6bZBQYbcnT/xRrSe82/e7bc0ME=; b=VcLIk5Jtmy2aaGeysBdttphGs3d7JSGi2bt5CBjm/WrkLb6RIPtrTrgUuKDlOyxsUx CQtI6jlR3ilzcfZIIy5KHkC4byNZwZmw4YXRPMMTpov78eK4S8R40gCYhtI9JBLMAxGl soTIRVAvxjmZS/2MrohP5YUiiRklVyk3PHADPzYNUmsOzV6UMhh3tQkMSm6U+XAozANf 0a/Dy05gRBkUV0t5lKvrxzVGSYz4/bHHB4KRxpbo9DJpNTLMgusdXnizrLzoTCF1ZJQx 97pzHpTAcKt++eynp1PlMJnJqpb/OIG4c0xHCEC5Trlqg8Csxyj+2dr/v1vdZKCBunj8 TqSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525514; x=1723130314; 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=oWqYrLfWlCgO1EiU/6bZBQYbcnT/xRrSe82/e7bc0ME=; b=wgqDAWiqbmid1eaYkgo1KegtdVWQ3vySq7iGX19gMQJ1zJAG3oNX3028ynWoFmGTEU jmlmPtDyayzoGuBC3+NyG4GcMnq4qlZgk1r1gak+LAznCxVWk0OF9ik4RqUFhGXsKA4I hrcdW5xyIRhxLAgtg+AEPwgSnV/h0lIrVpaK0gHqbBvQuqWh8o38T1d5RK0CxBwL6MMi 620d4mrUGjdCa1vgKGKYLeSJ6WTx9J3aj2pCVYuPen3XePiKFe5Ond2YEYQrsXyCV727 P0PTkTaBH/eTQADuZ/NA2XOMVjaAvSbHMkOApVVew23GbnJBGsGllAdoON7D2JAmHRaW BdVw== X-Gm-Message-State: AOJu0Yxih9vYtfIAidDPb60U1ZAbjKoWkixC2lbwknecxWfmEszFeJiw crTMQxEfru58k1l/oFPuLC/TrVFY0ACT13W2KM2bkokviGN2DO5kNcsnWohzd1KOArjv8zhKIgh PVw== X-Google-Smtp-Source: AGHT+IEJ8XAQOPu1GLY+eh74P1MAwU3qSZlQqiSD/aJdRdWnO9Sj7ZDuVBZMXS+rL4dNCWEytx6SNg== X-Received: by 2002:a5d:4003:0:b0:368:4edc:611e with SMTP id ffacd0b85a97d-36bbc0db7c9mr130135f8f.14.1722525513646; Thu, 01 Aug 2024 08:18:33 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:33 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 28/30] ada: Accept duplicate SPARK_Mode pragmas in configuration files Date: Thu, 1 Aug 2024 17:17:36 +0200 Message-ID: <20240801151738.400796-28-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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: Piotr Trojanek For consistency, we now accept duplicate SPARK_Mode pragmas in configuration files just like we accept other duplicate pragas there. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Don't check for duplicate SPARK_Mode pragmas in configuration files. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 52d63cf4492..e41fb2f8618 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -24758,14 +24758,6 @@ package body Sem_Prag is if No (Context) then Check_Valid_Configuration_Pragma; - - if Present (SPARK_Mode_Pragma) then - Duplication_Error - (Prag => N, - Prev => SPARK_Mode_Pragma); - raise Pragma_Exit; - end if; - Set_SPARK_Context; -- The pragma acts as a configuration pragma in a compilation unit From patchwork Thu Aug 1 15:17:37 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: 1967849 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=d2eQi1oQ; 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 4WZY5C4TNDz1ybX for ; Fri, 2 Aug 2024 01:38:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF69E386182A for ; Thu, 1 Aug 2024 15:38:05 +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 33A7E386102B for ; Thu, 1 Aug 2024 15:18:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33A7E386102B 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 33A7E386102B 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=1722525531; cv=none; b=bmRU9jB7TRtznnqWvSOpQBteujivGracNkf1oqvYxvMcnMC1HqQASjqQLYeOSCDmdNZ0gZ50iMbCQyi4sBYCtTbhO1uRu+pmzNHM1k0KDQZsSqxyGzkull+REd6gbiiWL8wJOUPXdrEWkwgbbgSohgxs5TRIhzLUECOh3qxl9gU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525531; c=relaxed/simple; bh=sB1ev/kznnIZ8dPp2w6f+FbyyjgnvncbQiK0q4tdn/I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Wz2KvfVVql2Q+f3s5t9y2kY/4AJl2TazSJGKezM3uTdFzXZfXejz8vuCxJkMCaMTRKirjCvKtr5kWpipE7CMHy53c8i23n+n0Zt5des6E4zDwWkt/DKZBOUOQIq08xumikEJgQftNtCT/3mDIQ/svgRi5wZqOMVe+szFC55PAx4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2ef27bfd15bso93965631fa.2 for ; Thu, 01 Aug 2024 08:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525515; x=1723130315; 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=K2at1y8a+bzlT3ZhXVnJnKU//8DgDrof8NZ6DYfrzS8=; b=d2eQi1oQlxgGFoYYAsb0mN8cXr/jX44xOyzBaL2+QXojzNAZB7AsYWYG4Mptt6Pdm9 VpFmwhwM1nkpG0FGC1xKXDZ9SI4f7MFBBcDIjtoeXbuxgXGuPTm9Fn78zepkf+9GSB1w W/++iq0fuhNPz577Wgujq8jqy/TArKI2pvDx09J08CsxkzWTKmsee0JpvVaMXVZFz51V LUq8HcDp+zH0PUG67IywH4jyWk488zXjpmEr2oahFG/UtaQul6Z9GZ8w0r+jGqcW9xSf 2XSXgO79x9D8zeW/jvG3SABcwVISThgI5qJgQCn/PLW65KTFY1xi5rNiU8dZz3BpN7mM EwMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525515; x=1723130315; 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=K2at1y8a+bzlT3ZhXVnJnKU//8DgDrof8NZ6DYfrzS8=; b=w/zu0/BEEb1aL9wzFD7UeHzAz/xzS9snJ5+qrPAMzI2jofCEdRBzw9R4JJJcLgzCOY RlG6xerGGsn51jJxC2vxNfEb9nMnvEjm/5wDRQUjFrxDTfLIn/iGVoCPR06hPPV7cOgh IZ/QZ8EbiJBgnF2z3kFpxHDBwvpuFaEEWQE6JK9h0d8P7KDIjL2Wgsi1Sabw8AJNxNB8 INdGx6LZxyVcPu7B6HFNYfslDudtGOEhABX6yPdus9oSPNDi+ikVzVj1TC+ojghpwMY/ 3DlzlfY4urCDsQzxudUws8k9BbcBeXv3iHBhVu30dQ8iJ6qVdAkxqsCAjRQ5CFs28iO3 O1Lg== X-Gm-Message-State: AOJu0YzNZHcBc7Z+8Vnm65n8vnUM/YnV95CMABsg/IAH1EwPMUX3qOl4 FyTe9PIjyehMMI/rgXt/pTCqYS2EFVh9k2bJt60AUS2BUx1K3e2mOwAy9ompcuY3RI/t55r67fk nog== X-Google-Smtp-Source: AGHT+IFt9cC5vQTg6sHr0HjlXHK5D5MSHrcpiQJiSY7i45cqVmkgJ1M9+uqLnxh8XLaz32+XNA0UHA== X-Received: by 2002:a2e:2e0f:0:b0:2ef:18b7:440b with SMTP id 38308e7fff4ca-2f15aa916f0mr4787181fa.12.1722525514418; Thu, 01 Aug 2024 08:18:34 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:33 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [COMMITTED 29/30] ada: Update contracts on Strings libraries Date: Thu, 1 Aug 2024 17:17:37 +0200 Message-ID: <20240801151738.400796-29-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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: Yannick Moy The contracts of Ada.Strings.Bounded.To_String and Ada.Strings.Fixed.Delete are updated to reflect the standard spec and to allow proof of callers. gcc/ada/ * libgnat/a-strbou.ads (To_String): Add a postcondition to state the value of bounds of the returned string, which helps with proof of callers. * libgnat/a-strfix.adb (Delete): Fix implementation to produce correct result in all cases. For example, returned string should always have a lower bound of 1, which was not respected in one case. This was not detected by proof, since this code was dead according to the too strict precondition. * libgnat/a-strfix.ads (Delete): State the correct precondition from standard which allows a value of Through beyond the last valid index, and also restricts values of From from below. Update the Contract_Cases accordingly to allow new values of parameters. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/a-strbou.ads | 3 +++ gcc/ada/libgnat/a-strfix.adb | 33 ++++++++++++--------------------- gcc/ada/libgnat/a-strfix.ads | 20 ++++++++++++-------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/gcc/ada/libgnat/a-strbou.ads b/gcc/ada/libgnat/a-strbou.ads index 827c0dc7448..a4830e56b78 100644 --- a/gcc/ada/libgnat/a-strbou.ads +++ b/gcc/ada/libgnat/a-strbou.ads @@ -127,6 +127,9 @@ is -- * If Drop=Error, then Strings.Length_Error is propagated. function To_String (Source : Bounded_String) return String with + Post => + To_String'Result'First = 1 + and then To_String'Result'Length = Length (Source), Global => null; -- To_String returns the String value with lower bound 1 -- represented by Source. If B is a Bounded_String, then diff --git a/gcc/ada/libgnat/a-strfix.adb b/gcc/ada/libgnat/a-strfix.adb index 901fd60284b..2da5367985b 100644 --- a/gcc/ada/libgnat/a-strfix.adb +++ b/gcc/ada/libgnat/a-strfix.adb @@ -266,36 +266,27 @@ package body Ada.Strings.Fixed with SPARK_Mode is return Result_Type (Source); end; - elsif From not in Source'Range - or else Through > Source'Last - then - pragma Annotate - (CodePeer, False_Positive, - "test always false", "self fullfilling prophecy"); - - -- In most cases this raises an exception, but the case of deleting - -- a null string at the end of the current one is a special-case, and - -- reflects the equivalence with Replace_String (RM A.4.3 (86/3)). - - if From = Source'Last + 1 and then From = Through then - return Source; - else - raise Index_Error; - end if; - else declare - Front : constant Integer := From - Source'First; + Front_Len : constant Integer := + Integer'Max (0, From - Source'First); + -- Length of prefix of Source copied to result + Back_Len : constant Integer := + Integer'Max (0, Source'Last - Through); + -- Length of suffix of Source copied to result + + Result_Length : constant Integer := Front_Len + Back_Len; + -- Length of result begin - return Result : String (1 .. Source'Length - (Through - From + 1)) + return Result : String (1 .. Result_Length) with Relaxed_Initialization do - Result (1 .. Front) := + Result (1 .. Front_Len) := Source (Source'First .. From - 1); if Through < Source'Last then - Result (Front + 1 .. Result'Last) := + Result (Front_Len + 1 .. Result'Last) := Source (Through + 1 .. Source'Last); end if; end return; diff --git a/gcc/ada/libgnat/a-strfix.ads b/gcc/ada/libgnat/a-strfix.ads index 9d5e9d92341..aed0851493b 100644 --- a/gcc/ada/libgnat/a-strfix.ads +++ b/gcc/ada/libgnat/a-strfix.ads @@ -1061,9 +1061,9 @@ is From : Positive; Through : Natural) return String with - Pre => (if From <= Through - then (From in Source'Range - and then Through <= Source'Last)), + Pre => From > Through + or else (From - 1 <= Source'Last + and then Through >= Source'First - 1), -- Lower bound of the returned string is 1 @@ -1079,12 +1079,14 @@ is -- Length of the returned string - Delete'Result'Length = Source'Length - (Through - From + 1) + Delete'Result'Length = + Integer'Max (0, From - Source'First) + + Integer'Max (Source'Last - Through, 0) -- Elements before From are preserved and then - Delete'Result (1 .. From - Source'First) + Delete'Result (1 .. Integer'Max (0, From - Source'First)) = Source (Source'First .. From - 1) -- If there are remaining characters after Through, they are @@ -1092,9 +1094,11 @@ is and then (if Through < Source'Last - then Delete'Result - (From - Source'First + 1 .. Delete'Result'Last) - = Source (Through + 1 .. Source'Last)), + then + Delete'Result + (Integer'Max (0, From - Source'First) + 1 + .. Delete'Result'Last) + = Source (Through + 1 .. Source'Last)), -- Otherwise, the returned string is Source with lower bound 1 From patchwork Thu Aug 1 15:17:38 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: 1967855 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=VkeqYb3Y; 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 4WZY6P2GyZz1ybX for ; Fri, 2 Aug 2024 01:39:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 828163851C30 for ; Thu, 1 Aug 2024 15:39:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 8F9CD385DDFE for ; Thu, 1 Aug 2024 15:18:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F9CD385DDFE 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 8F9CD385DDFE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525534; cv=none; b=PnSm1Sa2CWu90YU/Gcr32Ksl6E7rLlbrzRpSpGVyp0IPVhFYsKnKP1RBh+6E3O4wpjrtpGwkU3cSJjNRhYumdN7UQxqTtHjZNruEjyvJww+wEUkhzc+qnw+J6GLBkGzoPBRsoS/gPIptzxOKr/KD0JdJstOTIl+0WvrqdFiUOtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722525534; c=relaxed/simple; bh=3fOqU8vDgz/nBiKUiV1xHCja2KU3o4dM2VvCP4FX/0o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=OWA8oGZbkDQ6Bkw4/oUxFag1CKrBZ066v2TDkeGxM/Vt70dY2Cw5/RlUayAZE41nhQ+skQyY6tmV8nA1wiZTSW6NPxgdiHJSfzR74DA3HlxUoHOqTauRemqLRTU/v1Pq9XnTBjqLoyszQokSyeFKzV3xjM/DHyiuFGk+x1p551o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4266f3e0df8so45275195e9.2 for ; Thu, 01 Aug 2024 08:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722525515; x=1723130315; 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=YKbO3S0sRMxFfKCQJQwQi15zyUgy9t8WUqI4e3bOln4=; b=VkeqYb3Y5SsjRg7OETiWlhqTJ/T48l17qrgMyryHK0G4Cy5JzgEJcjCQnsyTGP2KSW vqmrJZ1y8VCy8WdbsG4uZW/Qu2c0CxoWOp7gCtomkKZzIZarjUOjM2r9fOzzwTyTewy2 hFKd6YXLX4sIn4zjyTlpHx7oSzM0n5hKwP/3RcxzODfz8qiODdFEvdq1edQJon4HhgZK uXfEzPm48JCezQ40S29AnrEM2OKtxUrQ+Ho6kInHn5GlptHVmikPONS4ZHNJYp7LIrJV tl0awsvE5TteONj8m0uCC87zvHXZc6gg3BvNdbNfBL9pLUpSCvn/RruBkbkwjHZfDc4r ktAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722525515; x=1723130315; 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=YKbO3S0sRMxFfKCQJQwQi15zyUgy9t8WUqI4e3bOln4=; b=KdMH48PmNV66AkMSZXiHNv1nfgleWhjoHZAcCxAyiAsLYZ/pW7+R0X/RtRPVDGtVFx Skz6tCEOoAn1Yjm1ig43wLqTbsunxbkW8jEqPd3vSaRwAlyTCOFDy4t53vfUFreqDuZS g99s+lhVwOXdmztflLNgr2L8MbnhW41UMwtmMINipVXDFiu3R4L2c7BG+Nzdmk53pVtl Eaydzrf9X5sibiYsezDvej3WGrgATcvumMGj6IiWkolNJTEbNvBef2Pd4Z1DpGIrDYhF 3dL8uFvcFzU4EFEgZNQFRXgVZH4acWAe684tqEQQ7zrnoI/aeqcVE3dILTg0lPAsGnTN LnEw== X-Gm-Message-State: AOJu0YywNRv0fIgd5Orh8gW2683dCIpgsY//v4SUhs/bg0Fez3dzRQ7h au2VnYC3m4BNb7/nf28H4GToodb3CXIgYYMrZ6LH1MF4u1shf90cRKMzmVdIPsXyaoiYXg0TbF7 3og== X-Google-Smtp-Source: AGHT+IGV3/oc63KA8b2rmmWz7Z5EOc7Y9QczNITrvAsxj+su8KlWz1DorWxTsjd1mKkORpSkJgYvVw== X-Received: by 2002:a5d:424a:0:b0:366:e89c:342e with SMTP id ffacd0b85a97d-36bbc1c0c76mr104903f8f.53.1722525515192; Thu, 01 Aug 2024 08:18:35 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36857fdesm20065995f8f.75.2024.08.01.08.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:18:34 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [COMMITTED 30/30] ada: Fix computation of new size when reallocating unbounded string Date: Thu, 1 Aug 2024 17:17:38 +0200 Message-ID: <20240801151738.400796-30-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801151738.400796-1-poulhies@adacore.com> References: <20240801151738.400796-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 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: Yannick Moy The procedure Realloc_For_Chunk which is used to reallocate an unbounded string when needed may lead in theory to an overflow, due to the use of variable S_Length denoting the current allocated length instead of Source.Last denoting the current string length. Now fixed. This has no effect in practice since the only targets that use this version of Ada.Strings.Unbounded do not have enough memory to make it possible to have an overflow here. gcc/ada/ * libgnat/a-strunb.adb (Realloc_For_Chunk): Fix computation of new size. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/a-strunb.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ada/libgnat/a-strunb.adb b/gcc/ada/libgnat/a-strunb.adb index 219abad3f07..c3d4c71271b 100644 --- a/gcc/ada/libgnat/a-strunb.adb +++ b/gcc/ada/libgnat/a-strunb.adb @@ -824,7 +824,7 @@ package body Ada.Strings.Unbounded is declare New_Size : constant Positive := Saturated_Sum - (Sum (S_Length, Chunk_Size), S_Length / Growth_Factor); + (Sum (Source.Last, Chunk_Size), S_Length / Growth_Factor); New_Rounded_Up_Size : constant Positive := Saturated_Mul