From: Harald Anlauf Date: Thu, 23 Nov 2023 21:48:38 +0000 (+0100) Subject: Fortran: avoid obsolescence warning for COMMON with submodule [PR111880] X-Git-Tag: releases/gcc-11.5.0~465 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=246760b37f1239b3b97c20fb4a914f21154389a3;p=thirdparty%2Fgcc.git Fortran: avoid obsolescence warning for COMMON with submodule [PR111880] gcc/fortran/ChangeLog: PR fortran/111880 * resolve.c (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. (cherry picked from commit c9d029ba2ceb435e31492c1f3f0fd3edf0e386be) --- diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index bc38444ea75f..531f72b992ea 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -965,8 +965,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 000000000000..c0cd98a93d4d --- /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