[flang] Fix problems determining object/function/subroutine
authorTim Keith <tkeith@nvidia.com>
Sat, 22 Sep 2018 15:05:46 +0000 (08:05 -0700)
committerTim Keith <tkeith@nvidia.com>
Sat, 22 Sep 2018 15:05:46 +0000 (08:05 -0700)
commit9811353abfedf9881ca61c6e7ff33b38a6000334
treec4d19adea68a8b9cb366bd2faab378a30b2f2abc
parent94f16cc649b0c2290c108e8bddb5e4e1121b370e
[flang] Fix problems determining object/function/subroutine

Convert each Entity to ObjectEntity at the end of each scope.
Add `ConvertToObjectEntity()` to achieve this, similar to
`ConvertToProcEntity()`. Move them both up into `ScopeHandler`
because they need to be called from `PopScope()`.

In a proc-decl, only mark the proc as a function if it has a return type.
If no return type is declared, function vs. subroutine is determined by:
- for a module it is a subroutine (at end of specification-part)
- otherwise it is by usage

If an entity that could otherwise be a function is used as the base of a
structure component, that forces it to be an object. Because we have to
change it to an object entity at that point, the `base` in `FindComponent()`
can't be const, and that propagates to all of its callers.

Remove the name argument to `ApplyImplicitRules` as it is unneeded.

Fixes flang-compiler/f18#191.

Original-commit: flang-compiler/f18@9bd8bf7c3706e501a58b564f316794d023f762b6
Reviewed-on: https://github.com/flang-compiler/f18/pull/194
Tree-same-pre-rewrite: false
flang/lib/semantics/resolve-names.cc
flang/test/semantics/resolve09.f90
flang/test/semantics/resolve21.f90