llvm-project/flang/lib/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
..
CMakeLists.txt [flang][directives] Use TableGen information for clause classes in parse-tree 2020-08-11 10:44:14 -04:00
call.cpp [flang] Fix frontend build with -DBUILD_SHARED_LIBS=On 2020-07-09 15:54:19 -07:00
character.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
characteristics.cpp [flang] Implement shape analysis of TRANSFER intrinsic function result 2020-08-13 09:56:24 -07:00
check-expression.cpp [flang] Check shape conformance on initializers 2020-08-31 16:27:06 -07:00
common.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
complex.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
constant.cpp [flang] Fixes for RESHAPE() 2020-07-30 19:05:06 -07:00
expression.cpp [flang] Fix assert on constant folding of extended types 2020-09-10 14:34:03 -07:00
fold-character.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
fold-complex.cpp [flang] Fix CMPLX folding with complex arguments 2020-07-31 10:26:08 +02:00
fold-designator.cpp [flang] Implement shape analysis of TRANSFER intrinsic function result 2020-08-13 09:56:24 -07:00
fold-implementation.h [flang] Fix assert on constant folding of extended types 2020-09-10 14:34:03 -07:00
fold-integer.cpp [flang] Make `TypeParamInquiry` monomorphic 2020-08-31 15:40:40 -07:00
fold-logical.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
fold-real.cpp [flang][NFC] Move and rework pgmath description used in folding 2020-07-03 10:19:33 +02:00
fold.cpp [flang] DATA stmt processing (part 3/4): Remaining prep work 2020-06-19 09:09:05 -07:00
formatting.cpp [flang] Make `TypeParamInquiry` monomorphic 2020-08-31 15:40:40 -07:00
host.cpp [flang] Fix setting mxcsr on MSVC 2020-07-08 07:25:25 -05:00
host.h Remove unneeded RoundDefault enumerator, and fix spelling in comments 2020-08-03 16:14:24 -07:00
initial-image.cpp [flang] Implement shape analysis of TRANSFER intrinsic function result 2020-08-13 09:56:24 -07:00
int-power.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
integer.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
intrinsics-library-templates.h [flang][NFC] Reformat files with current clang-format 2020-08-07 12:10:26 -07:00
intrinsics-library.cpp [flang] partially revert upstreamed code to support complex values in runtime support to avoid warnings. 2020-07-09 07:39:44 -07:00
intrinsics.cpp [Flang] Move markdown files(.MD) from documentation/ to docs/ 2020-08-18 15:14:15 +05:30
logical.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
real.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
shape.cpp [flang] Check shape conformance on initializers 2020-08-31 16:27:06 -07:00
static-data.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
tools.cpp [flang] Fix check for distinguishable operators/assignments 2020-09-10 07:22:55 -07:00
type.cpp [flang] Fix assert on constant folding of extended types 2020-09-10 14:34:03 -07:00
variable.cpp [flang] Make `TypeParamInquiry` monomorphic 2020-08-31 15:40:40 -07:00