Commit graph

290 commits

Author SHA1 Message Date
Jean Perier c61c03c32e [flang] Address review comments
Original-commit: flang-compiler/f18@0c975ed88c
Tree-same-pre-rewrite: false
2019-04-23 05:57:50 -07:00
Jean Perier 1cc1ef2629 [flang] Fix allocate in deallocate01.f90 test
Original-commit: flang-compiler/f18@681e51f50b
Tree-same-pre-rewrite: false
2019-04-23 03:05:57 -07:00
Jean Perier ce05ebf748 [flang] First batch of semantics checks for allocate
Original-commit: flang-compiler/f18@1019a84ac8
Tree-same-pre-rewrite: false
2019-04-23 03:05:56 -07:00
Tim Keith ed26a23f8a [flang] Continue semantics checks after expression error
Change statement semantics to continue with checks after an error
in expression analysis. This allows the compiler to report more
compilation errors. It requires that statement semantics not assume
that every parser::Expr has a valid evaluate::Expr.

For example, the test cases in coarrays02.f90 can now be moved to
coarrays01.f90. Previously the errors like "Must be a scalar value"
from ExprChecker prevented other errors from being detected by
CoarrayChecker.

Change to a stable sort of messages so that they come out in a
deterministic order. Otherwise when there are two errors at the
same location (e.g. line 71 of coarrays01.f90) the test can fail
randomly.

Original-commit: flang-compiler/f18@f420d21909
Reviewed-on: https://github.com/flang-compiler/f18/pull/422
Tree-same-pre-rewrite: false
2019-04-19 09:21:12 -07:00
Tim Keith 5094c3c584 [flang] Save and fetch analyzed Expr in Variable
Add typedExpr data member to Variable like that in Expr.
When expression analysis analyzed a Variable it stores the
resulting evaluate::Expr there.

Add GetExpr overloads in semantics/tools.h for using in statement
semantics. It gets an evaluate::Expr from an Expr, Variable, or
wrapper around one of those. It returns a const pointer so that
clients cannot modify the cached expression (and copies do not
have to be made).

Change CoarrayChecker to make use of GetExpr. It will eventually
replace all references to typedExpr in statement semantics.

Original-commit: flang-compiler/f18@b02a41efe1
Reviewed-on: https://github.com/flang-compiler/f18/pull/422
Tree-same-pre-rewrite: false
2019-04-18 17:48:55 -07:00
peter klausler 146e13ce22 [flang] Fold array operations
Original-commit: flang-compiler/f18@e6c86ecfd1
Reviewed-on: https://github.com/flang-compiler/f18/pull/420
2019-04-18 14:48:05 -07:00
Paul Osmialowski 306873e7a8 [flang] Semantics checker for STOP and ERROR STOP statements - one more batch of post-review tweaks
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@f49ee0df05
Reviewed-on: https://github.com/flang-compiler/f18/pull/367
Tree-same-pre-rewrite: false
2019-04-17 14:13:23 -07:00
Paul Osmialowski 9cb7ec52e2 [flang] Semantics checker for STOP and ERROR STOP statements - remove overhead checks and corresponding test cases
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@6ce6234acc
Reviewed-on: https://github.com/flang-compiler/f18/pull/367
Tree-same-pre-rewrite: false
2019-04-17 14:13:23 -07:00
Paul Osmialowski 54068ddbca [flang] Semantics checker for STOP and ERROR STOP statements - test file rename
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@b89137b614
Reviewed-on: https://github.com/flang-compiler/f18/pull/367
Tree-same-pre-rewrite: false
2019-04-17 14:13:23 -07:00
Paul Osmialowski d1e409ab09 [flang] Semantics checker for STOP and ERROR STOP statements.
This commit introduces a new checker (StopChecker) for STOP
and ERROR STOP Fortran statements along with a test code.

Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@c554174562
Reviewed-on: https://github.com/flang-compiler/f18/pull/367
Tree-same-pre-rewrite: false
2019-04-17 14:13:23 -07:00
Tim Keith fab062244b [flang] Fix bug resolving internal and module functions
When analyzing a function call in an expression we weren't properly
recognizing a ProcedureDesignator that was the name of an internal
or module function, i.e. a symbol with SubprogramDetails.

The fix is to add IsProcedure to identify symbols that correspond
to procedures. IsFunction and GetType also need to be extended to
handle this case.

Fixes flang-compiler/f18#391.

Original-commit: flang-compiler/f18@f165f8d38c
Reviewed-on: https://github.com/flang-compiler/f18/pull/417
Tree-same-pre-rewrite: false
2019-04-17 07:42:16 -07:00
Jean Perier d1659ca3b4 [flang] removed unused func in tests
Original-commit: flang-compiler/f18@4c6e6ad4d0
Tree-same-pre-rewrite: false
2019-04-15 01:18:40 -07:00
Jean Perier 44e0c5084d [flang] Add software subnormal flusing around host library call for host arch that do not support it
Original-commit: flang-compiler/f18@04555f5359
Tree-same-pre-rewrite: false
2019-04-15 01:18:40 -07:00
Jean Perier 48daa0f9a9 [flang] make host subnormal flsuhing control test runtime independent
Original-commit: flang-compiler/f18@96b25596a7
Tree-same-pre-rewrite: false
2019-04-15 01:18:39 -07:00
Jean Perier db2f460e52 [flang] Test host subnormal flushing setup when folding on host
Original-commit: flang-compiler/f18@78381c897d
Tree-same-pre-rewrite: false
2019-04-15 01:18:38 -07:00
Tim Keith b2f84a5eda [flang] More coarray name resolution and semantic checks
Add CoarrayChecker to check for valid team-value in CHANGE TEAM,
SYNC TEAM, and image selector. Check that coarray names and selector
names are distinct in CHANGE TEAM.

Resolve the variable in a coarray-association.
Create a scope for the construct entities of a CHANGE TEAM construct.

Add ResolveSelector to resolve a parser::Selector into an Expr and
optional variable name (and a source location for messages). Make use of
ResolveSelector to handle coarray-association, as well as it's previous
use in associate-stmt.

Improve the check for C1157 in select-type-stmt and add a test.

Add a test for "Associate name must have a type".

Move ResolveName, ResolveDataRef, etc. from ResolveNamesVisitor
to DeclarationVisitor so that they are available in ConstructVisitor
as well. Add ResolveVariable and ResolveDesignator.

In the parse tree, change TeamValue from a type alias to a wrapper
class. We already had a wrapper class anyway, ImageSelectorSpec::Team,
so the new TeamValue can be used instead. This allows the member
of ImageSelectorSpec to be treated like other occurrences of TeamValue.

Original-commit: flang-compiler/f18@f856744b54
Reviewed-on: https://github.com/flang-compiler/f18/pull/414
Tree-same-pre-rewrite: false
2019-04-15 14:07:11 -07:00
Steve Scalpone 85661f4657 [flang] Implement semantic checks for return and alt-return.
Original-commit: flang-compiler/f18@123c23783b
Tree-same-pre-rewrite: false
2019-04-15 10:59:12 -07:00
peter klausler 8529034ea0 [flang] Capitalize INTEGER in error messages
Original-commit: flang-compiler/f18@c00527c681
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 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 7243929103 [flang] Split doconcurrent04.f90 test into one with expression checks and one for later semantics pass.
Original-commit: flang-compiler/f18@6b9c25177b
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:41:47 -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
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
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 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 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
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 94d0b8fb0a [flang] Address review comments
Original-commit: flang-compiler/f18@20cef2db45
Reviewed-on: https://github.com/flang-compiler/f18/pull/386
2019-04-05 15:19:13 -07:00
peter klausler 130e166a6e [flang] Remove hash from expected module file output
Original-commit: flang-compiler/f18@8da47c44d2
Reviewed-on: https://github.com/flang-compiler/f18/pull/386
Tree-same-pre-rewrite: false
2019-04-05 13:09:02 -07:00
peter klausler 5c3197fa0b [flang] Fix implied DO folding with negative strides, add test
Original-commit: flang-compiler/f18@2e14b76041
Reviewed-on: https://github.com/flang-compiler/f18/pull/386
Tree-same-pre-rewrite: false
2019-04-05 12:58:19 -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
Tim Keith 720b1a7de4 [flang] Fix test
A sequence type must have a component.

Original-commit: flang-compiler/f18@937b3eaf06
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
2019-04-01 07:15:03 -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 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
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 af958345ce [flang] Use operator<< in test.
Original-commit: flang-compiler/f18@e3f321e9f0
Reviewed-on: https://github.com/flang-compiler/f18/pull/371
Tree-same-pre-rewrite: false
2019-04-01 13:03:26 -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 b35f4a98e2 [flang] work in progress
Original-commit: flang-compiler/f18@33ea8e506a
Reviewed-on: https://github.com/flang-compiler/f18/pull/371
Tree-same-pre-rewrite: false
2019-04-01 10:59:00 -07:00
peter klausler e0f76d2306 [flang] Support CONVERT= and DISPOSE= on INQUIRE
Original-commit: flang-compiler/f18@fbedd32376
Reviewed-on: https://github.com/flang-compiler/f18/pull/352
Tree-same-pre-rewrite: false
2019-04-01 10:14:19 -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
Peter Steinfeld 8586f299e3 [flang] This test fails when the directory in which test tests are run contains a path that matches the pattern "do *[1-9]". In my case, I had a directory called "do1". The "*" is not necessary in the pattern. Now the test passes unless the directory contains a " ".
Original-commit: flang-compiler/f18@462f15e4e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/365
2019-03-28 17:17:30 -07:00
Jean Perier 9f98662b5f [flang] Fix F18 scalar integer power algorithm
Original-commit: flang-compiler/f18@f0609e7ace
2019-03-28 08:18:42 -07:00
Jean Perier 07f6963dbb [flang] Remove non standard use of bessel C functions
Original-commit: flang-compiler/f18@a40559372a
Tree-same-pre-rewrite: false
2019-03-28 04:25:13 -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
Jean Perier be5cfaa5c7 [flang] fix clang errors and warnings
Original-commit: flang-compiler/f18@410f96384f
Tree-same-pre-rewrite: false
2019-03-27 10:16:07 -07:00
Jean Perier 8f0eb89cb6 [flang] Test cases for folding intrinsic function with runtime
Original-commit: flang-compiler/f18@92caee1def
Tree-same-pre-rewrite: false
2019-03-27 10:16:07 -07:00
Jean Perier 63cdc3b0d3 [flang] Cherry picking commits from #PR275 and simplifying it
Commit was: Draft of elemental intrinsics function folding

Simplification was made in order to solve conflicts and
to prepare for commit of host math library indirection.

Conflicts:
	lib/evaluate/fold.cc

Original-commit: flang-compiler/f18@45678bc44c
Tree-same-pre-rewrite: false
2019-03-27 10:16:07 -07:00