]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Crash on use of 'Img on record type in expression
authorEd Schonberg <schonberg@adacore.com>
Mon, 10 May 2021 13:40:22 +0000 (09:40 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 6 Jul 2021 14:46:55 +0000 (14:46 +0000)
gcc/ada/

* exp_ch4.adb (Process_Transient_In_Expression): Ensure that
Fin_Context, used to insert finalization code for the
expression, is a list member: the value returned by
Find_Hook_Context may be an expression node when the transient
is part of a larger expression and it has a non-boolean type.

gcc/ada/exp_ch4.adb

index 21b2c2225eb5bddef0ff163067e96ff424dd4b14..738d651c69386e5e2880c451ab3d8d834994626c 100644 (file)
@@ -14952,7 +14952,17 @@ package body Exp_Ch4 is
       --       Hook := null;
       --    end if;
 
+      --  Note that the value returned by Find_Hook_Context may be an
+      --  operator node, which is not a list member. We must locate in the
+      --  tree the proper node after which to inwert the finaliation code.
+
       else
+         while not Is_List_Member (Fin_Context) loop
+            Fin_Context := Parent (Fin_Context);
+         end loop;
+
+         pragma Assert (Present (Fin_Context));
+
          Insert_Action_After (Fin_Context,
            Make_Implicit_If_Statement (Obj_Decl,
              Condition =>