[flang] Rework when symbol table expressions are evaluated
authorTim Keith <tkeith@nvidia.com>
Thu, 6 Dec 2018 14:59:37 +0000 (06:59 -0800)
committerTim Keith <tkeith@nvidia.com>
Thu, 6 Dec 2018 15:16:52 +0000 (07:16 -0800)
commit8ae55f79bcd0a134f1b9ea02606e761674a1104f
treea542de0237dcbeba5962d15b1aaffb84388cf3f9
parentd6b37b19675d8a828751ca591835b9b454105bb9
[flang] Rework when symbol table expressions are evaluated

It's not good enough to evaluate expressions in the symbol table after
name resolution has completed. This is because we need the values of
constant expressions for types, for example, we need to evaluate `k` in
`integer(k) :: x` to know the type of `x`.

So, eliminate `LazyExpr` and call `EvaluateExpr()` on expressions that
we need in the symbol table. The latter evaluates and folds an
expression in the current context. This is now possible because symbols
are added to `parser::Name` as soon as possible rather than in a pass
after name resolution. Along with `LazyExpr` we can eliminate the whole
`ResolveSymbolExprs` pass that used to resolve them.

In resolve-names.cc, many `Pre` functions are changed to `Post` so that
names are resolved before doing the associated processing. For example,
with intrinsic type specs, names in the kind expression must be resolved
before attempting to evaluate that expression.

In `GetSymbolType()` in type.cc, handle both `ObjectEntityDetails` and
`EntityDetails` by using `Symbol::GetType()`.

Add explicit declarations in label01.F90 because we can't handle
implicitly typed array bounds yet.

Original-commit: flang-compiler/f18@d67716640baeedca150205f9f3845ceb5d2f6402
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
13 files changed:
flang/lib/evaluate/type.cc
flang/lib/semantics/expression.cc
flang/lib/semantics/mod-file.cc
flang/lib/semantics/resolve-names.cc
flang/lib/semantics/semantics.cc
flang/lib/semantics/symbol.cc
flang/lib/semantics/symbol.h
flang/lib/semantics/type.cc
flang/lib/semantics/type.h
flang/test/semantics/CMakeLists.txt
flang/test/semantics/label01.F90
flang/test/semantics/modfile12.f90
flang/test/semantics/resolve37.f90 [new file with mode: 0644]