Skip to content

Commit

Permalink
Don't baulk on intent(in) pointers (#120)
Browse files Browse the repository at this point in the history
* Replace `setup.py` script with `stylist.toml` configuration file.

* Turned out the `.toml` file wasn't being used.

* Discovered mistake in pull request workflow.

* Since `setup.py` has been removed we can't check it with `mypy`

* Added Conda Forge badge to ReadMe.

* Constrain fParser version.

* Remove reference to setup.py from documentation.

* Pointer initialisation rules doesn't apply to abstract interfaces.

* Or normal interfaces.
  • Loading branch information
MatthewHambley committed Nov 27, 2023
1 parent 248c16d commit 9cac327
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
7 changes: 7 additions & 0 deletions source/stylist/fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,13 @@ def _data(root: Fortran2003.Base,
attribute_specification):
continue

# @todo This is quite ugly
#
potential_interface_block = data_declaration.parent.parent.parent
if isinstance(potential_interface_block,
Fortran2003.Interface_Block):
continue

for entity in fp_walk(data_declaration, entity_declaration):
if str(fp_get_child(entity, Fortran2003.Name)) in ignore_names:
continue
Expand Down
30 changes: 28 additions & 2 deletions unit-tests/fortran_pointer_init_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def test_pointer_init(self,

def test_arguments_without_intent(self):
"""
Checks that the rule can cope with arguments which do not specify an
intent.
Checks that the rule can cope with arguments which should not specify
an intent.
"""
source_text = dedent('''
subroutine my_sub( first, second )
Expand All @@ -192,3 +192,29 @@ def test_arguments_without_intent(self):

issue_descriptions = [str(issue) for issue in issues]
assert issue_descriptions == []

def test_abstract_interface(self):
"""
Checks that the rule can cope with arguments which are intent in and
user defined types.
"""
source_text = dedent(
'''
module this_mod
abstract interface
subroutine their_sub( first, second )
implicit none
type(thang_type), intent(in), pointer :: first
class(thang_type), pointer, intent(in) :: second
end subroutine their_sub
end interface
end module this_mod
''').strip()
source_reader = SourceStringReader(source_text)
source = FortranSource(source_reader)

test_unit = stylist.fortran.MissingPointerInit()
issues = test_unit.examine(source)

issue_descriptions = [str(issue) for issue in issues]
assert issue_descriptions == []

0 comments on commit 9cac327

Please sign in to comment.