public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-3719] ada: Reject misplaced pragma Obsolescent
Date: Mon,  7 Nov 2022 08:38:06 +0000 (GMT)	[thread overview]
Message-ID: <20221107083806.3BF643858403@sourceware.org> (raw)

https://gcc.gnu.org/g:74056e9411e0457c33ff5546a3563edb9ed09c99

commit r13-3719-g74056e9411e0457c33ff5546a3563edb9ed09c99
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Wed Sep 7 15:02:04 2022 +0200

    ada: Reject misplaced pragma Obsolescent
    
    Pragma Obsolescent appearing before declaration was putting the
    Obsolescent flag on the Standard package, which is certainly wrong. The
    problem was that we relied on the Find_Lib_Unit_Name routine without
    sanitizing the pragma placement with Check_Valid_Library_Unit_Pragma.
    
    Part of cleaning up the warnings machinery to better handle references
    to unset objects.
    
    gcc/ada/
    
            * sem_prag.adb (Analyze_Pragma [Pragma_Obsolescent]): Reject
            misplaced pragma.

Diff:
---
 gcc/ada/sem_prag.adb | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 60ea681001a..471ef870fa7 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -20502,10 +20502,16 @@ package body Sem_Prag is
 
             if No (Decl) then
 
-               --  First case: library level compilation unit declaration with
+               --  Case 0: library level compilation unit declaration with
+               --  the pragma preceding the declaration.
+
+               if Nkind (Parent (N)) = N_Compilation_Unit then
+                  Pragma_Misplaced;
+
+               --  Case 1: library level compilation unit declaration with
                --  the pragma immediately following the declaration.
 
-               if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
+               elsif Nkind (Parent (N)) = N_Compilation_Unit_Aux then
                   Set_Obsolescent
                     (Defining_Entity (Unit (Parent (Parent (N)))));
                   return;

                 reply	other threads:[~2022-11-07  8:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221107083806.3BF643858403@sourceware.org \
    --to=dkm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).