Commit graph

615 commits

Author SHA1 Message Date
Tim Keith
edf9eec265 [flang] More miscellaneous name resolution
Resolve the index name in a FORALL, DO, or DO CONCURRENT.

Handle pointer-stmt. Add DeclareUnknownEntity() to declare an entity
that is not yet know to be an object or procedure. This is used in the
EntityDecl and PointerDecl cases.

When an array element assignment is mistakenly parsed as a statement
function, ensure the index names are resolved.

Detect erroneous use-association with local name that matches the name
of the containing subprogram.

Cleanup: Eliminate GetVariableName() and CheckImplicitSymbol() in favor
of using the Resolve* functions consistently. Add ResolveName() to do
what CheckImplicitSymbol() used to do.

Disable warnings about unresolved names for some categories of
constructs that are not yet implemented: common blocks, namelist
statements, etc. These will be turned back on when they are implemented.

Original-commit: flang-compiler/f18@9a41bf37fd
Reviewed-on: https://github.com/flang-compiler/f18/pull/210
2018-10-10 16:20:46 -07:00
Tim Keith
7db04a4c05 [flang] Check conflicting construct names
Check that construct names don't conflict with other construct names or
entities in the same scoping unit.

This requires adding symbols for them. MiscDetails was added for cases
like this where we don't need to save much information about the symbol.
References to construct names are recorded too, so those names are now
expected to be resolved and no longer are exceptions in rewrite-parse-tree.cc

Checking that construct names match is still done in resolve-labels.cc.

Original-commit: flang-compiler/f18@0ad79ff029
Reviewed-on: https://github.com/flang-compiler/f18/pull/210
Tree-same-pre-rewrite: false
2018-10-10 16:05:00 -07:00
peter klausler
884d9057d0 [flang] Prep for review
Original-commit: flang-compiler/f18@a9439ee83c
Reviewed-on: https://github.com/flang-compiler/f18/pull/209
2018-10-10 15:27:17 -07:00
peter klausler
fa671ab542 [flang] Remove some obsolete casts now that Integer has a better constructor
Original-commit: flang-compiler/f18@f9a4a8bdda
Reviewed-on: https://github.com/flang-compiler/f18/pull/209
Tree-same-pre-rewrite: false
2018-10-10 15:01:12 -07:00
peter klausler
a10f6000b0 [flang] Fix issue#202 by avoiding clang+BSD/Darwin header bug
Original-commit: flang-compiler/f18@1bdefe528a
Reviewed-on: https://github.com/flang-compiler/f18/pull/209
Tree-same-pre-rewrite: false
2018-10-10 15:01:10 -07:00
Paul Henning
3712060d2e [flang] Removed obsolete comments and conversions
The addition of a more robust Integer constructor for POD types has
made some comments and static_cast expressions obsolete.

Original-commit: flang-compiler/f18@847b8a7684
Reviewed-on: https://github.com/flang-compiler/f18/pull/208
2018-10-10 14:43:21 -07:00
peter klausler
4bdb76af0b [flang] Make conversions between C++ integral types and Integer fully generic.
Original-commit: flang-compiler/f18@bf753a183d
Reviewed-on: https://github.com/flang-compiler/f18/pull/206
2018-10-10 13:21:46 -07:00
Tim Keith
03435d981d [flang] Use fundamental types in overloadings of Unparse.
Different systems map std::size_t, string::size_type, etc. to different
fundamental types. To ensure they are all covered, make the overloadings
of Unparse for integer types use only fundamental types.

This fixes compilations problems on Darwin and *BSD systems.

Original-commit: flang-compiler/f18@5576ed49a2
Reviewed-on: https://github.com/flang-compiler/f18/pull/205
2018-10-10 07:24:27 -07:00
Eric Schweitz
ee7b4dafde [flang] Build the label stack locally and thread the iterators explicitly rather
than as implied state within the Mutator object.

Original-commit: flang-compiler/f18@ae2adeab34
Reviewed-on: https://github.com/flang-compiler/f18/pull/203
2018-10-05 13:59:43 -07:00
Eric Schweitz
98ed7d037b [flang] Use move semantics directly to move the LoopControl object.
Original-commit: flang-compiler/f18@7d646b42bb
Reviewed-on: https://github.com/flang-compiler/f18/pull/203
Tree-same-pre-rewrite: false
2018-10-05 11:10:47 -07:00
peter klausler
b64a39e1ea [flang] Prep for review
Original-commit: flang-compiler/f18@e86eae005e
Reviewed-on: https://github.com/flang-compiler/f18/pull/200
2018-10-04 13:55:51 -07:00
peter klausler
7e87d5a297 [flang] Parse nonlabel DO within label DO better; add -fdebug-semantics; more testing
Original-commit: flang-compiler/f18@2825a45956
Reviewed-on: https://github.com/flang-compiler/f18/pull/200
Tree-same-pre-rewrite: false
2018-10-04 13:54:07 -07:00
peter klausler
4d6885346e [flang] rework non-block DO loop canonicalization
Original-commit: flang-compiler/f18@50574936f2
Reviewed-on: https://github.com/flang-compiler/f18/pull/200
Tree-same-pre-rewrite: false
2018-10-04 13:52:42 -07:00
Eric Schweitz
f5286c19b6 [flang] Add static to explicitly denote that some member functions do not access
the object's state; it is explicitly passed instead.

Original-commit: flang-compiler/f18@53df8087f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/201
2018-10-04 09:57:39 -07:00
Eric Schweitz
c06e78ae16 [flang] Fix recursion bug so canondo04.f90 test passes.
Original-commit: flang-compiler/f18@49510ff01f
Reviewed-on: https://github.com/flang-compiler/f18/pull/201
Tree-same-pre-rewrite: false
2018-10-04 09:41:29 -07:00
peter klausler
c71aecb787 [flang] Correct the spelling of LOCAL_INIT clauses on DO CONCURRENT statements.
Original-commit: flang-compiler/f18@bfc869ad5f
Reviewed-on: https://github.com/flang-compiler/f18/pull/198
2018-10-02 10:03:37 -07:00
Eric Schweitz
c105c9432a [flang] Review comments
Original-commit: flang-compiler/f18@fa5daf35ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/199
2018-10-02 09:29:53 -07:00
peter klausler
7b141b62df [flang] Resolve g++ 7.2 build problem
Original-commit: flang-compiler/f18@09859b2e9c
Reviewed-on: https://github.com/flang-compiler/f18/pull/197
2018-10-01 14:36:31 -07:00
Eric Schweitz
1c2dc51cc0 [flang] Handle review comments
Original-commit: flang-compiler/f18@9789d4d21b
Reviewed-on: https://github.com/flang-compiler/f18/pull/193
2018-09-21 11:12:02 -07:00
Eric Schweitz
d14c38fbe7 [flang] Rename two member functions
Original-commit: flang-compiler/f18@c953185c9f
Reviewed-on: https://github.com/flang-compiler/f18/pull/193
Tree-same-pre-rewrite: false
2018-09-21 10:51:06 -07:00
Eric Schweitz
8b45686de6 [flang] Fix the double end do condition. Translate a labelled end do into a
continue and preserve the label for control flow.

Original-commit: flang-compiler/f18@bd611b9809
Reviewed-on: https://github.com/flang-compiler/f18/pull/193
Tree-same-pre-rewrite: false
2018-09-21 08:22:41 -07:00
Eric Schweitz
4972485598 [flang] canonicalize DO constructs
Fix a bug with BLOCK DATA name matching
Add tests and finish up DO loop canonicalization

Original-commit: flang-compiler/f18@2d93b2819c
Reviewed-on: https://github.com/flang-compiler/f18/pull/193
Tree-same-pre-rewrite: false
2018-09-20 16:14:58 -07:00
peter klausler
3cecff6a05 [flang] checkpoint
Original-commit: flang-compiler/f18@960ae495fd
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:24:04 -07:00
peter klausler
d969464673 [flang] typed function references
Original-commit: flang-compiler/f18@e9b9d72958
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:24:04 -07:00
peter klausler
ad2fda8932 [flang] substrings and better rank checks
Original-commit: flang-compiler/f18@4fa483ac49
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:24:02 -07:00
peter klausler
0787d7f2df [flang] check C1002
Original-commit: flang-compiler/f18@6a2fd760b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:24:02 -07:00
peter klausler
1322e6090f [flang] Use dynamic default REAL kind for conversions that were static
Original-commit: flang-compiler/f18@9a83fbbe95
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:24:01 -07:00
peter klausler
a5687fd579 [flang] source provenances for expressions
Original-commit: flang-compiler/f18@5fe292fcac
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:24:00 -07:00
peter klausler
b74d469103 [flang] some clean-up
Original-commit: flang-compiler/f18@b6eb3e990a
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:24:00 -07:00
peter klausler
c2d4f07cda [flang] Changes that might fix MSVC build problems from sjs
Original-commit: flang-compiler/f18@009f0cc8df
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:23:59 -07:00
peter klausler
84af9c28f0 [flang] subscripts
Original-commit: flang-compiler/f18@7fb7518af7
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:23:59 -07:00
peter klausler
93a7f1f85c [flang] work on structure components
Original-commit: flang-compiler/f18@619b6957b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:23:58 -07:00
Tim Keith
9f29b0152a [flang] Simplify handling of ProcDecl
DeclareProcEntity takes care of setting the Function or Subroutine flag
on the procedure entity, so it is not necessary in this function.

Original-commit: flang-compiler/f18@a015b3187d
Reviewed-on: https://github.com/flang-compiler/f18/pull/194
2018-09-24 11:43:48 -07:00
Tim Keith
a0858885c2 [flang] Recognize complex-part-designator
The "%RE" or "%IM" is parsed as a structure-component.
If the base has type COMPLEX and the component name is one
of those, allow it without comment.

Note that the `parser::Name` for these components don't get
symbols filled in, so we still get a warning that they are
unresolved. We have to figure out how to deal with names
like this that we won't have symbols for.

Fixes flang-compiler/f18#188.

Original-commit: flang-compiler/f18@1d4a84fe3c
Reviewed-on: https://github.com/flang-compiler/f18/pull/194
Tree-same-pre-rewrite: false
2018-09-24 07:12:38 -07:00
Tim Keith
9811353abf [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@9bd8bf7c37
Reviewed-on: https://github.com/flang-compiler/f18/pull/194
Tree-same-pre-rewrite: false
2018-09-22 08:05:46 -07:00
Tim Keith
af22eea4b0 [flang] Fix typo
Original-commit: flang-compiler/f18@3ad7a77898
Reviewed-on: https://github.com/flang-compiler/f18/pull/192
2018-09-20 14:21:04 -07:00
Tim Keith
3133c9e7e2 [flang] Fix problems with extended derived types
When looking for a component name in a derived type, also look in the
parent type. Before adding a component to a derived type, report an
error if it already has one with that name. Check that components are
accessible when they are accessed.

Add the "parent component" to derived types (i.e. a component with the
same name as the parent type). The symbol is marked with the
`ParentComp` flag so we can avoid writing it to `.mod` files.

Add calls to `add_occurrence()` so that those particular instances of
`parser::Name` get their symbol set.

Change `DeclareObjectEntity` and `DeclareProcEntity` to use `SourceName` as
the name passed in rather than `parser::Name`.

Fix some problems in `unparse-with-symbols.cc` on statements that both
define and reference names.

Fixes flang-compiler/f18#187.

Original-commit: flang-compiler/f18@664b9627f2
Reviewed-on: https://github.com/flang-compiler/f18/pull/192
Tree-same-pre-rewrite: false
2018-09-20 14:08:59 -07:00
Eric Schweitz
09a84c4d7d [flang] Fix a bug with BLOCK DATA name matching
Original-commit: flang-compiler/f18@f0af26df12
Reviewed-on: https://github.com/flang-compiler/f18/pull/189
2018-09-19 15:01:38 -07:00
Tim Keith
bea570ff74 [flang] Change how messages_ is handled in ResolveNameVisitor
Change messages_ back to a reference. At the end, move them out to Annex
to the main messages object. This eliminates the need for set_messages
and ensures that messages_ is properly initialized.

Original-commit: flang-compiler/f18@78bd74501e
Reviewed-on: https://github.com/flang-compiler/f18/pull/186
2018-09-16 20:34:20 -07:00
Tim Keith
f5e29b175e [flang] Add explicit '= default' for move constructor.
Original-commit: flang-compiler/f18@7007a488ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/186
Tree-same-pre-rewrite: false
2018-09-15 15:05:59 -07:00
Tim Keith
64ed507b36 [flang] Initialize directories_ directly rather than with setter.
Original-commit: flang-compiler/f18@a9a6fc688b
Reviewed-on: https://github.com/flang-compiler/f18/pull/186
Tree-same-pre-rewrite: false
2018-09-14 16:21:37 -07:00
Tim Keith
7edb7ec69b [flang] Add top-level Semantics class
Refactor to create the Semantics class that is responsible for holding
state during semantics (the scope tree and messages) and managing the
logic of the various phases of semantic processing. Eliminate static
Scope::globalScope.

The messages generated during semantic processing are accumulated in a
Messages data member of Semantics so that individual phases don't need
to emit them to std::cerr. This is now done by the driver so that it has
control over where they go and eliminates other includes of iostream.
To do this, the messages object is passed in to the various semantics
operations.

Move DumpSymbols into semantics.cc: it doesn't belong in resolve-names.cc
and it depends on the global scope, so it's as good a place as any.
The call to RewriteParseTree is also moved to Semantics.

Original-commit: flang-compiler/f18@771d0e1293
Reviewed-on: https://github.com/flang-compiler/f18/pull/186
Tree-same-pre-rewrite: false
2018-09-14 15:04:50 -07:00
Eric Schweitz
9ea2010677 [flang] Convert some of the functions to longer names.
Original-commit: flang-compiler/f18@6cb59e916c
Reviewed-on: https://github.com/flang-compiler/f18/pull/184
2018-09-13 15:46:17 -07:00
Eric Schweitz
43da7a187e [flang] Remove incorrect error message
Original-commit: flang-compiler/f18@9ef54520df
Reviewed-on: https://github.com/flang-compiler/f18/pull/184
Tree-same-pre-rewrite: false
2018-09-13 15:46:17 -07:00
Eric Schweitz
b1938138a7 [flang] Add semantics checking for END xxx statements.
Add a negative test for END xxx names.
Reverse the sequence of calls such that resolve-label is before
resolve-name.

Original-commit: flang-compiler/f18@5fe62f108c
Reviewed-on: https://github.com/flang-compiler/f18/pull/184
Tree-same-pre-rewrite: false
2018-09-13 15:46:17 -07:00
peter klausler
a636624c71 [flang] Resolve recent NAG failures better, more clean-up, ready for merge.
Original-commit: flang-compiler/f18@5bc5a317f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/183
2018-09-13 11:29:10 -07:00
peter klausler
0f28575378 [flang] Fix recent regression on NAG tests found during pre-merge testing
Original-commit: flang-compiler/f18@1fc6d00ac8
Reviewed-on: https://github.com/flang-compiler/f18/pull/183
Tree-same-pre-rewrite: false
2018-09-13 10:29:44 -07:00
peter klausler
58b357d1ce [flang] Repair CMakeLists.txt after accidentally clang-formatting it
Original-commit: flang-compiler/f18@21eef98f47
Reviewed-on: https://github.com/flang-compiler/f18/pull/183
Tree-same-pre-rewrite: false
2018-09-12 16:37:28 -07:00
peter klausler
74563c17c1 [flang] Add "explicit" to constructors, define Type<TypeCategory::Derived>
Original-commit: flang-compiler/f18@79c165af65
Reviewed-on: https://github.com/flang-compiler/f18/pull/183
Tree-same-pre-rewrite: false
2018-09-12 16:29:23 -07:00
peter klausler
55763194f1 [flang] Merge with current master, address early review comments.
Original-commit: flang-compiler/f18@d1f981ddb4
Reviewed-on: https://github.com/flang-compiler/f18/pull/183
Tree-same-pre-rewrite: false
2018-09-12 16:29:22 -07:00