Commit graph

504 commits

Author SHA1 Message Date
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