1. [flang] Fix assert on constant folding of extended types (details)
Commit b34f116856306d97aa9244a46eb1643a8ddd49a8 by psteinfeld
[flang] Fix assert on constant folding of extended types

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 contains the name of the parent type where a component name would
normally appear.  This caused an assert during contant folding.

There are three cases for components that appear in structure constructors.
The first is the normal case of a component appearing in a structure
constructor for its type.

  The second is a component of the parent (or grandparent) type appearing in a
  structure constructor for the child type.

  The third is the parent type component, which can appear in the structure
  constructor of its child.

There are also cases where the component can be arrays.

I created the test case folding12.f90 that covers all of these cases and
modified the code to handle them.

Most of my changes were to the "Find()" method of the type
"StructureConstructor" where I added code to cover the second and third cases
described above.  To handle these cases, I needed to create a
"StructureConstructor" for the parent type component and return it.  To handle
returning a newly created "StructureConstructor", I changed the return type of
"Find()" to be "std::optional" rather than an ordinary pointer.

This change supersedes D86172.

Differential Revision:
The file was modifiedflang/lib/Evaluate/fold-implementation.h (diff)
The file was modifiedflang/include/flang/Evaluate/type.h (diff)
The file was modifiedflang/include/flang/Evaluate/expression.h (diff)
The file was addedflang/test/Evaluate/folding12.f90
The file was modifiedflang/lib/Evaluate/type.cpp (diff)
The file was modifiedflang/lib/Evaluate/expression.cpp (diff)