Skip to content

Commit

Permalink
Merge branch 'master' into martin_fileinfo_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
SCHREIBER Martin committed Jan 8, 2025
2 parents 4d750d2 + 93741fd commit 623028b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

6) PR #2820 for #2773. Adds support for the Vernier timing library.

7) PR #2840 for #2839. Raise error in FortranReader if ignore_directives
is True but ignore_comments is True.

release 3.0.0 6th of December 2024

1) PR #2477 for #2463. Add support for Fortran Namelist statements.
Expand Down
Binary file modified psyclone.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions src/psyclone/psyir/frontend/fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class FortranReader():
for more precise control it also accepts a list of module names.
Defaults to False.
:raises ValueError: If ignore_directives is set to False but
ignore_comments is set to True.
'''
# Save parser object across instances to reduce the initialisation time
_parser = None
Expand All @@ -83,6 +86,11 @@ def __init__(self, free_form: bool = True, ignore_comments: bool = True,
if not self._parser:
self._parser = ParserFactory().create(std="f2008")
self._free_form = free_form
if ignore_comments and not ignore_directives:
raise ValueError(
"Setting ignore_directives to False in the FortranReader will"
" only have an effect if ignore_comments is also set to False."
)
self._ignore_comments = ignore_comments
self._processor = Fparser2Reader(ignore_directives,
last_comments_as_codeblocks,
Expand Down
9 changes: 9 additions & 0 deletions src/psyclone/tests/psyir/frontend/fortran_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,12 @@ def test_fortran_psyir_from_file(fortran_reader, tmpdir_factory):
assert node.preceding_comment == "Comment on assignment"
else:
assert node.preceding_comment == ""

# Check that the following combination raises an error
with pytest.raises(ValueError) as err:
FortranReader(ignore_comments=True, ignore_directives=False)
msg = (
"Setting ignore_directives to False in the FortranReader will"
" only have an effect if ignore_comments is also set to False."
)
assert msg in str(err.value)

0 comments on commit 623028b

Please sign in to comment.