summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Diener <diener@cct.lsu.edu>2019-03-04 15:52:44 (GMT)
committerPeter Diener <diener@cct.lsu.edu>2019-03-04 15:52:44 (GMT)
commit39696fb565547639be518a9f92525904118b55c1 (patch)
treed643821bc7a7e2ad1ab53240372ec8d6526fd0eb
parentd6f6ae54248286a4501f683654f1bc54a2ade591 (diff)
downloadSCons-39696fb565547639be518a9f92525904118b55c1.zip
SCons-39696fb565547639be518a9f92525904118b55c1.tar.gz
SCons-39696fb565547639be518a9f92525904118b55c1.tar.bz2
Fix issue #3135.
This fixes issue #3135 regarding the issue with using type bound procedures in Fortran submodules. The fix consists of changing the regex used in the scanner and the emitter to ignore lines starting with: module subroutine and module function as these are used to define type bound procedures instead of modules named 'subroutine' or 'function'. The regex is case insensitive.
-rw-r--r--src/engine/SCons/Scanner/Fortran.py29
-rw-r--r--src/engine/SCons/Tool/FortranCommon.py3
2 files changed, 19 insertions, 13 deletions
diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py
index 6065bbd..171a2e8 100644
--- a/src/engine/SCons/Scanner/Fortran.py
+++ b/src/engine/SCons/Scanner/Fortran.py
@@ -285,21 +285,26 @@ def FortranScan(path_variable="FORTRANPATH"):
# but *not* the following:
#
# MODULE PROCEDURE procedure_name
+# MODULE SUBROUTINE subroutine_name
+# MODULE FUNCTION function_name
#
# Here is a breakdown of the regex:
#
-# (?i) : regex is case insensitive
-# ^\s* : any amount of white space
-# MODULE : match the string MODULE, case insensitive
-# \s+ : match one or more white space characters
-# (?!PROCEDURE) : but *don't* match if the next word matches
-# PROCEDURE (negative lookahead assertion),
-# case insensitive
-# (\w+) : match one or more alphanumeric characters
-# that make up the defined module name and
-# save it in a group
-
- def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+# (?i) : regex is case insensitive
+# ^\s* : any amount of white space
+# MODULE : match the string MODULE, case
+# insensitive
+# \s+ : match one or more white space
+# characters
+# (?!PROCEDURE|SUBROUTINE|FUNCTION) : but *don't* match if the next word
+# matches PROCEDURE, SUBROUTINE or
+# FUNCTION (negative lookahead
+# assertion), case insensitive
+# (\w+) : match one or more alphanumeric
+# characters that make up the defined
+# module name and save it in a group
+
+ def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE|SUBROUTINE|FUNCTION)(\w+)"""
scanner = F90Scanner("FortranScan",
"$FORTRANSUFFIXES",
diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py
index ec409c0..b16dee5 100644
--- a/src/engine/SCons/Tool/FortranCommon.py
+++ b/src/engine/SCons/Tool/FortranCommon.py
@@ -64,7 +64,8 @@ def _fortranEmitter(target, source, env):
if not node.exists() and not node.is_derived():
print("Could not locate " + str(node.name))
return ([], [])
- mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+ # This has to match the def_regex in the Fortran scanner
+ mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE|SUBROUTINE|FUNCTION)(\w+)"""
cre = re.compile(mod_regex,re.M)
# Retrieve all USE'd module names
modules = cre.findall(node.get_text_contents())