aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-06-23 09:40:27 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2019-06-23 17:27:46 +0300
commitef53107f14a272784e3fa2b0daa67cbba6f5ac56 (patch)
treecb455b2358b6eb2b8bfa571deed3130befbd58fe
parent9042130e9a990497c0e53a43d2750fb907507f09 (diff)
downloadmeson-ef53107f14a272784e3fa2b0daa67cbba6f5ac56.zip
meson-ef53107f14a272784e3fa2b0daa67cbba6f5ac56.tar.gz
meson-ef53107f14a272784e3fa2b0daa67cbba6f5ac56.tar.bz2
BUGFIX: Fortran module regex handle more edge cases
-rw-r--r--mesonbuild/backend/ninjabackend.py8
-rw-r--r--test cases/fortran/12 submodule/child.f904
-rw-r--r--test cases/fortran/12 submodule/parent.f905
-rw-r--r--test cases/fortran/2 modules/mymod.f902
4 files changed, 15 insertions, 4 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 1e132b5..54535ff 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 45b5b41..dc076ec 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 9d087d0..77c8fb4 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 f8e7929..a45f5c9 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