]> gcc.gnu.org Git - gcc.git/commitdiff
ada: Deep copy of an expression sometimes fails to copy entities
authorSteve Baird <baird@adacore.com>
Tue, 30 Apr 2024 20:44:25 +0000 (13:44 -0700)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 13 Jun 2024 13:30:33 +0000 (15:30 +0200)
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.

gcc/ada/sem_util.adb

index 438dea7997787d48def6da7d37f904b996e863fe..e8120c2addacce475163fa997302cf6a65187d08 100644 (file)
@@ -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
This page took 0.078844 seconds and 5 git commands to generate.