[Ada] Potential access to uninitialized variable
authorArnaud Charlet <charlet@adacore.com>
Tue, 2 Jun 2020 06:57:11 +0000 (02:57 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 15 Jul 2020 13:42:39 +0000 (09:42 -0400)
gcc/ada/

* sem_aggr.adb (Resolve_Iterated_Component_Association): Ensure
Typ is never accessed uninitialized.

gcc/ada/sem_aggr.adb

index 31496bee1dd3cbd7521ef697fd99bb9d68c77fd4..d2419d9bde538b91a953162fe2371ab43e720aaa 100644 (file)
@@ -2677,7 +2677,7 @@ package body Sem_Aggr is
          Ent    : Entity_Id;
          Expr   : Node_Id;
          Id     : Entity_Id;
-         Typ    : Entity_Id;
+         Typ    : Entity_Id := Empty;
 
       begin
          if Present (Iterator_Specification (Comp)) then
@@ -2727,7 +2727,9 @@ package body Sem_Aggr is
          --  expression will reference the internal (synonym) loop variable.
 
          Enter_Name (Id);
+
          if No (Key_Type) then
+            pragma Assert (Present (Typ));
             Set_Etype (Id, Typ);
          else
             Set_Etype (Id, Key_Type);