public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1498] [Ada] Warn about obsolete uses of renamed Ada 83 packages Date: Tue, 5 Jul 2022 08:31:25 +0000 (GMT) [thread overview] Message-ID: <20220705083125.6833A3839824@sourceware.org> (raw) https://gcc.gnu.org/g:5a387a2b8f58a238acfea6ec820a0fd44057a09a commit r13-1498-g5a387a2b8f58a238acfea6ec820a0fd44057a09a Author: Piotr Trojanek <trojanek@adacore.com> Date: Thu May 19 20:42:42 2022 +0200 [Ada] Warn about obsolete uses of renamed Ada 83 packages 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. 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: --- .../doc/gnat_ugn/building_executable_programs_with_gnat.rst | 3 +-- gcc/ada/gnat_ugn.texi | 3 +-- gcc/ada/sem_ch10.adb | 12 ++++++++++-- gcc/testsuite/gnat.dg/renaming1.adb | 8 ++++---- gcc/testsuite/gnat.dg/renaming1.ads | 4 ++-- gcc/testsuite/gnat.dg/warn29.adb | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) 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 index 2e835f2f353..c0eeca43cf0 100644 --- 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 index a080cd43871..cfd9a87395d 100644 --- 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 index 9b9a9f147cc..8c1c00cc8b9 100644 --- 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 index d033c9abce2..c85e50abd40 100644 --- 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 index 893f423d532..fba216a5318 100644 --- 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 index ec3b9eebf6e..eeb3a89925d 100644 --- 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
reply other threads:[~2022-07-05 8:31 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=20220705083125.6833A3839824@sourceware.org \ --to=pmderodat@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: linkBe 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).