Skip to content

Commit

Permalink
Fortran: avoid obsolescence warning for COMMON with submodule [PR111880]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
harald-anlauf committed Nov 26, 2023
1 parent 22f42cd commit c9d029b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcc/fortran/resolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 22 additions & 0 deletions gcc/testsuite/gfortran.dg/pr111880.f90
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c9d029b

Please sign in to comment.