Skip to content

Commit b766924

Browse files
committed
Fix Linter warnings for inline calls with interface block imported from header with func.h suffix
1 parent b9be6f6 commit b766924

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

lint_rules/lint_rules/ifs_arpege_coding_standards.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,17 @@ def _get_external_symbols(cls, program_unit):
147147
}
148148

149149
# Collect all symbols declared via intfb includees
150+
c_includes = [
151+
include for include in FindNodes(ir.Import).visit(program_unit.ir)
152+
if include.c_import
153+
]
150154
external_symbols |= {
151-
include.module[:-8].lower()
152-
for include in FindNodes(ir.Import).visit(program_unit.ir)
153-
if include.c_import and include.module.endswith('intfb.h')
155+
include.module[:-8].lower() for include in c_includes
156+
if include.module.endswith('.intfb.h')
157+
}
158+
external_symbols |= {
159+
include.module[:-7].lower() for include in c_includes
160+
if include.module.endswith('.func.h')
154161
}
155162

156163
# Add locally declared interface symbols

lint_rules/tests/test_ifs_arpege_coding_standards.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def test_missing_intfb_rule_subroutine(rules):
175175
end subroutine local_intf_routine
176176
end interface
177177
#include "included_func.intfb.h"
178+
#include "other_inc_func.func.h"
178179
179180
CALL IMPORTED_ROUTINE(A)
180181
CALL INCLUDED_ROUTINE(B)
@@ -185,6 +186,8 @@ def test_missing_intfb_rule_subroutine(rules):
185186
LOCAL_VAR = LOCAL_VAR + MIN(INCLUDED_FUNC(B), 1)
186187
LOCAL_VAR = LOCAL_VAR + MISSING_FUNC(A, B)
187188
LOCAL_VAR = LOCAL_VAR + DT%FUNC(A+B)
189+
LOCAL_VAR = LOCAL_VAR + OTHER_INC_FUNC(A, 'STR VAL')
190+
LOCAL_VAR = LOCAL_VAR + MISSING_INC_FUNC(A, 'STR VAL')
188191
end subroutine missing_intfb_rule
189192
""".strip()
190193
source = Sourcefile.from_source(fcode)
@@ -193,11 +196,14 @@ def test_missing_intfb_rule_subroutine(rules):
193196
run_linter(source, [rules.MissingIntfbRule], handlers=[handler])
194197

195198
expected_messages = (
196-
(['[L9]', 'MissingIntfbRule', '`missing_routine`', '(l. 19)']),
197-
# (['[L9]', 'MissingIntfbRule', 'MISSING_FUNC', '(l. 15)']),
199+
(['[L9]', 'MissingIntfbRule', '`missing_routine`', '(l. 20)']),
200+
# (['[L9]', 'MissingIntfbRule', 'MISSING_FUNC', '(l. 25)']),
201+
(['[L9]', 'MissingIntfbRule', '`missing_inc_func`', '(l. 28)'])
198202
# NB:
199-
# - The missing function is not discovered because it is syntactically
203+
# - The `missing_func` is not discovered because it is syntactically
200204
# indistinguishable from an Array subscript
205+
# - The `missing_inc_func` has a string argument and can therefore be
206+
# identified as an inline call by fparser
201207
# - Calls to type-bound procedures are not reported
202208
)
203209

0 commit comments

Comments
 (0)