[Ada] Do not free task for _parent

Message ID 20211201102544.GA1635366@adacore.com
State Committed
Commit e3102ec09c9b7e58312f3c18c841679db5778458
Headers
Series [Ada] Do not free task for _parent |

Commit Message

Pierre-Marie de Rodat Dec. 1, 2021, 10:25 a.m. UTC
  When a task was stored in a record, GNAT would mistakenly generate a
call to free_task twice, the first being correct and triggered by the
freeing of the record, the second being incorrect and generated from
recursing through the record's _parent.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_ch7.adb (Cleanup_Record): Don't process parent.
  

Patch

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -4629,8 +4629,9 @@  package body Exp_Ch7 is
 
       Comp := First_Component (U_Typ);
       while Present (Comp) loop
-         if Has_Task (Etype (Comp))
-           or else Has_Simple_Protected_Object (Etype (Comp))
+         if Chars (Comp) /= Name_uParent
+           and then (Has_Task (Etype (Comp))
+             or else Has_Simple_Protected_Object (Etype (Comp)))
          then
             Tsk :=
               Make_Selected_Component (Loc,