Skip to content
Open
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
10 changes: 4 additions & 6 deletions src/fparser/two/Fortran2008/label_do_stmt_r816.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -----------------------------------------------------------------------------
# BSD 3-Clause License
#
# Copyright (c) 2023, Science and Technology Facilities Council.
# Copyright (c) 2023-2026, Science and Technology Facilities Council.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -37,12 +37,12 @@
label-do-stmt is [ do-construct-name : ] DO label [ loop-control ]

The only difference to F2003 rule R828 is that we force this rule to
use the F2008 version of loop-control
use the F2008 version of loop-control.

"""

from fparser.two.Fortran2003 import Label_Do_Stmt as Label_Do_Stmt_2003
from fparser.two.Fortran2008 import Loop_Control
from fparser.two.Fortran2008.loop_control_r818 import Loop_Control


class Label_Do_Stmt(Label_Do_Stmt_2003):
Expand All @@ -52,10 +52,8 @@ class Label_Do_Stmt(Label_Do_Stmt_2003):
"""

@staticmethod
def loop_control_cls():
def loop_control_cls() -> Loop_Control:
"""
:returns: Fortran2008 Loop_Control class.
:rtype: :py:class:`fparser.two.Fortran2008.Loop_Control`

"""
return Loop_Control
52 changes: 52 additions & 0 deletions src/fparser/two/tests/fortran2008/test_f2008_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) 2026 Science and Technology Facilities Council

# All rights reserved.

# Modifications made as part of the fparser project are distributed
# under the following license:

# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:

# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sys
import subprocess

"""Tests for the Fortran2008 module as a whole."""


def test_fortran2008_import_without_fortran2003_first():
"""
Check that `from fparser.two import Fortran2008` works in a
fresh interpreter, i.e. without Fortran2003 having been
imported first (which previously masked a circular import bug).
"""
result = subprocess.run(
[sys.executable, "-c", "from fparser.two import Fortran2008"],
capture_output=True,
text=True,
)
assert result.returncode == 0, result.stderr
Loading