public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-839] [Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects
@ 2022-05-30  8:31 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-30  8:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:507ed659e0110e3cba9aa8bba875768833d7b7ea

commit r13-839-g507ed659e0110e3cba9aa8bba875768833d7b7ea
Author: Justin Squirek <squirek@adacore.com>
Date:   Thu Apr 21 20:35:20 2022 +0000

    [Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects
    
    This patch corrects an error in the compiler whereby spurious
    unreferenced warnings are generated on formal parameters of null generic
    subprograms.
    
    These changes also fix the parsing of aspects on formal parameters such
    that the aspects now get properly set for all formal parameters in a
    parameter list.
    
    gcc/ada/
    
            * par-ch6.adb (P_Formal_Part): Set Aspect_Specifications on all
            formals instead of just the last in a formal id list.
            * sem_ch6.adb (Analyze_Null_Procedure): Mark expanded null
            generic procedures as trivial in order to avoid spurious
            unreferenced warnings.

Diff:
---
 gcc/ada/par-ch6.adb | 22 ++++++++++++++++++++++
 gcc/ada/sem_ch6.adb |  5 +++++
 2 files changed, 27 insertions(+)

diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb
index 2832fd4a82e..95fa9374c9d 100644
--- a/gcc/ada/par-ch6.adb
+++ b/gcc/ada/par-ch6.adb
@@ -1656,6 +1656,28 @@ package body Ch6 is
 
             P_Aspect_Specifications (Specification_Node, False);
 
+            --  Set the aspect specifications for previous Ids
+
+            if Has_Aspects (Specification_Node)
+              and then Prev_Ids (Specification_Node)
+            then
+               --  Loop through each previous id
+
+               declare
+                  Prev_Id : Node_Id := Prev (Specification_Node);
+               begin
+                  loop
+                     Set_Aspect_Specifications
+                       (Prev_Id, Aspect_Specifications (Specification_Node));
+
+                     --  Exit when we reach the first parameter in the list
+
+                     exit when not Prev_Ids (Prev_Id);
+                     Prev_Id := Prev (Prev_Id);
+                  end loop;
+               end;
+            end if;
+
             if Token = Tok_Right_Paren then
                Scan;  -- past right paren
                exit Specification_Loop;
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index cb2ed7c5e45..8ca29746e43 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -2063,6 +2063,11 @@ package body Sem_Ch6 is
          Analyze_Generic_Subprogram_Body (Null_Body, Prev);
          Is_Completion := True;
 
+         --  Mark the newly generated subprogram body as trivial
+
+         Set_Is_Trivial_Subprogram
+           (Defining_Unit_Name (Specification (Null_Body)));
+
          goto Leave;
 
       else


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-30  8:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30  8:31 [gcc r13-839] [Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).