diff mbox series

[Ada] Task arrays trigger spurious unreferenced warnings

Message ID 20220110094131.GA585995@adacore.com
State New
Headers show
Series [Ada] Task arrays trigger spurious unreferenced warnings | expand

Commit Message

Pierre-Marie de Rodat Jan. 10, 2022, 9:41 a.m. UTC
This patch fixes an issue in the compiler whereby objects of task arrays
would trigger spurious unreferenced warnings.

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

gcc/ada/

	* sem_warn.adb (Check_References): Handle arrays of tasks
	similar to task objects.
diff mbox series

Patch

diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1700,7 +1700,14 @@  package body Sem_Warn is
               and then ((Ekind (E1) /= E_Variable
                           and then Ekind (E1) /= E_Constant
                           and then Ekind (E1) /= E_Component)
-                         or else not Is_Task_Type (E1T))
+
+                         --  Check that E1T is not a task or an array of them
+
+                         or else not
+                           (Is_Task_Type (E1T)
+                             or else (Ekind (E1T) in Array_Kind
+                                       and then Is_Task_Type
+                                                  (Component_Type (E1T)))))
 
               --  For subunits, only place warnings on the main unit itself,
               --  since parent units are not completely compiled.