diff mbox series

[COMMITTED,23/30] ada: Deep copy of an expression sometimes fails to copy entities

Message ID 20240613133338.1809385-23-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/30] ada: Missing dynamic predicate checks | expand

Commit Message

Marc Poulhiès June 13, 2024, 1:33 p.m. UTC
From: Steve Baird <baird@adacore.com>

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 mbox series

Patch

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