From patchwork Thu Jun 13 13:33: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: 1947419 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=AoI1i8mt; 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 4W0Nr246X9z20Xd for ; Thu, 13 Jun 2024 23:42:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3BFF388264B for ; Thu, 13 Jun 2024 13:42:08 +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 713CE3882130 for ; Thu, 13 Jun 2024 13:34:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 713CE3882130 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 713CE3882130 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=1718285663; cv=none; b=D8IcwjoPACrY8SNSeQGpolmzUXpEHlu6jv1EmjPJZ7+9u41fYl5OlJ/vVi376zvnt3oY7uaOY3xmq9rfYCxbbs4BPi30WEDKwUQEJnOsE88pIvBnzpmn/4jKaCaDvcGKYO36pM1OeRGU7stNlC8feMDVT4Yv2+F45DkzLq/LuLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718285663; c=relaxed/simple; bh=PBQCZ6whJeycA30KECYlNTQPLVZDw8xx2si3SfWkzLQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Dc2PK+KNxhiK86ei7DwYYdlkDBUJdK8UjohcWCCDMqqWSTxpmi231+5H8BdfEGNZ+zOMBFI6xQr0T1a9b+hb7jE/BPxpIw4W5j6hvOofkYf5q1ooysb91P6ShCNWCboeeFfARtq/hkOMjr+l9poTTz+dJOBFRl3gIHTikqy5wKM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2eaa89464a3so10285891fa.3 for ; Thu, 13 Jun 2024 06:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718285648; x=1718890448; 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=GtcxcS8HIez68QWDWcPhPkuxN5nJqIaoe8eVK7QlFPk=; b=AoI1i8mtF/6tz1Qd2dNoEezfYkDyUKGYqOwOD4vFIFVNHv6D7RLlN2lJYP/ZwxFR/9 2wdJFQdiOriyn+6W1aPpsRj0wt6wEdXrXzotA66UMyoVpSv2ALFsArg1xZ4ieGYZTNAm n8xEm8XQYIDb1uJItFoTiwIydltB9svsoKkmJeA9qv+q1VLm1Ea6F9g5xUgrc5unGj48 LzRQ0qNEPmM90F8vzXa2Bh55AFoX+0DBoBQMbyhfy7RukTaBzZOyh7gys/FHWq/sY9Wa BrCHqhf9Kc4LwFkj1FSJdnpYw82mKUj9CiEClClPbOXzkW99x/9g0QGx10nZhYYOeRfQ kDyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718285648; x=1718890448; 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=GtcxcS8HIez68QWDWcPhPkuxN5nJqIaoe8eVK7QlFPk=; b=jToajCBO2/L/L4i/o9JfmCPpiouJmwV/RQCpF4gOrXPr1v7rG1T9gEH4hRDm+1it3X hoTYCWbgYkkKJ6+zRZbVLcugrMlRO++vVi4DorvU+Cva+bRt/FHNJJFuMe2qVH9KUePq oeXXRAUpCgcMviAD73fJ/oTOfAZZEPYDcDlBvpbdChQur2ltAiXo1+8mLPk11GTC0R6/ 3AhtjgKqglduJqNCXIP9xH9ivJQ0yoYE0muWU2PeA55Eia3l6we/glV3/msNvoCGg+nK PaNa5pDe8IKaaM8P2OhhDUF9hwCoiEluBvxernYVFxEoJTXfrKiHH5yAE7m1tzmFveEW WLJw== X-Gm-Message-State: AOJu0Yx+f+Yq6ffu8Peh0eioJwvD+T01DJIiacgz4dNLy5PLpG+ovZbZ Ttq3loTcSE8/HhXvCcx6iNJ9KYUIxo7/f4orpPDe0VEa5WaaC+o1nAom4IOIeTcI+mPfSeLBaFQ = X-Google-Smtp-Source: AGHT+IGTimqvIecM8v7zeAenMBg7rP3Px48VxXxZ9LxFl+ELAvL9HDmMD3w/SGf3dbIxOm5bBJueRA== X-Received: by 2002:a05:651c:2113:b0:2eb:f8ae:1cb0 with SMTP id 38308e7fff4ca-2ebfc99f52fmr38764891fa.37.1718285647994; Thu, 13 Jun 2024 06:34:07 -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-422870e9145sm62391955e9.22.2024.06.13.06.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 06:34:07 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 23/30] ada: Deep copy of an expression sometimes fails to copy entities Date: Thu, 13 Jun 2024 15:33:29 +0200 Message-ID: <20240613133338.1809385-23-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240613133338.1809385-1-poulhies@adacore.com> References: <20240613133338.1809385-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, T_SCC_BODY_TEXT_LINE 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 entity can be defined within an expression (the best example is probably a declare expression, but a quantified expression is another; there are others). When making a deep copy of an expression, the Entity nodes for such entities were sometimes not copied, apparently for performance reasons. This caused correctness problems in some cases, so do not perform that "optimization". gcc/ada/ * sem_util.adb (New_Copy_Tree.Visit_Entity): Delete code that prevented copying some entities. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 438dea79977..e8120c2adda 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -23907,27 +23907,6 @@ package body Sem_Util is elsif EWA_Inner_Scope_Level > 0 then return; - -- Nothing to do when the entity does not denote a construct that - -- may appear within an N_Expression_With_Actions node. Relaxing - -- this restriction leads to a performance penalty. - - -- ??? this list is flaky, and may hide dormant bugs - -- Should functions be included??? - - -- Quantified expressions contain an entity declaration that must - -- always be replaced when the expander is active, even if it has - -- not been analyzed yet like e.g. in predicates. - - elsif Ekind (Id) not in E_Block - | E_Constant - | E_Label - | E_Procedure - | E_Variable - and then not Is_Entity_Of_Quantified_Expression (Id) - and then not Is_Type (Id) - then - return; - -- Nothing to do when the entity was already visited elsif NCT_Tables_In_Use