CMake/Tests/FortranModules/Submodules/obfuscated_parent.f90
Vitaly Mogulian 219a9b1e14 Fortran: Fix suprious dependencies with submodules
In commit 695f0d0d3a (cmFortranParser: Parse keywords as lexical tokens,
2016-09-05, v3.7.0-rc1~150^2) we created keyword-specific variants of
the original `USE WORD other EOSTMT` production, such as
`MODULE WORD other EOSTMT` and `INTERFACE WORD other EOSTMT`.  The same
pattern was used by more keyword-specific productions in commit b5ac8b8aa7
(Fortran: Add support for submodule syntax in dependency scanning,
2016-09-05, v3.7.0-rc1~73^2~1).

The postfix part (`other`) of several keyword-specific productions is
not needed to match Fortran syntax.  See the Fortran 2018 standard,
para.4.1.4/1 on p.28, para.14.2.1/2 on pp.293-294.  The postfix is
needed only for a case of operator 'use':

    use <module-name> [, only : <list-of-vars>]

The unnecessary postfix matching from the keyword-specific productions
such as module, submodule, and interface declarations can cause spurious
module dependencies to be detected, so remove it.

Extend the test suite with examples covering the previously-broken
cases.

Fixes: #18427
2022-08-09 09:11:30 -04:00

34 lines
824 B
Fortran

! This module has two procedures from the "parent" module
! but it has different combinations 'module <word>' phrases
! in breaked lines for test of modules dependencies detection
! Module declaration on breaked line with reminder
module &
obfuscated_parent; implicit none
interface
! Boolean module function
module logical &
function child_function_obf() result(child_stuff)
end function
! Module subroutine
module subroutine &
grandchild_subroutine_obf()
end subroutine
end interface
contains
module logical function child_function_obf() result(child_stuff)
child_stuff=.true.
end function
module subroutine grandchild_subroutine_obf()
print *,"Test passed."
end subroutine
end module obfuscated_parent