llvm-project/flang/test/Evaluate
Peter Steinfeld b34f116856 [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: https://reviews.llvm.org/D87151
2020-09-10 14:34:03 -07:00
..
folding01.f90 [flang] Fix CMPLX folding with complex arguments 2020-07-31 10:26:08 +02:00
folding02.f90 [flang][NFC] Simplify semantics test scripts 2020-05-11 11:49:25 -07:00
folding03.f90 [flang][NFC] Simplify semantics test scripts 2020-05-11 11:49:25 -07:00
folding04.f90 [flang] AMAX0, MIN1... rewrite to MAX/MIN: make result conversion explicit 2020-06-18 08:14:58 +02:00
folding05.f90 [flang][NFC] Simplify semantics test scripts 2020-05-11 11:49:25 -07:00
folding06.f90 [flang][NFC] Simplify semantics test scripts 2020-05-11 11:49:25 -07:00
folding07.f90 [flang][NFC] Simplify semantics test scripts 2020-05-11 11:49:25 -07:00
folding08.f90 [flang] Check shape conformance on initializers 2020-08-31 16:27:06 -07:00
folding09.f90 [flang][NFC] Simplify semantics test scripts 2020-05-11 11:49:25 -07:00
folding10.f90 [flang] Implement shape analysis of TRANSFER intrinsic function result 2020-08-13 09:56:24 -07:00
folding11.f90 [flang] Correct manipulation of mixed complex expressions 2020-08-13 09:04:00 -07:00
folding12.f90 [flang] Fix assert on constant folding of extended types 2020-09-10 14:34:03 -07:00
test_folding.sh [flang][NFC] Simplify semantics test scripts 2020-05-11 11:49:25 -07:00