From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 3BF643858403; Mon, 7 Nov 2022 08:38:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BF643858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667810286; bh=41xK142fz2Z7G1yc47c97KmoNqvX7QtpHb+JhdjygnQ=; h=From:To:Subject:Date:From; b=HfXnuxnzxFLg9wwzhLqO+0Sy9ylRi9Hq1tJS4PoP0DNNvtGjVjxRsj4aPJ3KrdzY2 +RcwegFu+6ov42+18TiidNiy2RIqsnmkO1Nwa6MWtXeR9JwLrCaZS8m5PSrBKRjBWY s/NSfmTLNfo/B6oNgtccVmDL5Tz6zUxQVhUPNQ2w= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3719] ada: Reject misplaced pragma Obsolescent X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: c7dc111e9d8e2eb83e45870a98c193f2fd681313 X-Git-Newrev: 74056e9411e0457c33ff5546a3563edb9ed09c99 Message-Id: <20221107083806.3BF643858403@sourceware.org> Date: Mon, 7 Nov 2022 08:38:06 +0000 (GMT) List-Id: https://gcc.gnu.org/g:74056e9411e0457c33ff5546a3563edb9ed09c99 commit r13-3719-g74056e9411e0457c33ff5546a3563edb9ed09c99 Author: Piotr Trojanek 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;