Commit graph

568 commits

Author SHA1 Message Date
peter klausler
32424cad2d [flang] reformatting
Original-commit: flang-compiler/f18@d9bfa6f48e
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:44:54 -07:00
peter klausler
ba2ef03a02 [flang] pass all tests
Original-commit: flang-compiler/f18@3cee1993a1
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:41:50 -07:00
peter klausler
a90455057c [flang] Ensure no failed expression analyses without fatal errors.
Original-commit: flang-compiler/f18@3ef8b43031
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:41:49 -07:00
peter klausler
3484149aa7 [flang] Finish up
Original-commit: flang-compiler/f18@8c8242e6f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:41:48 -07:00
peter klausler
b39d0c51e4 [flang] Reactivate tree-driven constraint checking on expressions.
Original-commit: flang-compiler/f18@85c4a6aab6
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:41:41 -07:00
Tim Keith
b69c2c6997 [flang] Remove ObjectName alternative from Designator
A simple name in a `Designator` is always parsed as a `DataRef`, not
an `ObjectName`. So remove that alternative.

`StmtFunctionStmt::ConvertToAssignment` was creating a `Designator` with
that alternative: change it to do the same thing as the parser.

Add `GetSimpleName` utility functions to check if an `Expr` or `Variable`
represents a simple name. Many of the places that checked for `ObjectName`
in `Designator` are trying to do that.

Clean up includes and forward declarations in `tools.h`.

Original-commit: flang-compiler/f18@97d44de7b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/410
2019-04-12 16:30:03 -07:00
Steve Scalpone
a0e06bb5d4 [flang] Cleanup -- Remove unnecessary inline keyword,
remove unnecessary (void) casts when ignoring
return values, call context_.Say() directly
instead of via messages(), and fix up some
formatting issues using clang-format.

Original-commit: flang-compiler/f18@68e5c02541
Reviewed-on: https://github.com/flang-compiler/f18/pull/404
2019-04-11 15:20:14 -07:00
Peter Steinfeld
cdede97e39 [flang] Hopefully the last fixup of messages that appear for bad termination
of a DO loop.

Original-commit: flang-compiler/f18@23f7471f3a
Reviewed-on: https://github.com/flang-compiler/f18/pull/400
2019-04-11 15:35:44 -07:00
Peter Steinfeld
563d7a6c4c [flang] My last change neglected to include the change to the message.
Original-commit: flang-compiler/f18@09444379f7
Reviewed-on: https://github.com/flang-compiler/f18/pull/400
Tree-same-pre-rewrite: false
2019-04-11 15:35:44 -07:00
Peter Steinfeld
22b489508c [flang] Removed unused parameter and tweaked the error message one more time.
Original-commit: flang-compiler/f18@476791da2a
Reviewed-on: https://github.com/flang-compiler/f18/pull/400
Tree-same-pre-rewrite: false
2019-04-11 15:35:44 -07:00
Steve Scalpone
23c31c968e [flang] Simply use context_.Say. Update test with duplicate dealloc opts.
Original-commit: flang-compiler/f18@61b7461552
Reviewed-on: https://github.com/flang-compiler/f18/pull/401
2019-04-11 09:39:32 -07:00
Steve Scalpone
ee79690a0f [flang] Correct constraint numbers. Fix spelling error. Run clang-format.
Original-commit: flang-compiler/f18@59df0d39f3
Reviewed-on: https://github.com/flang-compiler/f18/pull/401
Tree-same-pre-rewrite: false
2019-04-11 04:16:14 -07:00
Steve Scalpone
70285af0ad [flang] Implement semantic checks for DEALLOCATE statements.
The parser checks for duplicate dealloc-opts and expr
analysis checks that dealloc-opts are the right type.

Original-commit: flang-compiler/f18@1ade7f6617
Reviewed-on: https://github.com/flang-compiler/f18/pull/401
Tree-same-pre-rewrite: false
2019-04-10 22:17:44 -07:00
Peter Steinfeld
95d8de80fe [flang] Changed the DO loop termination message to be different for the error
case.

Original-commit: flang-compiler/f18@51cf517cca
Reviewed-on: https://github.com/flang-compiler/f18/pull/398
2019-04-10 13:06:48 -07:00
Peter Steinfeld
5c7687bdbe [flang] Removed erroneous reference to "obsolete" and fixed up the message
as per Peter Klauser's recommendation.

Original-commit: flang-compiler/f18@f4d6d7007d
Reviewed-on: https://github.com/flang-compiler/f18/pull/398
Tree-same-pre-rewrite: false
2019-04-10 11:40:52 -07:00
Peter Steinfeld
7272fb7834 [flang] Fixed up messages per comments from Peter Klausler.
Original-commit: flang-compiler/f18@4103ca4297
Reviewed-on: https://github.com/flang-compiler/f18/pull/398
Tree-same-pre-rewrite: false
2019-04-10 10:52:47 -07:00
Peter Steinfeld
259c540191 [flang] Fix issue 392, improve the error message when a DO loop is
terminated by a statement other than END DO or CONTINUE.

Original-commit: flang-compiler/f18@0a9280eab1
Reviewed-on: https://github.com/flang-compiler/f18/pull/398
Tree-same-pre-rewrite: false
2019-04-10 09:50:27 -07:00
peter klausler
923c891111 [flang] Do not replace format with namelist if there is no unit (avoiding accidental language extension)
Original-commit: flang-compiler/f18@08562d9b86
Reviewed-on: https://github.com/flang-compiler/f18/pull/394
2019-04-10 08:52:46 -07:00
peter klausler
0e55f2463b [flang] Rewrite read-stmt/write-stmt parse trees for misparsed namelist group names
Original-commit: flang-compiler/f18@e0f1b1c469
Reviewed-on: https://github.com/flang-compiler/f18/pull/394
Tree-same-pre-rewrite: false
2019-04-10 08:52:42 -07:00
peter klausler
4950dfa04e [flang] Redo without macros
Original-commit: flang-compiler/f18@8d955cfb3b
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
2019-04-09 13:29:40 -07:00
peter klausler
8057a2ce32 [flang] Lots of debugging and refinement
Original-commit: flang-compiler/f18@1c3c30b540
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
2019-04-08 16:16:55 -07:00
peter klausler
17c4ae070b [flang] Revert that reversion. Move semantics work just fine.
Original-commit: flang-compiler/f18@72bd8e7b03
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
2019-04-08 14:29:47 -07:00
peter klausler
d0e7775431 [flang] Revert to forwarding on variadic messaging APIs
Original-commit: flang-compiler/f18@d2e464eb15
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
2019-04-08 14:29:47 -07:00
peter klausler
dc9c3d1c46 [flang] Fix bug#389, prevent std::move() on forwarded lvalue references
Original-commit: flang-compiler/f18@9d61c091ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
2019-04-08 14:29:45 -07:00
Steve Scalpone
9fbc37abf7 [flang] Use structureComponent.component.symbol directly instead of getting
the symbol from the result of expression analysis.  (This opens the
door to moving structure component semantic checking to expression
analysis.)

Also, improve error messages, remove unused include files, and add
copyright headers to test files.

Original-commit: flang-compiler/f18@17780c40d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/388
2019-04-08 00:26:10 -07:00
Steve Scalpone
37a53df82c [flang] Check semantic contraints for the nullify statement. The full
legality check is up to the user; however, some checks could
be done at compile time and others at runtime.  We choose to
skip any checking at compile time because it would not be
complete.

Note the instantiation of ExtractDataRef in expressions.cc.
This instantiation satifies the reference in check-nullify.cc
because expression.h just has a declaration of ExtractDataRef
instead of the definition.

Original-commit: flang-compiler/f18@b7199219fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/388
Tree-same-pre-rewrite: false
2019-04-07 11:29:48 -07:00
peter klausler
28184c4a49 [flang] Simplify expression visitor usage
Original-commit: flang-compiler/f18@9ab121d6a6
Reviewed-on: https://github.com/flang-compiler/f18/pull/386
Tree-same-pre-rewrite: false
2019-04-05 12:56:09 -07:00
Tim Keith
bc140ed13c [flang] Address review comments.
Change AnalyzeArraySpec and AnalyzeCoarraySpec to return resulting
ArraySpec by value.

Original-commit: flang-compiler/f18@0ae38143e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/384
2019-04-04 16:32:37 -07:00
Tim Keith
b7efa8b77b [flang] Support coarrays in name resolution
A coarray is represented as a `Symbol` with `ObjectEntityDetails` that
has a non-empty coshape. The coshape is represented using the same type
(`ArrayShape`) as the shape is, so the fact that it is a coshape is
determined from context.

Move code for analyzing shapes to `resolve-names-utils.cc` and
generalize it for coshapes.

In `symbol.cc` add dumping of coshapes. Simplify some of the functions
by adding some `Dump*` functions to handle common cases.

In `mod-file.cc` generalize the code for writing shapes to also write
coshapes. Fix a bug in `PutShapeSpec()`.

Original-commit: flang-compiler/f18@9d2482c40c
Reviewed-on: https://github.com/flang-compiler/f18/pull/384
Tree-same-pre-rewrite: false
2019-04-04 14:47:59 -07:00
Tim Keith
0f4ef956a9 [flang] Pointer assignment bounds, section subscript, substring
Resolve bounds in pointer assignment.
Remove TODOs for section-subscript and substring range.
Add tests that verify they are done.

Original-commit: flang-compiler/f18@dc2dd85a9a
Reviewed-on: https://github.com/flang-compiler/f18/pull/380
2019-04-02 15:36:20 -07:00
Steve Scalpone
c95b56d5a0 [flang] Remove unused variable in check-if-stmt.cc
Original-commit: flang-compiler/f18@520751311d
Reviewed-on: https://github.com/flang-compiler/f18/pull/375
2019-04-01 21:28:16 -07:00
peter klausler
4eade259b3 [flang] Address comments, clean up warnings
Original-commit: flang-compiler/f18@a5eeeb4430
Reviewed-on: https://github.com/flang-compiler/f18/pull/378
2019-04-02 11:56:19 -07:00
peter klausler
5dae2fb1a9 [flang] Clean up and prep for review
Original-commit: flang-compiler/f18@3f96c673e0
Reviewed-on: https://github.com/flang-compiler/f18/pull/378
Tree-same-pre-rewrite: false
2019-04-02 10:59:11 -07:00
peter klausler
ec2448123e [flang] Fix bug flang-compiler/f18#376, internal error when correcting misparse of structure constructor
Original-commit: flang-compiler/f18@f18a94ef96
Reviewed-on: https://github.com/flang-compiler/f18/pull/378
Tree-same-pre-rewrite: false
2019-04-02 10:59:09 -07:00
Tim Keith
d628a6f983 [flang] Rework .mod file writing for subprogram interfaces
A subprogram interface in a `.mod` file requires all of the symbols
needed to declare the function return value and dummy arguments.
Some of those were missing.

`SubprogramSymbolCollector` recursively discovers all such symbols,
including symbols used in type parameters, array bounds, character
lengths, parent types.

Common blocks require special handling: If any of the symbols that
are need appear in a common block, we have to include that common block
and all other symbols in it. To make that easier to figure out, add the
`commonBlock` property to `ObjectEntityDetails` to map the entity to
the common block it is in, if any.

Original-commit: flang-compiler/f18@08709f8e88
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false
2019-03-29 15:04:17 -07:00
Tim Keith
b4dc611eb4 [flang] Resolve LHS in pointer assignment
Original-commit: flang-compiler/f18@9a3525275c
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false
2019-03-29 09:08:49 -07:00
Tim Keith
e1ea983b0a [flang] Dump function return attributes
Also, change SubprogramDetails::result_ from `std::optional<Symbol *>`
to `Symbol *`. We don't need two levels of optional-ness.

Original-commit: flang-compiler/f18@db3b874946
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false
2019-03-29 09:08:18 -07:00
Tim Keith
fdba48a74c [flang] Don't add inherited procedures to generic binding
In this example:
```
  type t1
  contains
    procedure, nopass :: s1
    generic :: foo => s1
  end type
  type, extends(t1) :: t2
  contains
    procedure, nopass :: s2
    generic :: foo => s2
  end type
```

The GenericBindingDetails for foo in t2 include both s1 and s2 as
specific procs. There is no way to distinguish between the binding in
the current type and the binding that was inherited. In particular,
the .mod file will have a binding for s1 in t2, so it won't match the
original source (for exampke, see the old version of modfile14.f90).

Original-commit: flang-compiler/f18@4e2c6be5cb
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false
2019-03-29 09:07:27 -07:00
peter klausler
3c5a25a1bd [flang] Use source location in IF statement checks.
Original-commit: flang-compiler/f18@9e08746e2b
Reviewed-on: https://github.com/flang-compiler/f18/pull/373
Tree-same-pre-rewrite: false
2019-04-01 16:23:34 -07:00
peter klausler
1fb4869367 [flang] Fix typo
Original-commit: flang-compiler/f18@c5b05009df
Reviewed-on: https://github.com/flang-compiler/f18/pull/373
Tree-same-pre-rewrite: false
2019-04-01 16:23:33 -07:00
peter klausler
6fa22f95e0 [flang] Fix typo
Original-commit: flang-compiler/f18@6be309300e
Reviewed-on: https://github.com/flang-compiler/f18/pull/373
Tree-same-pre-rewrite: false
2019-04-01 16:23:33 -07:00
peter klausler
0ff94b9d0b [flang] Define and use UnlabeledStatement<> for if & forall
Original-commit: flang-compiler/f18@028e6aba6c
Reviewed-on: https://github.com/flang-compiler/f18/pull/373
Tree-same-pre-rewrite: false
2019-04-01 16:23:32 -07:00
Tim Keith
68df5ac3a2 [flang] Name resolution bug fixes
Fix a but where a derived type was not use-associated correctly
due to missing call to `GetUltimate()`.

Fix a bug with access statement, generic interface, and derived
type all with the same name.

Remove some TODOs that have been done.

Original-commit: flang-compiler/f18@4ba2b64c6d
Reviewed-on: https://github.com/flang-compiler/f18/pull/372
2019-04-01 13:08:57 -07:00
peter klausler
f719b4ae6e [flang] Revert to AsFortran in module file output.
Original-commit: flang-compiler/f18@3dc7f685d1
Reviewed-on: https://github.com/flang-compiler/f18/pull/371
2019-04-01 15:02:23 -07:00
peter klausler
9e9b9f0776 [flang] Pass tests
Original-commit: flang-compiler/f18@ffb057f262
Reviewed-on: https://github.com/flang-compiler/f18/pull/371
Tree-same-pre-rewrite: false
2019-04-01 12:30:08 -07:00
peter klausler
95b4e65ecf [flang] Move some AsFortran() implementations into new formatting.cc; use precedence for parentheses
Original-commit: flang-compiler/f18@2b5fa051df
Reviewed-on: https://github.com/flang-compiler/f18/pull/371
Tree-same-pre-rewrite: false
2019-04-01 10:58:55 -07:00
peter klausler
822810f017 [flang] Check int literals for overflow when kind is known.
improve test

Original-commit: flang-compiler/f18@09ce783cd3
Reviewed-on: https://github.com/flang-compiler/f18/pull/352
Tree-same-pre-rewrite: false
2019-04-01 10:14:16 -07:00
Steve Scalpone
1de9ecd251 [flang] Add CMake rules to install static and shared libraries in
the default install directory or in the directory specified
with CMAKE_INSTALL_PREFIX.  Fixes flang-compiler/f18#359.

Original-commit: flang-compiler/f18@35ce1628e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/364
2019-03-28 09:55:56 -07:00
Tim Keith
3e8c62b48b [flang] Track current statement location in SemanticsVisitor
Change `SemanticsVisitor` to track the location of the current
statement, if any, so that it's available through
`SemanticsContext::location()`

Add overloading of `SemanticsContext::Say()` that reports the
message at the location of the current statement if a `CharBlock`
is not provided.

Original-commit: flang-compiler/f18@5185c721ee
Reviewed-on: https://github.com/flang-compiler/f18/pull/357
2019-03-26 12:40:13 -07:00
Steve Scalpone
b8ce6f11ad [flang] Removed unused #include files from check-computed-goto.cc.
Did the same for a few other similar files.

Original-commit: flang-compiler/f18@6f7569b938
Reviewed-on: https://github.com/flang-compiler/f18/pull/360
2019-03-27 20:46:51 -07:00
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