From patchwork Tue Jul 5 08:30:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1652362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Tbl8QNO3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LcbmK053mz9s1l for ; Tue, 5 Jul 2022 18:43:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBDFD383A61D for ; Tue, 5 Jul 2022 08:43:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBDFD383A61D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657010590; bh=oO984Jogt8CjPwmyJ7rcZsUMPgLbn6PJvEBlH/vFpJE=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Tbl8QNO3u1R8KT4AQOjabNEEda8OyQfhaIMwobmLfGoI7MCIVcSeHuZoPXBqi/jMZ Kay2nGWOba4m66O1SFzLPId9kRYe7mqJ8kV5TPln2oQ8u7uyMCATdMQ6s3r938w7e7 GnyVA9KwGfLG7W4jU6EnJJ31iOMGpr+nWurgh+iM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id A6D70385AE6D for ; Tue, 5 Jul 2022 08:30:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A6D70385AE6D Received: by mail-wr1-x430.google.com with SMTP id v16so4998753wrd.13 for ; Tue, 05 Jul 2022 01:30:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=oO984Jogt8CjPwmyJ7rcZsUMPgLbn6PJvEBlH/vFpJE=; b=7BnD+7JHD/rOfYlcJqwJcgT/dop/RlFgC94sLRmYRw1lOTVnzJlaVSmWD3tJlMb655 nJoQd16bG5NIIz/LiD2LxUZZwlOzx0ZrAZtwa3droQss5z1zWA+odRfBWnH5G8fFU/Xs Jc1N+uPr9WNu4MYO9T+8acKYMHnsEU24Uf2ExPVutiz8geJHJNJO0YrQC+PSTTU2JiIO anKE5l6Si6Gy9mXphSezdGdP6Q1TogEtuE6xTQo1YG2KfmH3KMvR9mAH1Ezgq+vAKykZ E6ljs3lk8oqnUN+0HUMnCkMWeCPwEiSdAVSaihwJBq4Fw/+LW//TOv6Bj2QvuwNX/kGN E3pg== X-Gm-Message-State: AJIora9XWK/bZcDoG9z6hEKhmjV8pDrwBqU+Q9IoAVndCTqMQcjaiFWa FlLAGwAkR5rg+br6/QYlm87IYF/gs0oQiQ== X-Google-Smtp-Source: AGRyM1twbqXbs2hUGpur6wsJJbMFNB7UckCnOJJaLEJU9uNdLgRn78azwDkpQKpyNr6zWE/RKeBANA== X-Received: by 2002:a05:6000:1cf:b0:21d:656c:dd9f with SMTP id t15-20020a05600001cf00b0021d656cdd9fmr12077410wrx.15.1657009813267; Tue, 05 Jul 2022 01:30:13 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id f190-20020a1c38c7000000b0039c5328ad92sm18376235wma.41.2022.07.05.01.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 01:30:12 -0700 (PDT) Date: Tue, 5 Jul 2022 08:30:12 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Warn about obsolete uses of renamed Ada 83 packages Message-ID: <20220705083012.GA3198798@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Ada 83 packages like Unchecked_Conversion or Text_IO are obsolete since Ada 95. GNAT now warns about their uses when warnings on obsolescent featured (Annex J) is active. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Warning Message Control): Update description of switch -gnatwj. * gnat_ugn.texi: Regenerate. * sem_ch10.adb (Analyze_With_Clause): Warn on WITH clauses for obsolete renamed units; in Ada 83 mode do not consider predefined renamings to be obsolete. gcc/testsuite/ * gnat.dg/renaming1.adb: Update WITH clause. * gnat.dg/renaming1.ads: Likewise. * gnat.dg/warn29.adb: Likewise. diff --git a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst --- a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst +++ b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst @@ -3277,8 +3277,7 @@ of the pragma in the :title:`GNAT_Reference_manual`). If this warning option is activated, then warnings are generated for calls to subprograms marked with ``pragma Obsolescent`` and for use of features in Annex J of the Ada Reference Manual. In the - case of Annex J, not all features are flagged. In particular use - of the renamed packages (like ``Text_IO``) and use of package + case of Annex J, not all features are flagged. In particular, uses of package ``ASCII`` are not flagged, since these are very common and would generate many annoying positive warnings. The default is that such warnings are not generated. diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -11383,8 +11383,7 @@ This switch disables warnings on overlapping actuals in a call. If this warning option is activated, then warnings are generated for calls to subprograms marked with @code{pragma Obsolescent} and for use of features in Annex J of the Ada Reference Manual. In the -case of Annex J, not all features are flagged. In particular use -of the renamed packages (like @code{Text_IO}) and use of package +case of Annex J, not all features are flagged. In particular, uses of package @code{ASCII} are not flagged, since these are very common and would generate many annoying positive warnings. The default is that such warnings are not generated. diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -2597,11 +2597,19 @@ package body Sem_Ch10 is -- Note: this is not quite right if the user defines one of these units -- himself, but that's a marginal case, and fixing it is hard ??? - if Restriction_Check_Required (No_Obsolescent_Features) then - if In_Predefined_Renaming (U) then + if Ada_Version >= Ada_95 + and then In_Predefined_Renaming (U) + then + if Restriction_Check_Required (No_Obsolescent_Features) then Check_Restriction (No_Obsolescent_Features, N); Restriction_Violation := True; end if; + + if Warn_On_Obsolescent_Feature then + Error_Msg_N + ("renamed predefined unit is an obsolescent feature " + & "(RM J.1)?j?", N); + end if; end if; -- Check No_Implementation_Units violation diff --git a/gcc/testsuite/gnat.dg/renaming1.adb b/gcc/testsuite/gnat.dg/renaming1.adb --- a/gcc/testsuite/gnat.dg/renaming1.adb +++ b/gcc/testsuite/gnat.dg/renaming1.adb @@ -1,12 +1,12 @@ -- { dg-do compile} -- { dg-options "-gnatwa" } -with Text_IO; -use Text_IO; +with Ada.Text_IO; +use Ada.Text_IO; package body renaming1 is - procedure Fo (A : Text_IO.File_Access) is + procedure Fo (A : Ada.Text_IO.File_Access) is begin - if A = Text_IO.Standard_Output then + if A = Ada.Text_IO.Standard_Output then null; end if; end Fo; diff --git a/gcc/testsuite/gnat.dg/renaming1.ads b/gcc/testsuite/gnat.dg/renaming1.ads --- a/gcc/testsuite/gnat.dg/renaming1.ads +++ b/gcc/testsuite/gnat.dg/renaming1.ads @@ -1,4 +1,4 @@ -with Text_IO; +with Ada.Text_IO; package renaming1 is - procedure Fo (A : Text_IO.File_Access); + procedure Fo (A : Ada.Text_IO.File_Access); end; diff --git a/gcc/testsuite/gnat.dg/warn29.adb b/gcc/testsuite/gnat.dg/warn29.adb --- a/gcc/testsuite/gnat.dg/warn29.adb +++ b/gcc/testsuite/gnat.dg/warn29.adb @@ -1,7 +1,7 @@ -- { dg-do compile } -- { dg-options "-gnatwa" } -with Text_IO; use Text_IO; +with Ada.Text_IO; use Ada.Text_IO; package body Warn29 is procedure P (X : T; Y : Integer) is