Skip to content

Commit

Permalink
#1960 tidying following conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
arporter committed Jan 30, 2024
1 parent 3ff8391 commit d9fb9fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/psyclone/psyir/nodes/array_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def datatype(self):

# Otherwise, we're accessing a single element of the array.
if type(self.symbol) is Symbol:
return DeferredType()
return UnresolvedType()
if isinstance(self.symbol.datatype, UnsupportedType):
if (isinstance(self.symbol.datatype, UnsupportedFortranType) and
self.symbol.datatype.partial_datatype):
Expand Down
26 changes: 13 additions & 13 deletions src/psyclone/tests/psyir/nodes/array_reference_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,23 +532,23 @@ def test_array_datatype():
aref = ArrayReference.create(asym, [two.copy()])
assert aref.datatype is stype
# Reference to a single element of an array of UnsupportedType.
unsuppored_sym = DataSymbol(
"unsuppored",
UnsupportedFortranType("real, dimension(5), pointer :: unsuppored"))
aref = ArrayReference.create(unsuppored_sym, [two.copy()])
unsupported_sym = DataSymbol(
"unsupported",
UnsupportedFortranType("real, dimension(5), pointer :: unsupported"))
aref = ArrayReference.create(unsupported_sym, [two.copy()])
assert isinstance(aref.datatype, UnresolvedType)
# Reference to a single element of an array of UnsupportedType but with
# partial type information.
not_quite_unsuppored_sym = DataSymbol(
"unsuppored",
not_quite_unsupported_sym = DataSymbol(
"unsupported",
UnsupportedFortranType(
"real, dimension(5), pointer :: unsuppored",
"real, dimension(5), pointer :: unsupported",
partial_datatype=ArrayType(REAL_SINGLE_TYPE, [5])))
bref = ArrayReference.create(not_quite_unsuppored_sym, [two.copy()])
bref = ArrayReference.create(not_quite_unsupported_sym, [two.copy()])
assert bref.datatype == REAL_SINGLE_TYPE
# A sub-array of UnsupportedFortranType.
aref3 = ArrayReference.create(
unsuppored_sym, [Range.create(two.copy(), four.copy())])
unsupported_sym, [Range.create(two.copy(), four.copy())])
# We know the result is an ArrayType
assert isinstance(aref3.datatype, ArrayType)
assert aref3.datatype.shape[0].lower == one
Expand All @@ -558,18 +558,18 @@ def test_array_datatype():
assert isinstance(aref3.datatype.intrinsic, UnresolvedType)
# A whole array of UnsupportedType should simply have the same datatype as
# the original symbol.
aref4 = ArrayReference.create(not_quite_unsuppored_sym, [":"])
assert aref4.datatype == not_quite_unsuppored_sym.datatype
aref4 = ArrayReference.create(not_quite_unsupported_sym, [":"])
assert aref4.datatype == not_quite_unsupported_sym.datatype
# When the Reference is just to a Symbol. Although `create` forbids this,
# it is possible for the fparser2 frontend to create such a construct.
generic_sym = Symbol("existential")
aref5 = ArrayReference(generic_sym)
aref5.addchild(two.copy())
assert isinstance(aref5.datatype, DeferredType)
assert isinstance(aref5.datatype, UnresolvedType)
aref5.addchild(Range.create(two.copy(), four.copy()))
dtype5 = aref5.datatype
assert isinstance(dtype5, ArrayType)
assert isinstance(dtype5.intrinsic, DeferredType)
assert isinstance(dtype5.intrinsic, UnresolvedType)
assert dtype5.shape[0].lower.value == "1"
assert dtype5.shape[0].upper.debug_string() == "(4 - 2) / 1 + 1"

Expand Down

0 comments on commit d9fb9fa

Please sign in to comment.