This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix assert on character literal substrings as arguments
AbandonedPublic

Authored by PeteSteinfeld on Aug 7 2020, 8:35 PM.

Details

Summary

Character literal substrings used as arguments were causing asserts. This
happened when the code was trying to get the DynamicType of the substring. We
were only recording the DynamicType of the Designator on which the substring
was based. For character literal substrings, the Designator was a character
literal, and we weren't handling getting its type.

I fixed this by changing the GetType() method for DynamicType to check to
see if we were getting the type of a Substring and calling the GetType()
method of Substring in that case. This required adding a GetType() method
to the Substring class. This, in turn, required modifying the Substring
constructors to take the kind of the base substring as an argument.

I also changed the test resolve49.f90 with some tests, one of which causes
the original crash.

Diff Detail

Event Timeline

PeteSteinfeld created this revision.Aug 7 2020, 8:35 PM
Herald added a project: Restricted Project. · View Herald Transcript
PeteSteinfeld requested review of this revision.Aug 7 2020, 8:35 PM
PeteSteinfeld added a project: Restricted Project.Aug 7 2020, 8:36 PM
klausler added inline comments.Aug 10 2020, 9:25 AM
flang/include/flang/Evaluate/variable.h
305–306

Why does Substring need to have an explicit kind value -- can't this always be determined by the type of the parent string?

329

Can't the type be computed from that of the Parent?

I decided it would be easier to just add the necessary functionality to
Designator<T>::GetType() rather than add a GetType() method to Substring.

Reworked the implementation of GetType() based on feedback from Peter.

PeteSteinfeld abandoned this revision.Aug 13 2020, 8:13 AM

I've created a cleaner version of this -- https://reviews.llvm.org/D85908.