Skip to content

Commit

Permalink
pr #2396. Lots or character tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertford committed Dec 11, 2023
1 parent c3829cb commit 380201a
Show file tree
Hide file tree
Showing 2 changed files with 279 additions and 18 deletions.
31 changes: 22 additions & 9 deletions src/psyclone/psyir/frontend/fparser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3338,20 +3338,24 @@ def _select_type_construct_handler(self, node, parent):
# a kind specification
kind_spec_value = type_spec.children[1].children[1]
type_name = f"{type_name}_{kind_spec_value}"
elif isinstance(
type_spec.children[1],
Fortran2003.Length_Selector):
# This is a character type
value = type_spec.children[1].children[1]
if not isinstance(
value, (Fortran2003.Type_Param_Value,
Fortran2003.Int_Literal_Constant)):
elif walk(type_spec, Fortran2003.Length_Selector):
# This is a character intrinsic spec
length_selector = walk(type_spec, Fortran2003.Length_Selector)[0]
if isinstance(length_selector.children[1], Fortran2003.Int_Literal_Constant):
value = length_selector.children[1]

Check warning on line 3345 in src/psyclone/psyir/frontend/fparser2.py

View check run for this annotation

Codecov / codecov/patch

src/psyclone/psyir/frontend/fparser2.py#L3345

Added line #L3345 was not covered by tests
elif isinstance(length_selector.children[1], Fortran2003.Type_Param_Value):
value = length_selector.children[1]
else:
raise NotImplementedError(

Check warning on line 3349 in src/psyclone/psyir/frontend/fparser2.py

View check run for this annotation

Codecov / codecov/patch

src/psyclone/psyir/frontend/fparser2.py#L3349

Added line #L3349 was not covered by tests
f"Only character strings of type '*' or "
f"'literal' for the selector variable are "
f"currently supported in the PSyIR, but found "
f"'{child.children[1]}' in the select "
f"clause '{str(node)}'.")
if str(value) == "*":
value = "star"
elif str(value) == ":":
value = "colon"

Check warning on line 3358 in src/psyclone/psyir/frontend/fparser2.py

View check run for this annotation

Codecov / codecov/patch

src/psyclone/psyir/frontend/fparser2.py#L3357-L3358

Added lines #L3357 - L3358 were not covered by tests
type_name = f"{type_name}_{value}"
else:
# type or Class type
Expand Down Expand Up @@ -3402,8 +3406,17 @@ def _select_type_construct_handler(self, node, parent):
tmp = f"type({tmp})"
pointer_type = UnknownFortranType(
f"{tmp}, pointer :: {pointer_name}\n")
pointer_symbol = DataSymbol(pointer_name, pointer_type)
if guard_type[idx] in ["CHARACTER(LEN = *)", "CHARACTER*(*)"]:
pointer_symbol = DataSymbol(
pointer_name, pointer_type,
interface=ArgumentInterface(
ArgumentInterface.Access.WRITE))
else:
pointer_symbol = DataSymbol(pointer_name, pointer_type)

parent.scope.symbol_table.add(pointer_symbol)
if guard_type[idx] in ["CHARACTER(LEN = *)", "CHARACTER*(*)"]:
parent.scope.symbol_table._argument_list.append(pointer_symbol)
pointer_symbols.append(pointer_symbol)
if (intrinsic_type_name[idx] and
intrinsic_type_name[idx].lower() == "character"):
Expand Down
Loading

0 comments on commit 380201a

Please sign in to comment.