From patchwork Thu Aug 8 14:29:43 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: 1970581 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=ihLEKZZO; 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 4WfqGt6s91z1ybS for ; Fri, 9 Aug 2024 00:31:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C948A3864816 for ; Thu, 8 Aug 2024 14:31:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 874B63861025 for ; Thu, 8 Aug 2024 14:30:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 874B63861025 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 874B63861025 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127437; cv=none; b=oL3XS2EJBNGVDGAOyoiUIDJcz7FBO7JGO1zOIsqjLZfvCHLUA/qTNGIZSxrzNb5rzb1ZhC4n7Go434RhN5fIvVecK+rllst/A84YxrSoRVsgmCIcKVdEZn2tUnlrCFoxHehpsgMnUSK+X5+wScPiH+0+VUaS8W91qNd7Co6PcWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127437; c=relaxed/simple; bh=KqUF2txA4Cvq9iUQ7d7z7N7WsCtljtig5bp3Y9AC1JI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=c/gLOvp8CkeDhKQAVYEb9cADwWB6Wxz7MY67VQiWPAkvGFjmooRiLsJyt7Ik2BpNd7AoowGkR7DkoQKO7CtM5sbiv9yFZAJeNI/8aN/zJf74k9rpfEa8fou+9VjooXM/ni/ZjqpDP7STCLGgxQMDKfcQed3CsCe965IWkAV7Cto= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4280b3a7efaso7577045e9.0 for ; Thu, 08 Aug 2024 07:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1723127434; x=1723732234; 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=MziclQGT0mk9V7OwzeKUPVC3M3kdUwUTtkaEjw2fN2Q=; b=ihLEKZZO5zf12W0qRXtJV6JCtQLicN4Duuqs/SIPajFMS00oTZbfrgtGmAmFdNM2b9 mPR8FwMD2TK0bC/3JkLqsP9QmGEpi7n1wDs4R/rFQRNh7TdhudSr1Z+mO8kXX8FVIkR/ ec7WFhSO7rOwu5O4ug6w/kvXMQEo6tC8I2qL9Jb/w1PB6wNN4XVJKio9Kb+Gc4sYaQPn 0vx8SIcpcDdmK5XvWvkWohGIP4wsbYzGYt+gg2h5R/KNXk/PyJUBZs5MbRXoHrsrQOL7 B59UWuVv4l8/VpPWV4a+3upqheGm5OGpnHaAH3Oukm1OfMy6qDo0+7BBfoN7ScjGWMrX Bg+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723127434; x=1723732234; 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=MziclQGT0mk9V7OwzeKUPVC3M3kdUwUTtkaEjw2fN2Q=; b=oIQss7XvrzbZuPBY7/EIFW6WXWt34E9RHLNXBlmRqaYm/rxaDBbLJN67oDKMD0EDdW npzfK1XgIKWQsA+NzU/L7SwnfUUpvP3hkixKXkxs5mYzUTcKaDh1cSy7Y5aEXoGaDGDb 2fBwBZPujQD97PgsMjpEGVzsoiAn7LF2ILL4B8EaTeu46FbTjh4AeYIIv7Vjey6igmrh k9VrMCZNV9QGv4mAWGuqtSh4UM0C1Ali3Jfj/u9GHZchHDac7azvlQk5QJliULznt7tv aibNeQMywp7EL9uqcHcP9biomurQkxpnJMSoI472eDvI4vhtA/SpKA4G4pDvYELGnfMB T9ew== X-Gm-Message-State: AOJu0Yx1q0AcOg72967mFvhZ9pyEoFSOlrsaAtDcKtoCwgoRUtxvkxT3 y3Gp6tBgJWAmYaNTROcL/Jz3X0VkgZ4W2myl8ENor2HG4MiPljkvAK2j1BiTMEI5L96ZkWHuAi8 5sw== X-Google-Smtp-Source: AGHT+IG/E/hB8J6FhTDjHHiuuBfRQ65mOrGukE1ppJFhtYfbuNaCkJkLJBFyQohvhFcRpPEMb8lAOw== X-Received: by 2002:a05:600c:1c99:b0:428:f1b4:3473 with SMTP id 5b1f17b1804b1-4290af0fc8amr16052005e9.26.1723127433986; Thu, 08 Aug 2024 07:30:33 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c72d6c8sm25992015e9.9.2024.08.08.07.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 07:30:33 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 1/6] ada: Finalization_Size raises Constraint_Error Date: Thu, 8 Aug 2024 16:29:43 +0200 Message-ID: <20240808142948.807190-1-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 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 When the attribute Finalization_Size is applied to an interface type object, the compiler-generated code fails at runtime, raising a Constraint_Error exception. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference) : If the prefix is an interface type, generate code to obtain its address and displace it to reference the base of the object. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_attr.adb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 13c7444ca87..6475308f71b 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -3688,11 +3688,34 @@ package body Exp_Attr is -- Local variables - Size : Entity_Id; + P_Loc : constant Source_Ptr := Sloc (Pref); + Size : Entity_Id; -- Start of processing for Finalization_Size begin + -- If the prefix is an interface type, generate code to obtain its + -- address and displace it to reference the base of the object. + + if Is_Interface (Ptyp) then + -- Generate: + -- Ptyp!(tag_ptr!($base_address (ptr.all'address)).all) + + Rewrite (Pref, + Unchecked_Convert_To (Ptyp, + Make_Explicit_Dereference (P_Loc, + Unchecked_Convert_To (RTE (RE_Tag_Ptr), + Make_Function_Call (P_Loc, + Name => New_Occurrence_Of + (RTE (RE_Base_Address), P_Loc), + Parameter_Associations => + New_List ( + Make_Attribute_Reference (P_Loc, + Prefix => Duplicate_Subexpr (Pref), + Attribute_Name => Name_Address))))))); + Analyze_And_Resolve (Pref, Ptyp); + end if; + -- If the prefix is the dereference of an access value subject to -- pragma No_Heap_Finalization, then no header has been added. From patchwork Thu Aug 8 14:29:44 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: 1970584 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=aNXyThAC; 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 4WfqHj0QlTz1ybS for ; Fri, 9 Aug 2024 00:32:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4B19B3865C26 for ; Thu, 8 Aug 2024 14:31:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id AC9F2386183E for ; Thu, 8 Aug 2024 14:30:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC9F2386183E 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 AC9F2386183E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127438; cv=none; b=IiUqT25PDgqr9CWLBzPNOOHQ+YsPNlBwtz8h9qRtUJ//SWah8Iu4P8FByuW1blF90xqEmrwMVbOU8s1HJYBrGXb9jUZZaiowwRe+TeFLOYQS7uKkHjzZX2fRCBTql04mmwN72b8EpK616MV/IkJHXkvofVyRS25YTMQk63WBAko= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127438; c=relaxed/simple; bh=z99rgvLVsrb9aZQDuko0qOIufk1LrW4xEi2BtXaG2l8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=itgQEkRjc6sp/4Y4XsIQi+q09F9c2ILdT0wHjyYP0juDmsEbuLqYUewNpPV/xnMFtq7fxwv4Vvu+IFSTk9xfZlGwGNM/+xKKMP6wxU7Kbrfjtd5KLP3WBPrkvZqRjv8vhEjzWU0U+ubC58T8iT6wvjrQaOW/xfTdvPiUM4Nho6s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4281c164408so7464275e9.1 for ; Thu, 08 Aug 2024 07:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1723127435; x=1723732235; 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=8sAQJaehM5X3Pj5bKzchZP6C9IbjjVDHJvkC8s6AuFo=; b=aNXyThACpfaJK8WW2dMKHRbVu+4UyIOq2VKrfQ0b1vWUVD1JAHuTxaTu5C7tGUYYB9 rI+vRxSGC0S8ieJ472G9a40Dg06VFulzYiZTdlmIPHHcR1rWkzzBDnytH1Exg7c5TJD/ 9+9n+bi3+xJHqQ/fvPDHWaM21mC1pTtUH2Fbn7n65M3VNi1EKYL/G/OzLf4/K3CNERx4 evv4e/TCZn2U53jn+KWzV80+dKFdaLwODTWVfASdYAuSUYY6oDhUku2RAbzS02sZnch9 UwPKorRVlwWQqFbyqnrAfuwkd/NGROSDh+ImeEG7apBIHZb5o79EvY1YZQjvCQVCO8XE CcZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723127435; x=1723732235; 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=8sAQJaehM5X3Pj5bKzchZP6C9IbjjVDHJvkC8s6AuFo=; b=EuAxRI/nk8z/R4TcLWzQjrzdFtVGWhtHyjf+KX3otj2C/2eRRZWeza2R25M1dbPcIt dqWj0ZuolWsZTAr6hfPq1SjnZvDmFRYScFilk3kaIXN5zUK9bL50gRagvw0c1gi1SqiT A9aNbQHPlYo551mthtGriXJAhfdHOScllnpZR9+sX53LDAvMlwTilHoEjvfHJebpkKBp cJKt5lvqrhXUBodf3tcghqjVrZK9430I+d/i806WOPogWVnSkRCmd5z+IDkpj61Smj01 b1almu5xCY0sZWl1GFmrmaY3xkBp+PBGRC0d7DJ654dsNk3GaP2SmLAWY3AyJHUhjR4v 12nQ== X-Gm-Message-State: AOJu0YzW5KBvIfy0fFXtYjJ8oHePfg7je405BcXsgN9bUDulz+zx7uj0 AtM+600DwqYktD3pOzXEroxF6hhFoM5cZjQf0/U0yhGiQohXL1PioXI8G7mywYjfwbUTqum7TVj Sug== X-Google-Smtp-Source: AGHT+IF9Zfg5lKdMH3jzLbkkXw+LAb4h8anpYCHi834yWdIWbCp2xv1/PEAds3Jqg34cVN7AoE7TCw== X-Received: by 2002:a05:600c:458a:b0:428:f41:d467 with SMTP id 5b1f17b1804b1-4290aeb3a84mr15243855e9.10.1723127434805; Thu, 08 Aug 2024 07:30:34 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c72d6c8sm25992015e9.9.2024.08.08.07.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 07:30:34 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [COMMITTED 2/6] ada: Spurious maximum nesting level warnings Date: Thu, 8 Aug 2024 16:29:44 +0200 Message-ID: <20240808142948.807190-2-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240808142948.807190-1-poulhies@adacore.com> References: <20240808142948.807190-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: Justin Squirek This patch fixes an issue in the compiler whereby disabling style checks via pragma Style_Checks ("-L") resulted in the minimum nesting level being zero but the style still being enabled - leading to spurious maximum nesting level exceeded warnings. gcc/ada/ * stylesw.adb (Set_Style_Check_Options): Disable max nesting level when unspecified Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/stylesw.adb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/ada/stylesw.adb b/gcc/ada/stylesw.adb index 76004455b10..6ef8e205e96 100644 --- a/gcc/ada/stylesw.adb +++ b/gcc/ada/stylesw.adb @@ -537,7 +537,8 @@ package body Stylesw is Style_Check_Layout := False; when 'L' => - Style_Max_Nesting_Level := 0; + Style_Max_Nesting_Level := 0; + Style_Check_Max_Nesting_Level := False; when 'm' => Style_Check_Max_Line_Length := False; From patchwork Thu Aug 8 14:29:45 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: 1970587 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=Zbmb60iz; 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 4WfqJx56P6z1ybS for ; Fri, 9 Aug 2024 00:33:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 059FB385F018 for ; Thu, 8 Aug 2024 14:33:04 +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 4EEC8385E82D for ; Thu, 8 Aug 2024 14:30:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4EEC8385E82D 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 4EEC8385E82D 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=1723127439; cv=none; b=tEc931fmOh2WENVj8C/VgFjz1XinLLLz1jtQKmIOf9c23XJBDBt4IJRxs0p7yDr8l9lFIH0ejS6JT4Kq/NxhO2MenMoXQc0J0dhZfCKwcA+CnUE8Jjqxeu3RDuzPVFAJeeylIiqk2bqlc7yC72/Cgi1dKsIU9dWdz5gFDaY818Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127439; c=relaxed/simple; bh=vuwG2A4HjC7k/9vxDwYxLJzHkBcHl85p2iGYSb5ImiE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=O/0wYFj5iWMUzQi1Y4ovupflLL9+V9ICk2Qf7nrxR3xVLMpF4d6jiiyTDUMCRadSjbRkh9opvX7QOyMk65syZEfid15S6zopcBbWpGHGw2Ol03kKoQkabbCYg/XsXt00ZpqTlu/QffikF8TK0aAZvH2V71B9B92MpGdqPbqwh4o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-428178fc07eso6897795e9.3 for ; Thu, 08 Aug 2024 07:30:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1723127436; x=1723732236; 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=UUs57jvsIAQVoTSNniagnaYmsY53hQEYEAneOMskhj8=; b=Zbmb60izicyezj+WfpnU7O0pojlRMy9l6R3FIpCW5hocrlfIgYyliI2dbI8Md07Bgq FSHoOL8ChYUA8whpJaT4OV9ceAG4HVIqC9k3KgMKMpxFO+ZVuTq+nb6Li9RuQwWFHJV7 OPeG042Mfv8Q5qzFlAYwGS63dpuR8+YFz1DD368e2p3d/HBJ0y/6ishNKhhDw1Kk1rYI 0pClNHnopfGm9Mn9tJSJZ1bR7WubNu2mH3Gj1UReegJfJMKfUdEzkxGd7NpcuqbdNjTY 08VaxWJ5yKtsSSXGcaKhdkJnWETQvz0OjWh/niJYSpASaoEZRULHuTSrXDxnXL8MKtAw L1Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723127436; x=1723732236; 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=UUs57jvsIAQVoTSNniagnaYmsY53hQEYEAneOMskhj8=; b=iEvKHOmnSoSpZP19NARuFb9WqfZOzLdC6kt131Rz/97n/wolCZGq/JwelE679NyPMp 7shuUg/q+RH+hT1PeI5LbfXJI5+4IcIfHTYwSAuRUP8HCELTv/w11uazmRBj2fz82chB ccae2pSEDDDbdI5zpWty+pcm4j3pchlgABIas0mNJ8vq1mEcZNDnXbU/ydJGtcEZRFqf Qbqx2BtWpnU6sbxeIvtQn1jeQWKaxt8Bmwm6P5su+CWdbA805UhJTFE9LWMU5/Lq2Kpu LN6TCPlotg+5sU2F7tuJuMt7HzlluUJIIk3L4koT2Yivd0M8VOXQKmMGt8kOf/RIAfzO o5qg== X-Gm-Message-State: AOJu0YxQTE4G9hYOdCLUv9lKEZl8EwrCM19oMMmiYI3JcpHHHdSopeEA OIDVuk21csCF+9CQw4N6OvNW+d4BwnDiuYRH7CqUebzV7yz9Todmytc2WLpNGmC9F4KFxLL/QmB /cA== X-Google-Smtp-Source: AGHT+IGyXHX97z8hExhh0l/5wgb9NbSACqMyTChKH6e88JhohSt8mgLrpeg6t4wSHMurHRTOhkLTxw== X-Received: by 2002:a05:600c:190c:b0:426:6e86:f82 with SMTP id 5b1f17b1804b1-4290af13f11mr19436285e9.22.1723127435573; Thu, 08 Aug 2024 07:30:35 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c72d6c8sm25992015e9.9.2024.08.08.07.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 07:30:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [COMMITTED 3/6] ada: Futher refinements to mutably tagged types Date: Thu, 8 Aug 2024 16:29:45 +0200 Message-ID: <20240808142948.807190-3-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240808142948.807190-1-poulhies@adacore.com> References: <20240808142948.807190-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: Justin Squirek This patch further enhances the mutably tagged type implementation by fixing several oversights relating to generic instantiations, attributes, and type conversions. gcc/ada/ * exp_put_image.adb (Append_Component_Attr): Obtain the mutably tagged type for the component type. * mutably_tagged.adb (Make_Mutably_Tagged_Conversion): Add more cases to avoid conversion generation. * sem_attr.adb (Check_Put_Image_Attribute): Add mutably tagged type conversion. * sem_ch12.adb (Analyze_One_Association): Add rewrite for formal type declarations which are mutably tagged type to their equivalent type. (Instantiate_Type): Add condition to obtain class wide equivalent types. (Validate_Private_Type_Instance): Add check for class wide equivalent types which are considered "definite". * sem_util.adb (Is_Variable): Add condition to handle selected components of view conversions. Add missing check for selected components. (Is_View_Conversion): Add condition to handle class wide equivalent types. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_put_image.adb | 25 ++++++++++++++----------- gcc/ada/mutably_tagged.adb | 21 ++++++++++++++------- gcc/ada/sem_attr.adb | 7 +++++++ gcc/ada/sem_ch12.adb | 25 +++++++++++++++++++++++-- gcc/ada/sem_util.adb | 14 +++++++++++++- 5 files changed, 71 insertions(+), 21 deletions(-) diff --git a/gcc/ada/exp_put_image.adb b/gcc/ada/exp_put_image.adb index bf14eded93e..217c38a30e7 100644 --- a/gcc/ada/exp_put_image.adb +++ b/gcc/ada/exp_put_image.adb @@ -32,6 +32,7 @@ with Einfo.Utils; use Einfo.Utils; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Lib; use Lib; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; @@ -402,9 +403,9 @@ package body Exp_Put_Image is end; end Build_Elementary_Put_Image_Call; - ------------------------------------- + --------------------------------- -- Build_String_Put_Image_Call -- - ------------------------------------- + --------------------------------- function Build_String_Put_Image_Call (N : Node_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (N); @@ -485,9 +486,9 @@ package body Exp_Put_Image is Relocate_Node (Sink))); end Build_Protected_Put_Image_Call; - ------------------------------------ + ------------------------------- -- Build_Task_Put_Image_Call -- - ------------------------------------ + ------------------------------- -- For "Task_Type'Put_Image (S, Task_Object)", build: -- @@ -650,12 +651,14 @@ package body Exp_Put_Image is return Result; end Make_Component_List_Attributes; - -------------------------------- + --------------------------- -- Append_Component_Attr -- - -------------------------------- + --------------------------- procedure Append_Component_Attr (Clist : List_Id; C : Entity_Id) is - Component_Typ : constant Entity_Id := Put_Image_Base_Type (Etype (C)); + Component_Typ : constant Entity_Id := + Put_Image_Base_Type + (Get_Corresponding_Mutably_Tagged_Type_If_Present (Etype (C))); begin if Ekind (C) /= E_Void then Append_To (Clist, @@ -936,9 +939,9 @@ package body Exp_Put_Image is Build_Put_Image_Proc (Loc, Btyp, Decl, Pnam, Stms); end Build_Record_Put_Image_Procedure; - ------------------------------- + ----------------------------- -- Build_Put_Image_Profile -- - ------------------------------- + ----------------------------- function Build_Put_Image_Profile (Loc : Source_Ptr; Typ : Entity_Id) return List_Id @@ -983,9 +986,9 @@ package body Exp_Put_Image is Statements => Stms)); end Build_Put_Image_Proc; - ------------------------------------ + ---------------------------------- -- Build_Unknown_Put_Image_Call -- - ------------------------------------ + ---------------------------------- function Build_Unknown_Put_Image_Call (N : Node_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (N); diff --git a/gcc/ada/mutably_tagged.adb b/gcc/ada/mutably_tagged.adb index 34b032f08c8..495cdd0fcfb 100644 --- a/gcc/ada/mutably_tagged.adb +++ b/gcc/ada/mutably_tagged.adb @@ -272,15 +272,22 @@ package body Mutably_Tagged is if Force -- Otherwise, don't make the conversion when N is on the left-hand - -- side of the assignment, is already part of an unchecked conversion, - -- or is part of a renaming. + -- side of the assignment, in cases where we need the actual type + -- such as a subtype or object renaming declaration, or a generic or + -- parameter specification. + + -- Additionally, prevent generation of the conversion if N is already + -- part of an unchecked conversion or a part of a selected component. or else (not Known_To_Be_Assigned (N, Only_LHS => True) - and then (No (Parent (N)) - or else Nkind (Parent (N)) - not in N_Selected_Component - | N_Unchecked_Type_Conversion - | N_Object_Renaming_Declaration)) + and then (No (Parent (N)) + or else Nkind (Parent (N)) + not in N_Selected_Component + | N_Subtype_Declaration + | N_Parameter_Specification + | N_Generic_Association + | N_Unchecked_Type_Conversion + | N_Object_Renaming_Declaration)) then -- Exclude the case where we have a 'Size so that we get the proper -- size of the class-wide equivalent type. Are there other cases ??? diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index a5c90e3f36d..994a45becdc 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -2682,6 +2682,13 @@ package body Sem_Attr is E1); end if; + -- Generate a conversion from a class-wide equivalent type (if + -- present) to the relevant actual type E2. + + if Is_Mutably_Tagged_CW_Equivalent_Type (Etype (E2)) then + Make_Mutably_Tagged_Conversion (E2); + end if; + -- Check that the second argument is of the right type Analyze (E2); diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 0f8792c3a82..bc0d34e871d 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -2419,9 +2419,9 @@ package body Sem_Ch12 is -- but there is "others => <>". Add a copy of the declaration of the -- generic formal to the Result_Renamings. - --------------------- + ------------------------ -- Process_Box_Actual -- - --------------------- + ------------------------ procedure Process_Box_Actual (Formal : Node_Id) is pragma Assert (Assoc.Actual.Kind = Box_Actual); @@ -2535,6 +2535,19 @@ package body Sem_Ch12 is else Analyze (Match); + + -- Rewrite mutably tagged types to be their class-wide + -- equivalent type. + + if Ekind (Etype (Match)) /= E_Void + and then Is_Mutably_Tagged_Type (Etype (Match)) + then + Rewrite (Match, New_Occurrence_Of + (Class_Wide_Equivalent_Type + (Etype (Match)), Sloc (Match))); + Analyze (Match); + end if; + Append_List (Instantiate_Type (Assoc.Un_Formal, Match, Assoc.An_Formal, @@ -14928,6 +14941,7 @@ package body Sem_Ch12 is elsif not Is_Definite_Subtype (Act_T) and then Is_Definite_Subtype (A_Gen_T) + and then No (Class_Wide_Equivalent_Type (Act_T)) and then Ada_Version >= Ada_95 then Error_Msg_NE @@ -14957,6 +14971,13 @@ package body Sem_Ch12 is Act_T := Entity (Actual); + -- Obtain the class-wide equivalent type and use it for the + -- instantiation instead of a mutably tagged type. + + if Present (Class_Wide_Equivalent_Type (Act_T)) then + Act_T := Class_Wide_Equivalent_Type (Act_T); + end if; + -- Ada 2005 (AI-216): An Unchecked_Union subtype shall only be passed -- as a generic actual parameter if the corresponding formal type -- does not have a known_discriminant_part, or is a formal derived diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 7b575c09c30..3f956098c6d 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -21052,6 +21052,16 @@ package body Sem_Util is if Nkind (N) in N_Subexpr and then Assignment_OK (N) then return True; + -- It is possible that N is a selected component of a view conversion, + -- and in that case get the expression of the conversion and test + -- whether it is indeed a variable. + + elsif Nkind (N) = N_Selected_Component + and then Is_View_Conversion (Ultimate_Prefix (N)) + and then Is_Variable (Expression (Ultimate_Prefix (N))) + then + return True; + -- Normally we go to the original node, but there is one exception where -- we use the rewritten node, namely when it is an explicit dereference. -- The generated code may rewrite a prefix which is an access type with @@ -21205,7 +21215,9 @@ package body Sem_Util is and then Nkind (Unqual_Conv (N)) in N_Has_Etype then if Is_Tagged_Type (Etype (N)) - and then Is_Tagged_Type (Etype (Unqual_Conv (N))) + and then (Is_Tagged_Type (Etype (Unqual_Conv (N))) + or else Is_Class_Wide_Equivalent_Type + (Etype (Unqual_Conv (N)))) then return True; From patchwork Thu Aug 8 14:29:46 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: 1970582 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=bMmNkYXZ; 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 4WfqGv2yrgz1yfC for ; Fri, 9 Aug 2024 00:31:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41FF6384DEE0 for ; Thu, 8 Aug 2024 14:31:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id A9E2B384DEE3 for ; Thu, 8 Aug 2024 14:30:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A9E2B384DEE3 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 A9E2B384DEE3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::236 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127442; cv=none; b=cWEBrE/euqoKQ7kwyvT/JFctliWsNsVsE0P2AlkY+e1kTSyHVpx2xTv0C9lKWTcXqFcy6ANPACGreMDdmbkftQSqEXr5dlIHt2zUpXENOyvYpSEFESbZ7jTx8KzH1n1fv3d3HgY6jQ8GrLfHEsfEH9gIKrFLmSiyF4qa73A0aEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127442; c=relaxed/simple; bh=d4pxZH2l/8M6W/fW+cq9ZKRHWBUN1KfN9qRGamcnP0s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GxpBf8yW0hgdajr7xWjgABA0LsMavoUPIH4ly9R4X7BVYNKhFXqb+AJwGhNa3ye9X+/WU3xtsAdryrHs1hWrOMdJnqhQpXws1NQW3QpuketFz0iMgSUD3qaZWfEIAIkk+gqoit4jWhB0BoZgnofSKcm1qQ+Rd3Gwbg6P1uL/uNw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2ef2d96164aso10172991fa.3 for ; Thu, 08 Aug 2024 07:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1723127437; x=1723732237; 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=YJcqK4n2+01FQjJzdRQUOtgtA1b6J8bnbOz0jqLi7hM=; b=bMmNkYXZnvIV+JSEpKfOHjf8m8QJgrtyHz/QtgCT5yamw4IKXGcoc7esAx+H9E08Ri Y9wz88zA4aEDly+4EY5rnyaA7iEx66cRYHGRj8Y0459howhsfGdG18JNLyVELlBUXpH2 OkdVbIKCrQ/2eu6VhwjRwvc4gj0vlAKV2lgMa5uVCtqK/Kgv2OixvD1IcnMipLxiGhZ1 ZrSvSM+mms9OXLn+Pqp9LDIk1wgo+n00OUYC/n/IrDNUtH4api5NcjOpAE73WjkUHWLC fO23ga/e+JxIlIO2QK+PW9uUG2n3MRBtbeFxQECaGnPcLG30GqxzW/Zk+o7ax4rkQPLK L1gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723127437; x=1723732237; 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=YJcqK4n2+01FQjJzdRQUOtgtA1b6J8bnbOz0jqLi7hM=; b=acwY46zuPp6stIYZ91L0P7WRNw7rLHNIE43nyAvHeefI4NK1jxxQ4RuoLDt4sdE+CV m2IQCC1w7eMGGnnB+4ZDEwQjLHAlRWTH29mYwUjMAHcBlitbzASAOYRF9jBADo0O5VGr 2MpQuqExrMmCJI/hZ9Ih+xYi+drzyavfmM2iIA9oETCNf3/a+VabOeUxAbi7bRWR8tu0 S2XoOoiRc9YWyUjSOvd4pgdSHR6Efut/H1Ppx0VM4qZNQryHeUKoRQdqsoZqaPqG/bpf raOQuVh11wrYUt7iTOJqMW0NoBJIPYua7xZATRVUMZh/ItCkSl1Eteh95pY7vHAaDVOr wgDw== X-Gm-Message-State: AOJu0YzLC/zgLW0vO8kWNYnAwfQNctXekUVu579Xr0JuS5e6V3IFsbL6 FTR82C+ccHhGeBBbe8uti/rHAxjbtC2FQDWbjpwLT5Cyemm0QskKOIkIotyXMuv700USuhyYInQ oiQ== X-Google-Smtp-Source: AGHT+IGRgV/LaKPJTwrsMLH6b6HFKgkfA6W0TLn0LvaFNz3Pi1MS0Ex1P70OfVcEb9Pu4p+ARTqDNw== X-Received: by 2002:a2e:9c83:0:b0:2ec:55b5:ed45 with SMTP id 38308e7fff4ca-2f19de3b2eemr15078531fa.24.1723127436815; Thu, 08 Aug 2024 07:30:36 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c72d6c8sm25992015e9.9.2024.08.08.07.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 07:30:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED 4/6] ada: Run-time error with GNAT-LLVM on container aggregate with finalization Date: Thu, 8 Aug 2024 16:29:46 +0200 Message-ID: <20240808142948.807190-4-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240808142948.807190-1-poulhies@adacore.com> References: <20240808142948.807190-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 When unnesting is enabled, the compiler was failing to copy the At_End_Proc field from a block statement to the procedure created to replace it when unnesting of top-level blocks is done. At run time this could lead to exceptions due to missing finalization calls. gcc/ada/ * exp_ch7.adb (Unnest_Block): Copy the At_End_Proc from the block statement to the newly created subprogram body. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch7.adb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 72f0b539c2e..640ad5c60b8 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -8932,7 +8932,8 @@ package body Exp_Ch7 is Defining_Unit_Name => Local_Proc), Declarations => Declarations (Decl), Handled_Statement_Sequence => - Handled_Statement_Sequence (Decl)); + Handled_Statement_Sequence (Decl), + At_End_Proc => New_Copy_Tree (At_End_Proc (Decl))); -- Handlers in the block may contain nested subprograms that require -- unnesting. From patchwork Thu Aug 8 14:29:47 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: 1970586 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=aFE1TGRo; 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 4WfqJ75cWwz1ybS for ; Fri, 9 Aug 2024 00:32:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C89F385E82D for ; Thu, 8 Aug 2024 14:32:19 +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 05397384DEF1 for ; Thu, 8 Aug 2024 14:30:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05397384DEF1 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 05397384DEF1 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=1723127442; cv=none; b=DJno46bFUoCis688//6ENndWdJyX+SIJBjvVhW3wYfiLUSiiOKskIURXvXfgHwLTJhXd6RQskIzHo/fIvvDKuK+Gkz5bG/9GvJ4hD26GSIVbkJwdZ55Pj+8zdLuInZfV3I8za9O14RgmuWKKLQj1k0rrUa71u7QdLMh6PxkVEDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127442; c=relaxed/simple; bh=5gPFxGyvH4KKHe6XjnRbDOYuk3P4RxvbcpS8lwzkKSs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=QSciiJn5ObnuwrBQwxN0asiy0dbNaUyXuFUETHuAzssGPV62wjI/j4WyQ8Zcv4k4mFS9hiZyRLytFUW9xYCcQZWGqmM5+yr54vt9JhgdPMjhPYpyI+gL/ZpSKKC8++WJW7lIScBMdxOCBUA+78wLBkpy1e4JRrubx8agX0nwBc0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4257d5fc9b7so10440135e9.2 for ; Thu, 08 Aug 2024 07:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1723127438; x=1723732238; 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=BmU54caL5Unn2pU4FyexFZth7i64l1cJYrE192ptySQ=; b=aFE1TGRoIoedjDqsitOfUmQc2iDLGSGMjaespFuMailRgxfcga5Jl2cBZSMh/QNPAF AS/+kp4PgfSkA3sbtnq9zS27tNUC4WG4AYXTFlVz8KX3CLZwTGgKff87poYlG3mgkj84 Isj8/CSRZ3lsqURSxqaFBz9B9esKTZXQeMgWxPiZMIJ7vnz0CC1X1K5wBuDvuJrf7kq+ tHWz+dvNSfK8VmZx31BMq7WQew2bFAIk7eeT7yq4Yj5zMseDEcbaIHiolPVJEQOBVu6M KZaoyxP6gwoxjO+F4YqKtmLzNKTvoh9TfD79gD5P0VtSwUuRloXlfgXuQ+QUEFbg3WF8 oHBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723127438; x=1723732238; 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=BmU54caL5Unn2pU4FyexFZth7i64l1cJYrE192ptySQ=; b=FO+ojyJ+cUPMirjxfkYAOhjFsUZYW7f2xUwdMR9LF261ySfltvlP1PJ6QCX5B1MATm JOJzYxZZrwahTtN5DSZB2nkSIymtx2CUTW3oJ6Xmdbha3bvHeQex6FV/HI0D6p0/sgnn JIxnBo5XnCVMRbWPRyc2EGVxXizLnQ4yQ3OnRWeh8vm0Gt/+t/sVZSphD62SPn2poHAV PgXXyoNNMoAdiAE141yyuhnJO/dxYXpyeCnYQ/2q5+SMiLkkTtpQHydmPLq4NWDvO35j aZczTfX6ANANAUXXYzBQVtP/Ucnkf1a2jJy8G9dyxI1A1nlnQqKpVcj2mr4V2emkjhYU Xpew== X-Gm-Message-State: AOJu0YzNJpdxD+5vzNjGHQR+VBaxCaY4EDW3+/fGSpU56YmbJ5taGutf XXtt6Q8iK99L7flIDiyb0tLG7ElYyIAz80zVPoo2FYgXNrjbksNx8iNMqe0nfMI9bGv22kkRekA vag== X-Google-Smtp-Source: AGHT+IGqheYGs3h9mVmVuzMVzcVXOp4NZkRldKXqq7gXEcOcZC9wtVY02DosszIkNb+aGUOm/Lg0kw== X-Received: by 2002:adf:f70e:0:b0:368:3b5c:7a5d with SMTP id ffacd0b85a97d-36d274ef60dmr1898759f8f.20.1723127437575; Thu, 08 Aug 2024 07:30:37 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c72d6c8sm25992015e9.9.2024.08.08.07.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 07:30:37 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 5/6] ada: Etype missing for raise expression Date: Thu, 8 Aug 2024 16:29:47 +0200 Message-ID: <20240808142948.807190-5-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240808142948.807190-1-poulhies@adacore.com> References: <20240808142948.807190-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: Steve Baird If the primitive equality operator of the component type of an array type is abstract, then a call to that abstract function raises Program_Error (when such a call is legal). The FE generates a raise expression to implement this. That raise expression is an expression so it should have a valid Etype. gcc/ada/ * exp_ch4.adb (Build_Eq_Call): In the abstract callee case, copy the Etype of the callee onto the Make_Raise_Program_Error result. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch4.adb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 18ec7125cc1..106305f4636 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -443,8 +443,11 @@ package body Exp_Ch4 is begin if Present (Eq) then if Is_Abstract_Subprogram (Eq) then - return Make_Raise_Program_Error (Loc, - Reason => PE_Explicit_Raise); + return Result : constant Node_Id := + Make_Raise_Program_Error (Loc, Reason => PE_Explicit_Raise) + do + Set_Etype (Result, Etype (Eq)); + end return; else return From patchwork Thu Aug 8 14:29:48 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: 1970585 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=Q88/XDC5; 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 4WfqJ53bCLz1ybS for ; Fri, 9 Aug 2024 00:32:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A1BEC3861034 for ; Thu, 8 Aug 2024 14:32:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id D8A2D386103C for ; Thu, 8 Aug 2024 14:30:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D8A2D386103C 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 D8A2D386103C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::333 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127443; cv=none; b=gbZu2thnLU40/sfvv53mn2oiR0M8XdYTAgyPD6NpSWWUeQCWF7LbfomWX/Bvp92Sjg+nQjdg/04KKSHZWvnKvuBYEgVdSSWqhVu/jq2D93oyZVS/u28sGERaugvBg5I/ZX7z0QfKcGdo8KYmTTUvhdWub1U7bKyp39hcURl1fIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723127443; c=relaxed/simple; bh=mTinstReLXFDfH2GQyeqbsSJLtWMSiH2tuA8B5ux6xA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Muy94OS+cqS8tMo/8HVobhf4qU6E32fRryTE1sGhcb7UTaubj76SCQ7CYwNFdeCvBjsjaXD6Q6x0l7LrO2d9ozTufimf/fl09qdWn+yWFAFmP4tHRhNjcTS/WrcgZZB+4BErhCxSlFGFKzxsl5r6fVPeawon0fiPZzVWY+V8yfU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-428243f928fso10670985e9.0 for ; Thu, 08 Aug 2024 07:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1723127438; x=1723732238; 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=JAHi+yWG/iRa83L3xUKLJq0W/LFvbEPTiewMYbLOkZY=; b=Q88/XDC5kiDnsTPJmI2AAEl0fA8hn4swWYMmXO7Td5Tdy7gtdGwDT+3fuvPs/nxU0/ K5UUNbyDl13SpZtrwuGpcT6ZrouEBaEkDIL9vwSmY53uonAwDN0luOUh8NtVHOv1NfLB cHF9gnquusEGwcXDjOlbpDlMnbvVlgHq3mQRDfLFcd9H0DSYErp9rx+DMpLNmKA1mt5i +RMQafs5Xdfd0gMk0DdLtksDnMhCz5TzZpUf8yYwpgXrq11uC/mE4YB7SMTTW4Z0ID4Z ym8TtNf2Vlnt3foYLWwUz/Oxs0kRpmcJrmosi5G+vMKddOwQJMKMLmK/0DwXTZPCyeMB rXHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723127438; x=1723732238; 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=JAHi+yWG/iRa83L3xUKLJq0W/LFvbEPTiewMYbLOkZY=; b=QKnpXGA0WB6jWoSkjCnrHUILPQ4EIgn60AX/gsGzSvjqXNaDlLEiDYZDbVZKdCTHB4 Sw5CHHQkN7byxLJWyRrMtuUSIGUbLqT+qONphsSCo/r0LRazP2KBWLic0uSh2nJEm3vH Wiy17B33iePG+wfPOu+SoDrn+2SycR1BZebCCtK0Y2HzccBKsqYjjTvTeEfgD1RPdcC2 SNF+9aYNfQcZxS3swfFYJRvjliVE6MJHcBu5YbJuCtLQZWK8XNK3lMmwEo1nv0NBdf0x p04xG3vAQAReJdF0UvWZr8xWMe6/QjStyy6VWZt6Rig4FTEJI/xREInzFrTQyiklLD1g d+qg== X-Gm-Message-State: AOJu0Yw+mFjhB1LrNlOLT4XvJwdBPpXQWJ9g1rESMSzfYTb3oGszT78J vgqmRpKioEw5lowL5NJiDLunvq04yfOEQsTLxBmsy75ot20OhIvAFAexLMLRY4WdwMqnVyoub8/ I3A== X-Google-Smtp-Source: AGHT+IHNFgf7WM0bca8NjVxhogAeDIFbLHl14pkElvlbSIb89NTUZl3VyOp6v9DaxwIkWt0AppvsLQ== X-Received: by 2002:a05:600c:4f55:b0:426:6f87:65fc with SMTP id 5b1f17b1804b1-4290af072a1mr20228755e9.17.1723127438403; Thu, 08 Aug 2024 07:30:38 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c72d6c8sm25992015e9.9.2024.08.08.07.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 07:30:37 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 6/6] ada: Missing legality check when type completed Date: Thu, 8 Aug 2024 16:29:48 +0200 Message-ID: <20240808142948.807190-6-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240808142948.807190-1-poulhies@adacore.com> References: <20240808142948.807190-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: Steve Baird An access discriminant is allowed to have a default value only if the discriminated type is immutably limited. In the case of a discriminated limited private type declaration, this rule needs to be checked when the completion of the type is seen. gcc/ada/ * sem_ch6.adb (Check_Discriminant_Conformance): Perform check for illegal access discriminant default values when the completion of a limited private type is analyzed. * sem_aux.adb (Is_Immutably_Limited): If passed the not-yet-analyzed entity for the full view of a record type, test the Limited_Present flag (which is set by the parser). Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aux.adb | 11 +++++++++++ gcc/ada/sem_ch6.adb | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/gcc/ada/sem_aux.adb b/gcc/ada/sem_aux.adb index 0639a2e4d86..9903a2b6a16 100644 --- a/gcc/ada/sem_aux.adb +++ b/gcc/ada/sem_aux.adb @@ -1118,6 +1118,17 @@ package body Sem_Aux is elsif Is_Private_Type (Btype) then + -- If Ent occurs in the completion of a limited private type, then + -- look for the word "limited" in the full view. + + if Nkind (Parent (Ent)) = N_Full_Type_Declaration + and then Nkind (Type_Definition (Parent (Ent))) = + N_Record_Definition + and then Limited_Present (Type_Definition (Parent (Ent))) + then + return True; + end if; + -- AI05-0063: A type derived from a limited private formal type is -- not immutably limited in a generic body. diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index d3912ffc9d5..5735efb327c 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -6456,6 +6456,20 @@ package body Sem_Ch6 is New_Discr_Id); return; end if; + + if NewD + and then Ada_Version >= Ada_2005 + and then Nkind (Discriminant_Type (New_Discr)) = + N_Access_Definition + and then not Is_Immutably_Limited_Type + (Defining_Identifier (N)) + then + Error_Msg_N + ("(Ada 2005) default value for access discriminant " + & "requires immutably limited type", + Expression (New_Discr)); + return; + end if; end if; end;