Commit graph

501 commits

Author SHA1 Message Date
Eric Schweitz
3a0ccc1c0c [flang] fix typo
Original-commit: flang-compiler/f18@fc88b92af0
Reviewed-on: https://github.com/flang-compiler/f18/pull/332
2019-03-14 12:12:34 -07:00
Eric Schweitz
4fd1e5d795 [flang] Address review comments; merge with latest breaking changes on master
Original-commit: flang-compiler/f18@ffde96d486
Reviewed-on: https://github.com/flang-compiler/f18/pull/319
2019-03-11 08:59:33 -07:00
Eric Schweitz
d6964c42f2 [flang] FIR statements: various reworking of the code to decompose some
operations, get rid of unneeded nodes, restructure DO loops, etc.

Original-commit: flang-compiler/f18@0e0d67fbda
Reviewed-on: https://github.com/flang-compiler/f18/pull/319
Tree-same-pre-rewrite: false
2019-03-11 08:57:41 -07:00
peter klausler
c57fda817e [flang] Address review comment
Original-commit: flang-compiler/f18@8a9a41487e
Reviewed-on: https://github.com/flang-compiler/f18/pull/322
2019-03-09 10:25:08 -08:00
peter klausler
f3abed639d [flang] Fix misparsings of substrings in the parse tree, not in expressions.
Original-commit: flang-compiler/f18@53d0e26d92
Reviewed-on: https://github.com/flang-compiler/f18/pull/322
Tree-same-pre-rewrite: false
2019-03-09 10:25:07 -08:00
peter klausler
e3b632337d [flang] add structconst04.f90 test and fixes to pass it
Original-commit: flang-compiler/f18@d857c843f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/322
Tree-same-pre-rewrite: false
2019-03-09 10:25:07 -08:00
peter klausler
64ea462e3a [flang] Resolve misparse of structure constructor as function reference.
Original-commit: flang-compiler/f18@5b6b2540f6
Reviewed-on: https://github.com/flang-compiler/f18/pull/322
Tree-same-pre-rewrite: false
2019-03-09 10:25:06 -08:00
Tim Keith
f8995fcefa [flang] Remove build dependency on clang
For now all we need to depend on is LLVM.
Use llvm_map_components_to_libnames to find libraries to link against.

Original-commit: flang-compiler/f18@dff1402c2a
Reviewed-on: https://github.com/flang-compiler/f18/pull/321
2019-03-08 15:16:58 -08:00
peter klausler
972b3af6d4 [flang] Rearrange/simplify expr analysis code
Original-commit: flang-compiler/f18@aa9f3a7cca
Reviewed-on: https://github.com/flang-compiler/f18/pull/320
2019-03-07 14:46:31 -08:00
Tim Keith
251e0196e4 [flang] Simplify Semantics::Perform
`Semantics::Perform` is mostly a series of calls followed by a check
for fatal errors. There is more error checking logic than real code.

To make it clearer, change each of the phases it calls to return true
on success so that `Perform` can just call them one after the other.

Original-commit: flang-compiler/f18@a218cac788
Reviewed-on: https://github.com/flang-compiler/f18/pull/317
2019-03-06 17:07:25 -08:00
peter klausler
0de89a5c7d [flang] add rewriting as well as const visitation
Original-commit: flang-compiler/f18@1224eaee85
Reviewed-on: https://github.com/flang-compiler/f18/pull/316
Tree-same-pre-rewrite: false
2019-03-06 16:15:54 -08:00
peter klausler
642c78b680 [flang] back out one change
Original-commit: flang-compiler/f18@27fb43b6ed
Reviewed-on: https://github.com/flang-compiler/f18/pull/316
Tree-same-pre-rewrite: false
2019-03-06 16:15:52 -08:00
peter klausler
53ae00a9c4 [flang] Address review comments
Original-commit: flang-compiler/f18@3ed6199fed
Reviewed-on: https://github.com/flang-compiler/f18/pull/316
Tree-same-pre-rewrite: false
2019-03-06 16:15:52 -08:00
Tim Keith
f85ac283c5 [flang] Move ExprChecker into separate pass
DoConcurrentChecker depends on expressions being fully resolved so it
can't be in the same pass as ExprChecker. The same will probably
apply to AssignmentChecker when its finished.

Checks that don't depend on expressions can go in the first pass
with ExprChecker.

Original-commit: flang-compiler/f18@c0785ec06f
Reviewed-on: https://github.com/flang-compiler/f18/pull/315
2019-03-06 14:15:13 -08:00
Tim Keith
813e48dc21 [flang] Create framework for checking statement semantics
Add `SemanticsVisitor` as the visitor class to perform statement
semantics checks. Its template parameters are "checker" classes
that perform the checks. They have `Enter` and `Leave` functions
that are called for the corresponding parse tree nodes (`Enter`
before the children, `Leave` after). Unlike `Pre` and `Post` in
visitors they cannot prevent the parse tree walker from visiting
child nodes.

Existing checks have been incorporated into this framework:
- `ExprChecker` replaces `AnalyzeExpressions()`
- `AssignmentChecker` replaces `AnalyzeAssignments()`
- `DoConcurrentChecker` replaces `CheckDoConcurrentConstraints()`

Adding a new checker requires:
- defining the checker class:
  - with BaseChecker as virtual base class
  - constructible from `SemanticsContext`
  - with Enter/Leave functions for nodes of interest
- add the checker class to the template parameters of `StatementSemantics`

Because these checkers and also `ResolveNamesVisitor` require tracking
the current statement source location, that has been moved into
`SemanticsContext`. `ResolveNamesVisitor` and `SemanticsVisitor`
update the location when `Statement` nodes are encountered, making it
available for error messages.

`AnalyzeKindSelector()` now has access to the current statement through
the context and so no longer needs to have it passed in.

Test `assign01.f90` was added to verify that `AssignmentChecker` is
actually doing something.

Original-commit: flang-compiler/f18@3a222c3673
Reviewed-on: https://github.com/flang-compiler/f18/pull/315
Tree-same-pre-rewrite: false
2019-03-05 16:52:50 -08:00
peter klausler
0987d31f3e [flang] Tweak API per review
Original-commit: flang-compiler/f18@c0ab787cd1
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
2019-03-05 13:11:57 -08:00
peter klausler
6a0f9474ff [flang] Use value()/has_value() on Indirection class templates instead of operator*/operator->
Original-commit: flang-compiler/f18@a97f377ae6
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-05 12:28:08 -08:00
peter klausler
da2ebb6063 [flang] Improve error messages
Original-commit: flang-compiler/f18@4046134512
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:25 -08:00
peter klausler
6acfa11fda [flang] Add lib/semantics/tools.{h,cc}
Original-commit: flang-compiler/f18@c9823da207
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:25 -08:00
peter klausler
8a57433273 [flang] C1594 constraint checking on pointer components in struct constructors
Original-commit: flang-compiler/f18@386cd8a9b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:24 -08:00
peter klausler
3edc423bf8 [flang] Add SetLength operator to make character length changes explicit
Original-commit: flang-compiler/f18@f2d751d8a6
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:23 -08:00
peter klausler
431b84880a [flang] snapshot of work in progress
Original-commit: flang-compiler/f18@56e83d4dd6
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:23 -08:00
peter klausler
402cc8c4e9 [flang] Represent NULL()
Original-commit: flang-compiler/f18@2c3368fb5f
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:23 -08:00
peter klausler
857da8cfe9 [flang] Type checking on values in structure components
Original-commit: flang-compiler/f18@bea98aeb96
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:22 -08:00
peter klausler
c7cfc3f357 [flang] Add ForwardReference<> + documentation + clean-up
Original-commit: flang-compiler/f18@09e9501951
Reviewed-on: https://github.com/flang-compiler/f18/pull/314
2019-03-04 15:15:08 -08:00
peter klausler
ab74d1ac0c [flang] Rename to Fortran.h, update style guide, run clang-format
Original-commit: flang-compiler/f18@aa2907d226
Reviewed-on: https://github.com/flang-compiler/f18/pull/308
Tree-same-pre-rewrite: false
2019-02-28 11:48:15 -08:00
Tim Keith
fe588aff56 [flang] Fix bug handling function prefix type
This showed up in procinterface01. A function can have more than one
PrefixSpec (e.g. `real elemental f()`). We need to ignore that ones
that aren't types.

Also, process the type after the ImplicitPart rather than after the
SpecificationPart. The type of the function result variable could
be accessed between those places.

Original-commit: flang-compiler/f18@df85eedb92
Reviewed-on: https://github.com/flang-compiler/f18/pull/305
2019-02-28 10:38:17 -08:00
Tim Keith
ebcfd01ae3 [flang] Fix bug with host-association in module procedure interface body
A module procedure interface body can access entities in its host
without an IMPORT statement. So the `ImportKind` of the scope created
for such an interface body should be `Default`, not `None` as it is
for other interface bodies.

Original-commit: flang-compiler/f18@24bb2668fd
Reviewed-on: https://github.com/flang-compiler/f18/pull/305
Tree-same-pre-rewrite: false
2019-02-28 10:38:17 -08:00
Tim Keith
0b9621b635 [flang] Allow module procedure and generic with same name
The `GenericDetails::CheckSpecific()` check was happening too early.
We have to wait until all procedures of the generic have been seen.
The generic can have the same name as a module procedure only if that
module procedure is a specific procedure of the generic.

Improve the `SayAlreadyDeclared` error message when the previous
declaration is a use-association

Original-commit: flang-compiler/f18@269e3db602
Reviewed-on: https://github.com/flang-compiler/f18/pull/305
Tree-same-pre-rewrite: false
2019-02-28 10:38:17 -08:00
Tim Keith
563e65ded1 [flang] Fix .mod file for symbols with same name as generic
When a generic has the same name as a module procedure or derived type,
the latter weren't being written to the `.mod` file. Fix that by calling
`PutSymbol()` on those symbols from the generic. Change `PutSymbol()` to
accept `Symbol *` to make that more convenient.

Original-commit: flang-compiler/f18@1778efe981
Reviewed-on: https://github.com/flang-compiler/f18/pull/305
Tree-same-pre-rewrite: false
2019-02-28 10:38:17 -08:00
Tim Keith
9a497ddbad [flang] Fix resolution of function prefix type
When a function-stmt has a type in the prefix (`type(t) function f()`),
the type cannot be resolve until after processing the USE and IMPLICIT
statements. So save the parse-tree of the type and process it at the
end of the specification section.

Add `ProcessTypeSpec()` to handle the process of setting up to walk
a type spec, walking it, restoring the state, and returning the type
spec. We do this several other places too.

Original-commit: flang-compiler/f18@bcde294d0e
Reviewed-on: https://github.com/flang-compiler/f18/pull/305
Tree-same-pre-rewrite: false
2019-02-28 10:38:17 -08:00
Tim Keith
1ec4ec88bf [flang] Fix bug determining type of statement entity
A statement entity (`data-i-do-variable` or `ac-do-variable`) that
doesn't have a type specified gets the type it would have in the
enclosing scope. That means if there is a visible variable with the
same name, the statement entity gets its type. We were failing to
do that and just applying the implicit rules.

Original-commit: flang-compiler/f18@72bc7c29ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/305
Tree-same-pre-rewrite: false
2019-02-28 10:38:17 -08:00
Tim Keith
f1bcb92180 [flang] Handle subprogram declaration after call
If an external subprogram is called and then declared, we have to
replace the `ProcEntityDetails` with `SubprogramDetails` in the symbol.
While doing so we can also check that the call was consistent with the
declaration for function vs. subprogram.

Original-commit: flang-compiler/f18@e43a2dae79
Reviewed-on: https://github.com/flang-compiler/f18/pull/305
Tree-same-pre-rewrite: false
2019-02-28 10:38:17 -08:00
Tim Keith
41e5053ee6 [flang] Fix bug determining function vs. subroutine
We were setting `expectedProcFlag_` to indicate if a `ProcedureDesignator`
was used in a function or subroutine context. That didn't work if they
were nested, for example: `call f(g())`.

Instead, at the point we know function vs. subroutine (i.e. in the
`CallStmt` and `FunctionReference` nodes), explicitly walk the children,
passing in the flag.

Original-commit: flang-compiler/f18@8a13283f98
Reviewed-on: https://github.com/flang-compiler/f18/pull/305
Tree-same-pre-rewrite: false
2019-02-28 10:38:17 -08:00
peter klausler
94baaab8a8 [flang] address review comments
Original-commit: flang-compiler/f18@6f4af0fc1b
Reviewed-on: https://github.com/flang-compiler/f18/pull/304
Tree-same-pre-rewrite: false
2019-02-27 11:12:16 -08:00
peter klausler
4eccba942e [flang] Clean up DynamicType, link it to symbol table character length
Original-commit: flang-compiler/f18@833f5f52e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/304
Tree-same-pre-rewrite: false
2019-02-26 16:21:28 -08:00
peter klausler
f953583dea [flang] checkpoint
Original-commit: flang-compiler/f18@4d907e3184
Reviewed-on: https://github.com/flang-compiler/f18/pull/304
Tree-same-pre-rewrite: false
2019-02-26 16:21:26 -08:00
peter klausler
ba56b913a4 [flang] checkpoint
Original-commit: flang-compiler/f18@e7b0f456c9
Reviewed-on: https://github.com/flang-compiler/f18/pull/304
Tree-same-pre-rewrite: false
2019-02-26 16:19:36 -08:00
peter klausler
2d76abcd07 [flang] checkpoint
Original-commit: flang-compiler/f18@a2b1c94ddb
Reviewed-on: https://github.com/flang-compiler/f18/pull/304
Tree-same-pre-rewrite: false
2019-02-26 16:18:56 -08:00
Tim Keith
8b3783e2ea [flang] Fix build problem with clang
Moving one of the `Pre(ImplicitStmt)` functions up to
`DeclarationVisitor` seemed to cause clang to complain that the `Pre`
call from the `Walk` function was ambiguous. So this change moves
it back to `ResolveNameVisitor`.

Also, remove an unused variable that was causing a warning.

Original-commit: flang-compiler/f18@766d000e25
Reviewed-on: https://github.com/flang-compiler/f18/pull/299
2019-02-21 19:14:28 -08:00
Tim Keith
b6eb981caa [flang] Handle SAVE attribute and statement
As with COMMON blocks, we can't completely check SAVE statements and
attributes until the end of the specification part when we have seen
full declarations of entities. So when SAVE is specified, add it to one
of the two sets in `saveInfo_`. At the end of the specification part,
check that those entities can have SAVE applied and set it if it is
not already implicitly set (e.g. due to being in a module). Also apply
the "global" SAVE if present (i.e. setting it on every applicable
entity).

Add `IsDummy()` and `IsFuncResult()` to `Symbol` to simplify some of
the checks. Also detect attempts to put a function result in a common
block.

Original-commit: flang-compiler/f18@af19c02bac
Reviewed-on: https://github.com/flang-compiler/f18/pull/298
2019-02-21 08:59:38 -08:00
Tim Keith
a6874f8ee8 [flang] More work on COMMON blocks
Common block names can't clash with other names, so add `commonBlocks_`
to `Scope` to record the common blocks of a scoping unit. This requires
changes to how scopes are dumped and written to `.mod` files.

Support common blocks in BIND statements. Add optional bind-name to
`CommonBlockDetails`.

Add `CheckNotInBlock()` for checking statements that are not allowed in
block constructs.

In `rewrite-parse-tree.cc`, no longer skip check for resolved names in
common statements. But do skip the checks in compiler directives.

Original-commit: flang-compiler/f18@805a1ffd9b
Reviewed-on: https://github.com/flang-compiler/f18/pull/298
Tree-same-pre-rewrite: false
2019-02-21 08:48:20 -08:00
Tim Keith
8a03a67cb0 [flang] Change handling of BIND attributes
Previously `BIND(C, NAME="...")` caused `bindName` to be set but not
the `BIND` attribute. This made writing the `.mod` file easier, but it
makes it hard to ask: does this symbol have a C binding.

This change causes the `BIND` attribute to be set whenever there is
`BIND(C)` in the source, regardless of whether there is a name or not.
`bindName` is only set when the `BIND` attribute is also set.

Original-commit: flang-compiler/f18@5a6706ffcb
Reviewed-on: https://github.com/flang-compiler/f18/pull/298
Tree-same-pre-rewrite: false
2019-02-21 08:47:12 -08:00
peter klausler
6ed79af787 [flang] address review comments
Original-commit: flang-compiler/f18@a27f240bd4
Reviewed-on: https://github.com/flang-compiler/f18/pull/291
2019-02-19 10:08:10 -08:00
peter klausler
2793b663d6 [flang] Check for recursive EXTENDS()
Original-commit: flang-compiler/f18@8d0a9bb360
Reviewed-on: https://github.com/flang-compiler/f18/pull/291
Tree-same-pre-rewrite: false
2019-02-18 14:15:33 -08:00
peter klausler
88631be8b4 [flang] fix flang-compiler/f18#283 - recursive use of derived types
Original-commit: flang-compiler/f18@f8889b83fc
Reviewed-on: https://github.com/flang-compiler/f18/pull/291
Tree-same-pre-rewrite: false
2019-02-18 14:15:32 -08:00
peter klausler
dd9b7fda3e [flang] Address review comments
Original-commit: flang-compiler/f18@7662121287
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
2019-02-18 13:47:34 -08:00
peter klausler
475d72f8e6 [flang] push for review
Original-commit: flang-compiler/f18@17dc735911
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 14:26:23 -08:00
peter klausler
4417443be9 [flang] Fix CHECK() on wa22 by implementing PGI language extension
Original-commit: flang-compiler/f18@03fcb58977
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:29:10 -08:00
peter klausler
2f12ee4f52 [flang] complete transfer of struct constructor code to expression.cc
Original-commit: flang-compiler/f18@e6178b2fc7
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:29:07 -08:00
peter klausler
f5bc9fd1d1 [flang] checkpoint, much code moved out of name resolution
Original-commit: flang-compiler/f18@8a081e82fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:28:09 -08:00
peter klausler
115d3cdf52 [flang] catch up with master
Original-commit: flang-compiler/f18@e66ef3699c
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:24:17 -08:00
peter klausler
4d1a8a3ac8 [flang] checkpoint, tests pass
Original-commit: flang-compiler/f18@d90d5d9244
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:24:13 -08:00
peter klausler
5b79ffc5f6 [flang] checkpoint
Original-commit: flang-compiler/f18@156791b288
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:22:10 -08:00
peter klausler
4313f4c762 [flang] checkpoint array/struct constructor work
Original-commit: flang-compiler/f18@b0a574fa35
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:22:09 -08:00
peter klausler
d3559a5d18 [flang] Name resolution for structure constructors
Original-commit: flang-compiler/f18@9d60038f03
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:22:04 -08:00
peter klausler
6d47e5ab4d [flang] Eliminate DerivedTypeDetails::extends_ since it is front of component list
Original-commit: flang-compiler/f18@15150225f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:22:03 -08:00
peter klausler
509436cab1 [flang] begin work on structure constructors
Original-commit: flang-compiler/f18@7131a2f91d
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:22:02 -08:00
Tim Keith
543b15bca4 [flang] Add support for common blocks
A symbol for a common block has `CommonBlockDetails` which contains
a list of the symbols that are in the common block.

The name of the symbol for the blank common block is the empty string.
That preserves the property that every symbol name is a substring of
the cooked source. We use the 0-length substring starting at the COMMON
statement so that when symbols are sorted by the location of the start
of the name it ends up in the right place.

Some of the checks on members of common blocks don't happen until the
end of the scope. They can't happen earlier because we don't necessarily
know the type and attributes.

Enhance `test_errors.sh` so that multiple errors can be expected for
a single line.

Original-commit: flang-compiler/f18@2c4ca6b5d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/286
2019-02-14 07:59:20 -08:00
Tim Keith
b7412d0174 [flang] Strengthen checking for unresolved names
Make it a fatal error to have an unresolved name, except for a few
exceptions.

Remove namelist, bind, save statements from the exceptions.

Original-commit: flang-compiler/f18@b16cbed780
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
2019-02-11 10:58:20 -08:00
Tim Keith
e5965b4752 [flang] Fix bug setting type from association expression
When an association selector is an expression, we get the type of the
associate-name from the type of the expression. If that is a derived
type, we were failing to get the derived type scope in copy of the
type that was made. That meant the component names were not resolved.

The fix is to copy the scope in the copy and move constructors of
`DerivedTypeSpec`. As a result, `DerivedTypeSpec::Instantiate` cannot
assume that the `scope_` is not set.

Original-commit: flang-compiler/f18@79eaa8c47f
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
2019-02-11 10:49:48 -08:00
Tim Keith
3ecf8ef241 [flang] Always resolve associate-name in select-type
Even if the selector expression has an error, we can resolve the
associate-name.

Original-commit: flang-compiler/f18@3c35c30f58
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
2019-02-08 16:17:52 -08:00
Tim Keith
d396a8845b [flang] Resolve kind parameters on literal constants
When the kind parameter is a constant name, that name must be resolved.

Add `CheckIntrinsicKind` and `CheckIntrinsicSize` for common checking of
valid intrinsic kinds. Previous we had different forms of the error
message depending on the context ( "unsupported INTEGER(KIND=47)" and
"INTEGER(KIND=47) is not a supported type").

Report error for parameters without initialization where are they
declared (in `Post(EntityDecl)`) rather than where they are referenced
(in `AnalyzeExpr`).

Remove error message from `AnalyzeKindParam`: `AnalyzeExpr` will report
the error (e.g. not integer, not constant, etc.).

Remove "name was not resolved" error from `AnalyzeExpr`: it should be
reported by name resolution.

Original-commit: flang-compiler/f18@9b0a99ce66
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
2019-02-08 16:03:23 -08:00
Tim Keith
69369e3b52 [flang] Resolve binding names in type-bound generic
Enhance `FindInTypeOrParents()` to also accept a `parser::Name` argument
and to resolve that name when the symbol is found. This causes binding
names in type-bound generic statements to be resolved. Move this process
to the beginning of the handling of such statements so that they are
resolve even if the generic spec is not and we return early.

Also resolve type parameter keywords in derived type specs
(e.g. `k` in `type(k=1) :: x`). That involves collecting and searching
the symbols of the `TypeParamDetails` to match the name with the symbol.

Original-commit: flang-compiler/f18@7387fb436d
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
2019-02-08 08:57:28 -08:00
Eric Schweitz
a12981c776 [flang] Fix for both issues 274 and 278
Original-commit: flang-compiler/f18@9bb54046c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/280
2019-02-08 10:53:18 -08:00
Eric Schweitz
748860b684 [flang] Fixes infinite loop in tests
Original-commit: flang-compiler/f18@2fa96b7734
Reviewed-on: https://github.com/flang-compiler/f18/pull/279
2019-02-07 16:41:18 -08:00
Tim Keith
d0d92e4eff [flang] Address review comments
Original-commit: flang-compiler/f18@9daa2351c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/277
2019-02-07 12:25:59 -08:00
Tim Keith
2a43e78c17 [flang] Improvements to name resolution in data statements
Handle variables in data statements differently from implied dos:
If a variable is first mentioned in a data statement, it is implicitly
declared in the current scope (and subsequent type declarations only
confirm the type).
In the implied do case, the only variables that can be implicitly
declared are the iteration variables. They must be created in the new
ImpliedDos scope. There must be one such scope for each data-stmt-object
because the variable name can be reused.

Resolve references to named constants, e.g. in complex-literal-constant
and data-stmt-value. This requires changing the handling of
named-constant-def as that is a definition, not a reference.

Original-commit: flang-compiler/f18@9952b56af0
Reviewed-on: https://github.com/flang-compiler/f18/pull/277
Tree-same-pre-rewrite: false
2019-02-06 17:18:02 -08:00
Tim Keith
7c4e86b7e2 [flang] Add Symbol::IsArray()
Add and use IsArray for symbols, meaning: it is an object entity
with shape.

Original-commit: flang-compiler/f18@31c1a37f03
Reviewed-on: https://github.com/flang-compiler/f18/pull/277
Tree-same-pre-rewrite: false
2019-02-06 10:28:31 -08:00
Tim Keith
da46e49a01 [flang] Resolve namelist group and object names
Namelist groups are represents by symbols with `NamelistDetails`.
Those contain a list of symbols representing the objects in the group.
References to namelist groups in io-control-spec are resolved.

In `.mod` files, namelist groups are written out at the end of the
module specification section. This is so that the declarations of the
objects in the namelist group appear before they are referenced.

Original-commit: flang-compiler/f18@8b70dbcac7
Reviewed-on: https://github.com/flang-compiler/f18/pull/277
Tree-same-pre-rewrite: false
2019-02-05 14:43:00 -08:00
Tim Keith
be6e03ec90 [flang] Add SayWithDecl function for error reporting
Add `SayWithDecl` to handle the common case of reporting an error about
a symbol and referencing its original declaration.

Original-commit: flang-compiler/f18@cf4d6fbe7f
Reviewed-on: https://github.com/flang-compiler/f18/pull/277
Tree-same-pre-rewrite: false
2019-02-05 13:51:36 -08:00
Eric Schweitz
a67099adbf [flang] identifier conformity
Original-commit: flang-compiler/f18@7d6e28f699
Reviewed-on: https://github.com/flang-compiler/f18/pull/276
2019-02-05 10:27:32 -08:00
Eric Schweitz
5c5fda8680 [flang] Issue flang-compiler/f18#274 - add separate scopes for each procedure in the module
Original-commit: flang-compiler/f18@d8f6b66178
Reviewed-on: https://github.com/flang-compiler/f18/pull/276
Tree-same-pre-rewrite: false
2019-02-05 09:43:51 -08:00
peter klausler
56bf4f8e0f [flang] fix crash found by tim
Original-commit: flang-compiler/f18@c24120d811
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
2019-02-04 13:06:21 -08:00
peter klausler
7f7c44f425 [flang] address comments
Original-commit: flang-compiler/f18@ccbb1a2036
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-02-04 10:39:41 -08:00
peter klausler
6d8aecf981 [flang] Convert structs to classes, move some defs from variable.h to call.h
Original-commit: flang-compiler/f18@c877a34694
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 16:04:17 -08:00
peter klausler
981921f47a [flang] fix f90_correct failure
Original-commit: flang-compiler/f18@1d9dac8ab5
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 13:18:30 -08:00
peter klausler
8c5d6b99de [flang] Fix instantiation of PDT bindings
Original-commit: flang-compiler/f18@8dcfe0c70b
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 11:44:13 -08:00
peter klausler
140b4adcfe [flang] Address review comments, fix some f90_correct failures
Original-commit: flang-compiler/f18@e468f8cd54
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:37 -08:00
peter klausler
1c95fef459 [flang] pass tests
Original-commit: flang-compiler/f18@db22dc2294
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:35 -08:00
peter klausler
ab71bd343c [flang] folding array constructors
Original-commit: flang-compiler/f18@a4e045fc5a
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:33 -08:00
peter klausler
650b32ebfe [flang] support Constant arrays
Original-commit: flang-compiler/f18@a92d8a404f
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:32 -08:00
peter klausler
0ae3d43d76 [flang] Run expression semantic analysis with rest of semantics.
checkpoint array constructor semantics work

checkpoint

array constructors of lengthless intrinsic types

checkpoint

Correct ambiguous substring refs misparsed as array elements

Original-commit: flang-compiler/f18@2232549efe
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:28 -08:00
peter klausler
74a77dd2ed [flang] Use IEEE-754 terminology better: subnormal, not denormal(ized)
Original-commit: flang-compiler/f18@57b0ebb558
Reviewed-on: https://github.com/flang-compiler/f18/pull/273
2019-01-29 16:47:41 -08:00
peter klausler
9d63306d76 [flang] Remove SHARED from add_library(), use cmake command line option instead
Original-commit: flang-compiler/f18@6644c799a7
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
2019-01-22 16:31:20 -08:00
peter klausler
f47c0bdaba [flang] Add SHARED to add_library() invocations so f18 libraries are always built shared.
Original-commit: flang-compiler/f18@060ced04c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
2019-01-22 16:31:20 -08:00
peter klausler
e7b93436c3 [flang] Rearrange code to eliminate dependence cycles between f18 library binaries
Original-commit: flang-compiler/f18@88651eecae
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
2019-01-22 16:31:19 -08:00
peter klausler
f9d6c0a338 [flang] Move default intrinsic type kinds from lib/semantics to lib/common
Original-commit: flang-compiler/f18@887e72dd61
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
2019-01-22 16:31:18 -08:00
peter klausler
a75f28a8a2 [flang] Fix crash reported by Jean in error recovery case
Original-commit: flang-compiler/f18@33db1790be
Reviewed-on: https://github.com/flang-compiler/f18/pull/264
2019-01-18 12:09:22 -08:00
peter klausler
6d4f4b269b [flang] fix clang build warning
Original-commit: flang-compiler/f18@799fe63779
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
2019-01-18 10:45:07 -08:00
peter klausler
5ceaa14dd9 [flang] done with merge
Original-commit: flang-compiler/f18@9c63eb7a1a
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
Tree-same-pre-rewrite: false
2019-01-17 16:14:36 -08:00
peter klausler
7f3590771e [flang] merge with master, implement a TODO with LEN on ASSOCIATE
Original-commit: flang-compiler/f18@e4501c6fa4
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
Tree-same-pre-rewrite: false
2019-01-17 13:52:10 -08:00
peter klausler
be3b765e2a [flang] basic skeleton of assignment analyzer
remove needless template<> on some function overloads

dodge bogus compiler warning from gcc 8.1.0 only

stricter typing of expressions in symbols

adjust modfile12.f90 expected test results

add Unwrap, massage folding a bit

Use Unwrap to simplify folding

Move KindSelector analysis into expression semantics

fix crash

checkpoint

updates to TypeParamInquiry

support of %KIND type parameter inquiry

equality testing for expressions

checkpoint during PDT implementation

reformat

checkpoint derived type instantiation

checkpoint

resolve merge

debugging failed tests

fix failing resolve37.f90 test

all existing tests pass

clean up all build warnings

fix bug

update copyright dates

fix copyright dates

address review comments

review comment

merge with master after peeling off changes

bugfixing new feature

fix warning from old g++s

tweaks after merging with latest head

more bugfixing

making modfile17.f90 test work

Make kinds into expressions in symbol table types

big refactor for deferring kinds in intrinsic types

modfile17.f90 test passes

clean up TODOs

Simplify types as stored in scopes

Test KIND parameter default init expressions, debug them

Update copyright dates

address comments

remove dead line

address comments

Original-commit: flang-compiler/f18@1f43d0a048
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
Tree-same-pre-rewrite: false
2019-01-17 10:41:08 -08:00
Tim Keith
42d7ac3e36 [flang] Fix link error from last integration
We need to be able to analyze the `Variable` in a `Selector` and an
expression. That worked in a previous iteration of `expression.h` by
analyzing each variant of `Variable`.

This fix adds an explicit public function to analyze a Variable and
return a `MaybeExpr`.

Original-commit: flang-compiler/f18@9848a5d48f
Reviewed-on: https://github.com/flang-compiler/f18/pull/262
2019-01-16 17:18:10 -08:00
Tim Keith
3020a18652 [flang] Fix typo
Original-commit: flang-compiler/f18@27af745986
Reviewed-on: https://github.com/flang-compiler/f18/pull/261
2019-01-16 13:21:15 -08:00
Tim Keith
ee28b70827 [flang] Resolve names in ASSOCIATE and SELECT TYPE
Create `AssocEntityDetails` for symbols that represent entities
identified by the associate-name in ASSOCIATE and SELECT TYPE
constructs.

For ASSOCIATE, create a new scope for the associated entity.
For SELECT TYPE, create a new scope for each of type guard blocks.
Each one contains an associated entity with the appropriate type.

For SELECT TYPE, also create a place-holder symbol for the
associate-name in the SELECT TYPE statement. The real symbols
are in the new scopes and none of them is uniquely identified
with the associate-name.

Handling of `Selector` is common between these, with
`associate-name => expr | variable` recorded in
`ConstructVisitor::association_`.

When the selector is an expression, derive the type of the associated
entity from the type of the expression. This required some refactoring
of how `DeclTypeSpec`s are created. The `DerivedTypeSpec` that comes
from and expression is const so we can only create const `DeclTypeSpec`s
from it. But there were times during name resolution when we needed to
set type parameters in the current `DeclTypeSpec`. Now the non-const
`DerivedTypeSpec` is saved separately from the const `DeclTypeSpec`
while we are processing a declaration type spec. This makes it
unnecessary to save the derived type name.

Add a type alias for `common::Indirection` to reduce verbosity.

Original-commit: flang-compiler/f18@b7668cebe4
Reviewed-on: https://github.com/flang-compiler/f18/pull/261
Tree-same-pre-rewrite: false
2019-01-15 16:59:20 -08:00
peter klausler
70d7ab8789 [flang] address review comments
Original-commit: flang-compiler/f18@e770e52cb1
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
2019-01-09 16:39:58 -08:00
peter klausler
dc9faa270f [flang] cherrypick expression changes
Original-commit: flang-compiler/f18@427e267722
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
Tree-same-pre-rewrite: false
2019-01-09 15:06:07 -08:00
Tim Keith
7ec0830abd [flang] Resolve %kind and %len on intrinsic types
A `part-ref` can be `%kind` on an entity of any intrinsic type or
`%len` on a character entity. During name resolution, recognize these
and don't report an error as if they are component references.

Create symbols for these names as well as `%re` and `%im`. This is
partly for completeness so that we don't get warnings about unresolve
names. It also allows us to avoid having to do string comparisons on
these names in more than one place.

Rework `AnalyzeExpr` on structure components to make use of these
symbols and also not treat `%kind` and `%len` as derived type component
references.

Original-commit: flang-compiler/f18@65ae81ebac
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
2019-01-08 12:14:35 -08:00
Tim Keith
9ae71a0357 [flang] Fix crash evaluating kind expression
If we fail to evaluate the kind expression we were getting an invalid
optional reference. Instead, fail with an assert. This can happen if an
intrinsic function is not folded, but that will be implemented
eventually.

Original-commit: flang-compiler/f18@3bdbfc34bb
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tree-same-pre-rewrite: false
2019-01-08 12:14:35 -08:00