diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 1e132b5b1..54535ff52 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -38,10 +38,10 @@ from ..mesonlib import get_compiler_for_source, has_path_sep from .backends import CleanTrees from ..build import InvalidArguments -FORTRAN_INCLUDE_PAT = r"#?include\s*['\"](\w+\.\w+)['\"]" -FORTRAN_MODULE_PAT = r"\s*\bmodule\b\s+(?!procedure)(\w+)" -FORTRAN_SUBMOD_PAT = r"\s*submodule\s*\((\w+:?\w+)\)\s*(\w+)" -FORTRAN_USE_PAT = r"\s*use,?\s*(?:non_intrinsic)?\s*(?:::)?\s*(\w+)" +FORTRAN_INCLUDE_PAT = r"^\s*#?include\s*['\"](\w+\.\w+)['\"]" +FORTRAN_MODULE_PAT = r"^\s*\bmodule\b\s+(\w+)\s*(?:!+.*)*$" +FORTRAN_SUBMOD_PAT = r"^\s*\bsubmodule\b\s*\((\w+:?\w+)\)\s*(\w+)" +FORTRAN_USE_PAT = r"^\s*use,?\s*(?:non_intrinsic)?\s*(?:::)?\s*(\w+)" if mesonlib.is_windows(): quote_func = lambda s: '"{}"'.format(s) diff --git a/test cases/fortran/12 submodule/child.f90 b/test cases/fortran/12 submodule/child.f90 index 45b5b41c5..dc076ec47 100644 --- a/test cases/fortran/12 submodule/child.f90 +++ b/test cases/fortran/12 submodule/child.f90 @@ -6,5 +6,9 @@ module procedure pi2tau pi2tau = 2*pi end procedure pi2tau +module procedure good +print *, 'Good!' +end procedure good + end submodule parent diff --git a/test cases/fortran/12 submodule/parent.f90 b/test cases/fortran/12 submodule/parent.f90 index 9d087d0d1..77c8fb4f4 100644 --- a/test cases/fortran/12 submodule/parent.f90 +++ b/test cases/fortran/12 submodule/parent.f90 @@ -6,6 +6,9 @@ interface module elemental real function pi2tau(pi) real, intent(in) :: pi end function pi2tau + +module subroutine good() +end subroutine good end interface end module parent @@ -17,4 +20,6 @@ tau = pi2tau(pi) print *,'pi=',pi, 'tau=', tau +call good() + end program diff --git a/test cases/fortran/2 modules/mymod.f90 b/test cases/fortran/2 modules/mymod.f90 index f8e7929ed..a45f5c982 100644 --- a/test cases/fortran/2 modules/mymod.f90 +++ b/test cases/fortran/2 modules/mymod.f90 @@ -1,3 +1,5 @@ +! module circle to be sure module regex doesn't allow commented modules + module circle implicit none