diff mbox series

[COMMITTED,30/38] ada: Avoid unused with warning with Extend_System

Message ID 20241104161116.1431659-30-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/38] ada: Fix asymmetry in resolution of unary intrinsic operators | expand

Commit Message

Marc Poulhiès Nov. 4, 2024, 4:11 p.m. UTC
From: Viljar Indus <indus@adacore.com>

When the Extend_System pragma is used then we are supposed
to check the extended system for referenced entities. Otherwise
we would get an incorrect unused with warning.

This was previously done on body files but it should also be
done specs as well.

gcc/ada/ChangeLog:

	* sem_warn.adb (Check_One_Unit): When a system extension is
	present always check entities from that unit before marking
	the unit unreferenced.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_warn.adb | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index 69e60be2966..2ffd631d628 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -2583,14 +2583,17 @@  package body Sem_Warn is
 
                         if No (Ent) then
 
+                           --  Check entities in the extended system if
+                           --  specified.
+
+                           if Check_System_Aux (Lunit) then
+                              null;
+
                            --  If in spec, just set the flag
 
-                           if Unit = Spec_Unit then
+                           elsif Unit = Spec_Unit then
                               Set_No_Entities_Ref_In_Spec (Item);
 
-                           elsif Check_System_Aux (Lunit) then
-                              null;
-
                            --  Else the warning may be needed
 
                            else