From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id 4D3133858C29; Sun, 26 Nov 2023 19:20:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D3133858C29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701026400; bh=GuwVoQVFhaFVOYEvpa1JjMG/7p7uVmOIjJkKWsXFY2Q=; h=From:To:Subject:Date:From; b=GfM9F6Y31WjWF7S5iX8sOgaSduOC7yfwq7bJGQRyT37IYAANo6z4fRK2DdyhfQG8l VWv9e7zvmMpil4LQ3rdWb3UfetoWcz5maR9PbiLPDvPlFhUhnPmODmnDWoCTLpyuVW l0gJVJ6vzS4RdbZi3PM9Nrl9uKXiDpp0ZeUZ04qM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-5859] Fortran: avoid obsolescence warning for COMMON with submodule [PR111880] X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/master X-Git-Oldrev: 22f42cdcb091b7046f4d687342ac0913efb95838 X-Git-Newrev: c9d029ba2ceb435e31492c1f3f0fd3edf0e386be Message-Id: <20231126192000.4D3133858C29@sourceware.org> Date: Sun, 26 Nov 2023 19:20:00 +0000 (GMT) List-Id: https://gcc.gnu.org/g:c9d029ba2ceb435e31492c1f3f0fd3edf0e386be commit r14-5859-gc9d029ba2ceb435e31492c1f3f0fd3edf0e386be Author: Harald Anlauf Date: Thu Nov 23 22:48:38 2023 +0100 Fortran: avoid obsolescence warning for COMMON with submodule [PR111880] gcc/fortran/ChangeLog: PR fortran/111880 * resolve.cc (resolve_common_vars): Do not call gfc_add_in_common for symbols that are USE associated or used in a submodule. gcc/testsuite/ChangeLog: PR fortran/111880 * gfortran.dg/pr111880.f90: New test. Diff: --- gcc/fortran/resolve.cc | 4 ++-- gcc/testsuite/gfortran.dg/pr111880.f90 | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 81a14653a04..166b702cd9a 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -986,8 +986,8 @@ resolve_common_vars (gfc_common_head *common_block, bool named_common) /* gfc_add_in_common may have been called before, but the reported errors have been ignored to continue parsing. - We do the checks again here. */ - if (!csym->attr.use_assoc) + We do the checks again here, unless the symbol is USE associated. */ + if (!csym->attr.use_assoc && !csym->attr.used_in_submodule) { gfc_add_in_common (&csym->attr, csym->name, &common_block->where); gfc_notify_std (GFC_STD_F2018_OBS, "COMMON block at %L", diff --git a/gcc/testsuite/gfortran.dg/pr111880.f90 b/gcc/testsuite/gfortran.dg/pr111880.f90 new file mode 100644 index 00000000000..c0cd98a93d4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr111880.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! { dg-options "-std=f2018" } +! PR fortran/111880 - redundant warning of obsolescent COMMON with submodule + +module third_party_module + integer :: some_param + common /not_my_code/ some_param ! { dg-warning "COMMON block" } +end module third_party_module + +module foo + use third_party_module + interface + module subroutine bar() + end subroutine bar + end interface +end module foo + +submodule (foo) foo_submod ! We do not need a warning here! +contains + module procedure bar + end procedure bar +end submodule foo_submod