[Ada] Skip overlay checks on protected components with expansion disabled
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 26 Mar 2021 08:02:33 +0000 (09:02 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 21 Jun 2021 10:45:03 +0000 (06:45 -0400)
gcc/ada/

* sem_util.adb (Find_Overlaid_Entity): Ignore references to
components and discriminants.

gcc/ada/sem_util.adb

index b59116e..2e102b9 100644 (file)
@@ -9437,6 +9437,18 @@ package body Sem_Util is
 
          if Is_Entity_Name (Expr) then
             Ent := Entity (Expr);
+
+            --  If expansion is disabled, then we might see an entity of a
+            --  protected component or of a discriminant of a concurrent unit.
+            --  Ignore such entities, because further warnings for overlays
+            --  expect this routine to only collect entities of entire objects.
+
+            if Ekind (Ent) in E_Component | E_Discriminant then
+               pragma Assert
+                 (not Expander_Active
+                  and then Is_Concurrent_Type (Scope (Ent)));
+               Ent := Empty;
+            end if;
             return;
 
          --  Check for components