diff --git a/source/stylist/fortran.py b/source/stylist/fortran.py index 8cfb1b3..54e260c 100644 --- a/source/stylist/fortran.py +++ b/source/stylist/fortran.py @@ -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 diff --git a/unit-tests/fortran_pointer_init_test.py b/unit-tests/fortran_pointer_init_test.py index 2367362..1311fb4 100644 --- a/unit-tests/fortran_pointer_init_test.py +++ b/unit-tests/fortran_pointer_init_test.py @@ -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 ) @@ -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 == []