llvm-project/flang/lib/Evaluate
peter klausler 641ede93ef [flang] Improve initializer semantics, esp. for component default values
This patch plugs many holes in static initializer semantics, improves error
messages for default initial values and other component properties in
parameterized derived type instantiations, and cleans up several small
issues noticed during development.  We now do proper scalar expansion,
folding, and type, rank, and shape conformance checking for component
default initializers in derived types and PDT instantiations.
The initial values of named constants are now guaranteed to have been folded
when installed in the symbol table, and are no longer folded or
scalar-expanded at each use in expression folding.  Semantics documentation
was extended with information about the various kinds of initializations
in Fortran and when each of them are processed in the compiler.

Some necessary concomitant changes have bulked this patch out a bit:
* contextual messages attachments, which are now produced for parameterized
  derived type instantiations so that the user can figure out which
  instance caused a problem with a component, have been added as part
  of ContextualMessages, and their implementation was debugged
* several APIs in evaluate::characteristics was changed so that a FoldingContext
  is passed as an argument rather than just its intrinsic procedure table;
  this affected client call sites in many files
* new tools in Evaluate/check-expression.cpp to determine when an Expr
  actually is a single constant value and to validate a non-pointer
  variable initializer or object component default value
* shape conformance checking has additional arguments that control
  whether scalar expansion is allowed
* several now-unused functions and data members noticed and removed
* several crashes and bogus errors exposed by testing this new code
  were fixed
* a -fdebug-stack-trace option to enable LLVM's stack tracing on
  a crash, which might be useful in the future

TL;DR: Initialization processing does more and takes place at the right
times for all of the various kinds of things that can be initialized.

Differential Review: https://reviews.llvm.org/D92783
2020-12-07 14:40:41 -08:00
..
CMakeLists.txt [flang] Fix build with BUILD_SHARED_LIBS=ON and FLANG_BUILD_NEW_DRIVER=ON 2020-10-15 13:03:55 +02: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] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
check-expression.cpp [flang] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
common.cpp [flang] Add isnan() extension intrinsic function, with folding 2020-11-11 11:40:57 -08: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] Rework host runtime folding and enable REAL(2) folding with it. 2020-10-14 16:40:44 +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] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
fold-integer.cpp [flang] Make `TypeParamInquiry` monomorphic 2020-08-31 15:40:40 -07:00
fold-logical.cpp [flang] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
fold-real.cpp [flang] Rework host runtime folding and enable REAL(2) folding with it. 2020-10-14 16:40:44 +02:00
fold.cpp [flang] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
formatting.cpp [flang] Unsplit COMPLEX operations 2020-11-16 09:39:03 -08:00
host.cpp [flang] Fix setting mxcsr on MSVC 2020-07-08 07:25:25 -05:00
host.h [flang] Rework host runtime folding and enable REAL(2) folding with it. 2020-10-14 16:40:44 +02: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.cpp [flang] Rework host runtime folding and enable REAL(2) folding with it. 2020-10-14 16:40:44 +02:00
intrinsics.cpp [flang] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
logical.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
real.cpp [flang][msvc] Avoid a reinterpret_cast 2020-10-15 10:38:48 -07:00
shape.cpp [flang] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
static-data.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
tools.cpp [flang] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
type.cpp [flang] Improve initializer semantics, esp. for component default values 2020-12-07 14:40:41 -08:00
variable.cpp [flang] Substrings with lower bound greater than upper bound 2020-09-16 14:56:23 -07:00