Commit graph

468 commits

Author SHA1 Message Date
Steve Scalpone
fa2e6374ce [flang] Fix typo: "check" becomes "checked"
Original-commit: flang-compiler/f18@2b2b0bf324
Reviewed-on: https://github.com/flang-compiler/f18/pull/360
Tree-same-pre-rewrite: false
2019-03-27 15:48:46 -07:00
Steve Scalpone
7024515c7d [flang] Implement semantics for computed GOTO. Note that a PGI extension
will implicitly convert a float to integer (and issue a warning).
This commit does not implement that extension.

Original-commit: flang-compiler/f18@b85755f26f
Reviewed-on: https://github.com/flang-compiler/f18/pull/360
Tree-same-pre-rewrite: false
2019-03-27 15:44:17 -07:00
Steve Scalpone
c78f9081f9 [flang] Inline the constructors for IF semantics checkers.
Remove some leftover cruft from check-if-stmt.h too.

Original-commit: flang-compiler/f18@5c150289a9
Reviewed-on: https://github.com/flang-compiler/f18/pull/356
2019-03-26 20:48:51 -07:00
Steve Scalpone
3d892d56e9 [flang] Remove the IF specific context classes; in these cases they
added no value. Change several error messages to better say
what is expected.  Adjust tests for new messages.  Reformat
with llvm7 clang-format.

Original-commit: flang-compiler/f18@706b506e26
Reviewed-on: https://github.com/flang-compiler/f18/pull/356
Tree-same-pre-rewrite: false
2019-03-26 18:03:33 -07:00
Steve Scalpone
f01caa3833 [flang] Implement semantic checks for if statements, if constructs and
arithmetic ifs.

Original-commit: flang-compiler/f18@deb2726aad
Reviewed-on: https://github.com/flang-compiler/f18/pull/356
Tree-same-pre-rewrite: false
2019-03-26 00:43:08 -07:00
Eric
b027f6cf2b [flang] When computing the stack of scopes, a label on the first statement
that begins a construct should be considered as in the parent scope
rather that within the scope of the construct that is being entered.

Original-commit: flang-compiler/f18@93da3538bc
Reviewed-on: https://github.com/flang-compiler/f18/pull/353
2019-03-22 19:29:00 -07:00
Eric Schweitz
6fce8f1e27 [flang] Simply the test per review comment.
Original-commit: flang-compiler/f18@66ab8bb2aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/351
2019-03-22 15:39:51 -07:00
Eric Schweitz
dee4d4be8d [flang] implement the DO WHILE check
Original-commit: flang-compiler/f18@c367551041
Reviewed-on: https://github.com/flang-compiler/f18/pull/351
Tree-same-pre-rewrite: false
2019-03-22 15:02:04 -07:00
Kiran Chandramohan
ed92b04e49 [flang] C1167 : Check for exit statments in do-concurrent
Addresses https://github.com/flang-compiler/f18/issues/288

Original-commit: flang-compiler/f18@2a99e1ea54
Reviewed-on: https://github.com/flang-compiler/f18/pull/345
2019-03-21 17:44:47 +00:00
peter klausler
dfc1643f3f [flang] get clean compile
Original-commit: flang-compiler/f18@3a606d804d
Reviewed-on: https://github.com/flang-compiler/f18/pull/346
Tree-same-pre-rewrite: false
2019-03-20 13:44:00 -07:00
peter klausler
ad057a42fa [flang] Remove OwningPointer, use unique_ptr better instead.
Original-commit: flang-compiler/f18@89aff868aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/346
Tree-same-pre-rewrite: false
2019-03-20 11:38:45 -07:00
Tim Keith
8d4c934da7 [flang] Fix warning when compiling with clang
Original-commit: flang-compiler/f18@0f18c3443a
Reviewed-on: https://github.com/flang-compiler/f18/pull/343
Tree-same-pre-rewrite: false
2019-03-19 13:44:56 -07:00
Tim Keith
3ec5e102e2 [flang] Name resolution for defined operators
Instead of tracking just genericName_ while in a generic interface
block or generic statement, now we immediately create a symbol for it.
A parser::Name isn't good enough because a defined-operator or
defined-io-generic-spec doesn't have a name.

Change the parse tree to add a source field to GenericSpec. Use these
as names for symbols for defined-operator and defined-io-generic-spec
(e.g. "operator(+)" or "read(formatted)").

Change the source for defined-op-name to include the dots so that they
can be distinguished from normal symbols with the same name (e.g. you
can have both ".foo." and "foo"). These symbols have names in the symbol
table like ".foo.", not "operator(.foo.)", because references to them
have that form.

Add GenericKind enum to GenericDetails and GenericBindingDetails.
This allows us to know a symbol is "assignment(=)", for example,
without having to do a string comparison.

Add GenericSpecInfo to handle analyzing the various kinds of
generic-spec and generating symbol names and GenericKind for them.

Add reference to LanguageFeatureControl to SemanticsContext so that
they can be checked during semantics. For this change, if
LogicalAbbreviations is enabled, report an error if the user tries
to define an operator named ".T." or ".F.".

Add resolve-name-utils.cc to hold utility functions and classes that
don't have to be in the ResolveNamesVisitor class hierarchy. The goal
is to reduce the size of resolve-names.cc where possible.

Original-commit: flang-compiler/f18@3081f694e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/338
2019-03-18 11:48:02 -07:00
peter klausler
7c71e2f288 [flang] Fix parse of .TRUE._8
Original-commit: flang-compiler/f18@b03e7a691d
Reviewed-on: https://github.com/flang-compiler/f18/pull/336
2019-03-17 15:51:02 -07:00
Eric Schweitz
327fa06a6b [flang] replace the stubs for translating terminal symbols to expressions; start pushing Value type into FIR; cleanup terminator succ_blocks; remove parser element from disassociate; run clang-format; etc.
Original-commit: flang-compiler/f18@c5561646ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/334
Tree-same-pre-rewrite: false
2019-03-15 10:03:06 -07:00
peter klausler
615ba7754b [flang] Move dump-parse-tree.h from semantics into parser.
Original-commit: flang-compiler/f18@9075adfcdf
Reviewed-on: https://github.com/flang-compiler/f18/pull/330
Tree-same-pre-rewrite: false
2019-03-14 16:28:06 -07:00
peter klausler
3204a1c1b9 [flang] checkpoint
Original-commit: flang-compiler/f18@0c9bdc7032
Reviewed-on: https://github.com/flang-compiler/f18/pull/333
Tree-same-pre-rewrite: false
2019-03-14 14:52:44 -07:00
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