Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Linter warnings for inline calls with interface block imported from header with func.h suffix #332

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lint_rules/lint_rules/ifs_arpege_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,17 @@ def _get_external_symbols(cls, program_unit):
}

# Collect all symbols declared via intfb includees
c_includes = [
include for include in FindNodes(ir.Import).visit(program_unit.ir)
if include.c_import
]
external_symbols |= {
include.module[:-8].lower()
for include in FindNodes(ir.Import).visit(program_unit.ir)
if include.c_import and include.module.endswith('intfb.h')
include.module[:-8].lower() for include in c_includes
if include.module.endswith('.intfb.h')
}
external_symbols |= {
include.module[:-7].lower() for include in c_includes
if include.module.endswith('.func.h')
}

# Add locally declared interface symbols
Expand Down
12 changes: 9 additions & 3 deletions lint_rules/tests/test_ifs_arpege_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def test_missing_intfb_rule_subroutine(rules):
end subroutine local_intf_routine
end interface
#include "included_func.intfb.h"
#include "other_inc_func.func.h"

CALL IMPORTED_ROUTINE(A)
CALL INCLUDED_ROUTINE(B)
Expand All @@ -185,6 +186,8 @@ def test_missing_intfb_rule_subroutine(rules):
LOCAL_VAR = LOCAL_VAR + MIN(INCLUDED_FUNC(B), 1)
LOCAL_VAR = LOCAL_VAR + MISSING_FUNC(A, B)
LOCAL_VAR = LOCAL_VAR + DT%FUNC(A+B)
LOCAL_VAR = LOCAL_VAR + OTHER_INC_FUNC(A, 'STR VAL')
LOCAL_VAR = LOCAL_VAR + MISSING_INC_FUNC(A, 'STR VAL')
end subroutine missing_intfb_rule
""".strip()
source = Sourcefile.from_source(fcode)
Expand All @@ -193,11 +196,14 @@ def test_missing_intfb_rule_subroutine(rules):
run_linter(source, [rules.MissingIntfbRule], handlers=[handler])

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

Expand Down
Loading