[PATCH] D87151: [flang] Fix assert on constant folding of extended types

Pete Steinfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 12:10:12 PDT 2020


PeteSteinfeld updated this revision to Diff 291054.
PeteSteinfeld added a comment.

According to C799, every component in a structure constructor must have a
component-spec unless it has a default initialization.  So, aside from
components with default initializations, I don't believe that it's possible to
have gaps in a structure constructor.

Also, it looks like the compiler puts the components in a structure constructor
into their declared order, regardless of the order in which they appear in the
source.  The compiler also fills in components with default initializations.

I added test cases for structure constructors that depend on the values of
components with default initializers and for structure constructors that have
the components out of order in the source code.  But because of the points
listed above, these new tests did not require any changes to the compiler
source.

I don't understand the comment about not needed to recurse to collect the
components of the parent component.  In the current code, the function
StructureConstructor::Find() contains a recursive call to find components in a
parent component.  This code gets exercised by the following test that's part
of folding12.f90:

  type(child_type), parameter :: child_const9 = &
    child_type(parent_type(30), 31)
  integer, parameter :: int_const10 = child_const9%parent_field
  logical, parameter :: test_child5 = int_const10 == 30

Let me know if there's a form of structure constructor that this code doesn't
handle.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87151/new/

https://reviews.llvm.org/D87151

Files:
  flang/include/flang/Evaluate/expression.h
  flang/include/flang/Evaluate/type.h
  flang/lib/Evaluate/expression.cpp
  flang/lib/Evaluate/fold-implementation.h
  flang/lib/Evaluate/type.cpp
  flang/test/Evaluate/folding12.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87151.291054.patch
Type: text/x-patch
Size: 14696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200910/6bfda011/attachment.bin>


More information about the llvm-commits mailing list