This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix assert on constant folding of extended types
AbandonedPublic

Authored by PeteSteinfeld on Aug 18 2020, 2:56 PM.

Details

Summary

When we define a derived type that extends another derived type, we can then
create a structure constructor that contains values for the fields of both the
child type and its parent. The compiler's internal representation of that
value contained the name of the parent type where a component name would
normally appear. This caused an assert during contant folding.

I fixed this by changing the function "CreateComponent()" in
lib/Semantics/expression.cpp to no longer include type names in values of type
"evaluate::Component".

I also added the test Evaluate/folding12.f90 to exercise the affected code.

Diff Detail

Event Timeline

PeteSteinfeld created this revision.Aug 18 2020, 2:56 PM
Herald added a project: Restricted Project. · View Herald Transcript
PeteSteinfeld requested review of this revision.Aug 18 2020, 2:56 PM
PeteSteinfeld added a project: Restricted Project.Aug 18 2020, 2:56 PM

Be advised, there is indeed a "parent component" in every derived type that extends another, and it can be used as if the parent type were a component in the type that extends it. Structure constructors must allow for this (C798).

Be advised, there is indeed a "parent component" in every derived type that extends another, and it can be used as if the parent type were a component in the type that extends it. Structure constructors must allow for this (C798).

Thanks for the pointer. I'll take a look and make sure that I cover that parent component both in tests and implementation.

DavidTruby resigned from this revision.Sep 1 2020, 3:39 AM
PeteSteinfeld abandoned this revision.Sep 4 2020, 8:54 AM

This change is superseded by D87151.