summaryrefslogtreecommitdiffstats
path: root/Source/LexerParser/cmFortranParser.y
diff options
context:
space:
mode:
authorVitaly Mogulian <vitaly.mogulian@gmail.com>2022-07-30 17:07:14 (GMT)
committerBrad King <brad.king@kitware.com>2022-08-09 13:11:30 (GMT)
commit219a9b1e14084d16284c909ea055b3329750c909 (patch)
tree648c9bad4b00b5cc2869220f26e74641970221a1 /Source/LexerParser/cmFortranParser.y
parenta7211d6a2fd3097f88af94633b584d8ff76a8bce (diff)
downloadCMake-219a9b1e14084d16284c909ea055b3329750c909.zip
CMake-219a9b1e14084d16284c909ea055b3329750c909.tar.gz
CMake-219a9b1e14084d16284c909ea055b3329750c909.tar.bz2
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
Diffstat (limited to 'Source/LexerParser/cmFortranParser.y')
-rw-r--r--Source/LexerParser/cmFortranParser.y18
1 files changed, 7 insertions, 11 deletions
diff --git a/Source/LexerParser/cmFortranParser.y b/Source/LexerParser/cmFortranParser.y
index 07ca630..a5c8976 100644
--- a/Source/LexerParser/cmFortranParser.y
+++ b/Source/LexerParser/cmFortranParser.y
@@ -115,34 +115,30 @@ stmt:
cmFortranParser_RuleUse(parser, $2);
free($2);
}
-| MODULE WORD other EOSTMT {
+| MODULE WORD EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
- if (cmsysString_strcasecmp($2, "function") != 0 &&
- cmsysString_strcasecmp($2, "procedure") != 0 &&
- cmsysString_strcasecmp($2, "subroutine") != 0) {
- cmFortranParser_RuleModule(parser, $2);
- }
+ cmFortranParser_RuleModule(parser, $2);
free($2);
}
-| SUBMODULE LPAREN WORD RPAREN WORD other EOSTMT {
+| SUBMODULE LPAREN WORD RPAREN WORD EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleSubmodule(parser, $3, $5);
free($3);
free($5);
}
-| SUBMODULE LPAREN WORD COLON WORD RPAREN WORD other EOSTMT {
+| SUBMODULE LPAREN WORD COLON WORD RPAREN WORD EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleSubmoduleNested(parser, $3, $5, $7);
free($3);
free($5);
free($7);
}
-| INTERFACE WORD other EOSTMT {
+| INTERFACE WORD EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_SetInInterface(parser, true);
free($2);
}
-| END INTERFACE other EOSTMT {
+| END INTERFACE EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_SetInInterface(parser, false);
}
@@ -163,7 +159,7 @@ stmt:
free($3);
free($5);
}
-| INCLUDE STRING other EOSTMT {
+| INCLUDE STRING EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleInclude(parser, $2);
free($2);