[all-commits] [llvm/llvm-project] b34f11: [flang] Fix assert on constant folding of extended...
Pete Steinfeld via All-commits
all-commits at lists.llvm.org
Thu Sep 10 14:38:56 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: b34f116856306d97aa9244a46eb1643a8ddd49a8
https://github.com/llvm/llvm-project/commit/b34f116856306d97aa9244a46eb1643a8ddd49a8
Author: Peter Steinfeld <psteinfeld at nvidia.com>
Date: 2020-09-10 (Thu, 10 Sep 2020)
Changed paths:
M flang/include/flang/Evaluate/expression.h
M flang/include/flang/Evaluate/type.h
M flang/lib/Evaluate/expression.cpp
M flang/lib/Evaluate/fold-implementation.h
M flang/lib/Evaluate/type.cpp
A flang/test/Evaluate/folding12.f90
Log Message:
-----------
[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
More information about the All-commits
mailing list