]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Avoid unused with warning with Extend_System
authorViljar Indus <indus@adacore.com>
Wed, 16 Oct 2024 09:01:38 +0000 (12:01 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 4 Nov 2024 15:57:58 +0000 (16:57 +0100)
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.

gcc/ada/sem_warn.adb

index 69e60be29660fcccb3666b58f71f9bc22fb02b48..2ffd631d6283895c37461e52286552585848c377 100644 (file)
@@ -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