Commit Graph

1771 Commits

Author SHA1 Message Date
peter klausler bb83471e96 [flang] Fix folding of substring
Original-commit: flang-compiler/f18@62dc5e0c93
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:28:57 -07:00
peter klausler 52d46695fc [flang] Handle remaining cases in expression traversal
Original-commit: flang-compiler/f18@5cb0de58d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:28:56 -07:00
Brian 2105abf176 [flang] Merge pull request flang-compiler/f18#450 from flang-compiler/by-pgf90-mp
Add -mp option for pgf90 in the presence of -fopenmp

Original-commit: flang-compiler/f18@e07b20a799
Reviewed-on: https://github.com/flang-compiler/f18/pull/450
2019-05-08 10:24:57 -07:00
Jinxin Yang 80ccd20f3b [flang] Add -mp option for pgf90 in the presence of -fopenmp
Original-commit: flang-compiler/f18@a9d7287420
Reviewed-on: https://github.com/flang-compiler/f18/pull/450
2019-05-08 08:43:20 -07:00
Peter Klausler f11652a1e6 [flang] Merge pull request flang-compiler/f18#444 from flang-compiler/pmk-msg-format
Replace formatting of CharBlock & string

Original-commit: flang-compiler/f18@359bedbefd
Reviewed-on: https://github.com/flang-compiler/f18/pull/444
2019-05-07 12:15:49 -07:00
peter klausler 4ffb37e593 [flang] Remove support for Names in messages for now.
Original-commit: flang-compiler/f18@15d38c7059
Reviewed-on: https://github.com/flang-compiler/f18/pull/444
2019-05-07 10:04:21 -07:00
peter klausler f704d38129 [flang] Merge with recent changes
Original-commit: flang-compiler/f18@56a72cbbd6
Reviewed-on: https://github.com/flang-compiler/f18/pull/444
Tree-same-pre-rewrite: false
2019-05-07 09:24:35 -07:00
peter klausler ec6cf76536 [flang] Replace formatting of CharBlock & string
Preserve generated strings until consumed by formatting.

bugfix from premature push

Address review comments

Last fix(?)

Use %s formatting for CharBlocks and strings

Use new formatting and fix usage of std::forward<>()

Use forward_list rather than vector to save strings

Original-commit: flang-compiler/f18@8ea478420f
Reviewed-on: https://github.com/flang-compiler/f18/pull/444
Tree-same-pre-rewrite: false
2019-05-07 09:24:32 -07:00
jeanPerier 7334b71023 [flang] Change a user error to an internal error in ALLOCATE semantic check
Merge pull request flang-compiler/f18#448 from flang-compiler/jpr-check-allocate

Original-commit: flang-compiler/f18@66e766ac9a
2019-05-07 08:44:23 -07:00
Jean Perier a11ab23ccb [flang] Change a user error to an internal error in ALLOCATE semantic check
Original-commit: flang-compiler/f18@d9a9b59634
2019-05-07 08:28:24 -07:00
Tim Keith 8e212800c6 [flang] Merge pull request flang-compiler/f18#443 from flang-compiler/tsk4b
Process specification parts before execution parts

Original-commit: flang-compiler/f18@c8d3a77c02
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
2019-05-07 07:35:58 -07:00
Tim Keith de36472ef7 [flang] Re-enable test resolve51.f90
Original-commit: flang-compiler/f18@595e45fd34
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
2019-05-07 07:35:10 -07:00
Tim Keith 409212cf43 [flang] Move ProgramTree to its own file
Original-commit: flang-compiler/f18@06913c38ca
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
Tree-same-pre-rewrite: false
2019-05-06 10:12:27 -07:00
Tim Keith 14094c71c8 [flang] Process specification parts before execution parts
Change the order in which names are resolved. Before resolving names
in the execution part of a subprogram we need to know the interface
of contained subprograms. This is because the type of some construct
entities can depend on the return type of contained functions, e.g.
```
  associate(x => f())
  end associate
contains
  function f()...
```

To do this, we now build a tree rooted at each program unit with
child nodes corresponding to subprograms contained in the parent.
This provides flexibility in choosing an order to resolve names.
The current implementation processes all specification parts before
any execution parts. This ensures contained subprogram interfaces
are know before analyzing constructs like ASSOCIATE.

Resolving a specification part involves first adding
`SubprogramNameDetails` symbols for each contained subprogram, then
processing the statement that introduces the program unit (`ModuleStmt`,
`SubroutineStmt`, etc.), then visiting all of the statements in the
specification part.

If it proves necessary, we can add a phase to do implicit declarations
in the execution part before processing the specification part of
contained subprograms.

Original-commit: flang-compiler/f18@20e803fd92
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
Tree-same-pre-rewrite: false
2019-05-06 07:26:43 -07:00
Tim Keith 12f1660117 [flang] Add DIE macro
`DIE()` is like `common::die()` but with the source location appended,
as in `CHECK()`.

Original-commit: flang-compiler/f18@ed586c3f38
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
Tree-same-pre-rewrite: false
2019-05-03 08:02:31 -07:00
Tim Keith 28f80675e9 [flang] Change how Scopes are mapped to ImplicitRules
Previously we maintained a stack of ImplicitRules in parallel with
the Scope stack. Change to maintaining a mapping from Scope to
ImplicitRules.

This makes things simpler in some cases: Block scopes don't have their
own implicit rules. And submodule scopes aren't just pushed and popped.
This will also help with future changes to the order in which scopes
are processed.

Original-commit: flang-compiler/f18@443da50352
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
Tree-same-pre-rewrite: false
2019-05-02 11:19:01 -07:00
Peter Klausler 9ba14957e8 [flang] Merge pull request flang-compiler/f18#445 from flang-compiler/pmk-fixes
Fix or disable broken tests.

Original-commit: flang-compiler/f18@1d384b549a
Reviewed-on: https://github.com/flang-compiler/f18/pull/445
2019-05-06 11:44:36 -07:00
peter klausler eebc7ba001 [flang] Fix or disable broken tests.
Original-commit: flang-compiler/f18@a54396e92e
Reviewed-on: https://github.com/flang-compiler/f18/pull/445
2019-05-06 11:33:33 -07:00
Peter Klausler fbfb00dac8 [flang] Merge pull request flang-compiler/f18#442 from flang-compiler/pmk-struct-const
Semantics of structure constructors, part 2 of 2

Original-commit: flang-compiler/f18@2672b41af6
Reviewed-on: https://github.com/flang-compiler/f18/pull/442
2019-05-06 08:22:49 -07:00
peter klausler 1733317ad9 [flang] Tweak error message grammar
Original-commit: flang-compiler/f18@4190b97ecc
Reviewed-on: https://github.com/flang-compiler/f18/pull/442
2019-05-06 08:22:22 -07:00
peter klausler 5a18e79d5a [flang] Remove OwningPointer and ForwardReference
Use std::unique_ptr<> with custom deleter for forward-referenced owned pointer.

Move CopyableIndirection into common, add documentation, clean up.

Remove OwningPointer and ForwardReference

Use std::unique_ptr<> with custom deleter for forward-referenced owned pointer.

Use CopyableIndirection

clean up from merge after split

Complete characterization

fold conversions of arrays

Clean up subscripts to constant arrays

Elemental unary operations complete

Support assumed type TYPE(*) in actual arguments

clean up some TODOs

recognize TYPE(*) arguments to intrinsics

Complete folding of array operations

Finish elementwise array folding, add test, debug

characterize intrinsics, fix some bugs

Clean up build

Type compatibility and shape conformance checks on pointer assignments

Original-commit: flang-compiler/f18@99d734c621
Reviewed-on: https://github.com/flang-compiler/f18/pull/442
Tree-same-pre-rewrite: false
2019-05-06 07:51:07 -07:00
jeanPerier d427b58843 [flang] Allocate semantic checks (second and last part)
Merge pull request flang-compiler/f18#436 from flang-compiler/jpr-check-allocate

Original-commit: flang-compiler/f18@f4d89974d2
2019-05-06 08:02:23 -07:00
Jean Perier 6370087abc [flang] Address comments
Original-commit: flang-compiler/f18@2a6473ce6a
2019-05-03 01:31:48 -07:00
Jean Perier c67710e5ae [flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.

Original-commit: flang-compiler/f18@b4965d272b
Tree-same-pre-rewrite: false
2019-05-03 00:45:22 -07:00
Peter Klausler 672aadbfda [flang] Merge pull request flang-compiler/f18#441 from flang-compiler/pmk-message-cleanup
Support std::string and CharBlock in formatted messages

Original-commit: flang-compiler/f18@4b9431bae9
Reviewed-on: https://github.com/flang-compiler/f18/pull/441
2019-05-06 07:48:44 -07:00
peter klausler 9c369277a5 [flang] Prevent unhandled special formatting
Original-commit: flang-compiler/f18@378e0e2325
Reviewed-on: https://github.com/flang-compiler/f18/pull/441
2019-05-03 16:53:45 -07:00
peter klausler 1eece3d125 [flang] Support %zu and %ju before special codes; add comments
Original-commit: flang-compiler/f18@d237d4122b
Reviewed-on: https://github.com/flang-compiler/f18/pull/441
Tree-same-pre-rewrite: false
2019-05-03 16:07:37 -07:00
peter klausler 789b7d67b2 [flang] Add comments
Original-commit: flang-compiler/f18@3bd10af06b
Reviewed-on: https://github.com/flang-compiler/f18/pull/441
Tree-same-pre-rewrite: false
2019-05-03 15:17:59 -07:00
peter klausler 68209d4f87 [flang] Support std::string and CharBlock in formatted messages
fix off-by-one

Original-commit: flang-compiler/f18@58eb11c5c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/441
Tree-same-pre-rewrite: false
2019-05-03 15:10:03 -07:00
Peter Klausler bc0732002e [flang] Merge pull request flang-compiler/f18#440 from flang-compiler/pmk1
Changes from code review

Original-commit: flang-compiler/f18@c945b52b05
Reviewed-on: https://github.com/flang-compiler/f18/pull/440
2019-05-03 14:47:32 -07:00
peter klausler 80602cdb74 [flang] Changes from review
Original-commit: flang-compiler/f18@feafc0c216
Reviewed-on: https://github.com/flang-compiler/f18/pull/440
2019-05-03 14:42:33 -07:00
Peter Klausler 4831c41440 [flang] Merge pull request flang-compiler/f18#439 from flang-compiler/pmk1
Structure constructor semantics, part 1 of 2

Original-commit: flang-compiler/f18@56f3f7bd90
Reviewed-on: https://github.com/flang-compiler/f18/pull/439
2019-05-03 14:40:31 -07:00
peter klausler 25e6f03443 [flang] lib/evaluate work for structure constructors
Original-commit: flang-compiler/f18@76a192f9c9
Reviewed-on: https://github.com/flang-compiler/f18/pull/439
2019-05-03 11:29:15 -07:00
Peter Klausler c1fa835a71 [flang] Merge pull request flang-compiler/f18#438 from flang-compiler/pmk-fix-pp-noargs
Fix bug flang-compiler/f18#437

Original-commit: flang-compiler/f18@3dbcc78d77
Reviewed-on: https://github.com/flang-compiler/f18/pull/438
2019-05-02 19:07:01 -07:00
peter klausler 14b5cdd4d0 [flang] Fix f90_correct test failure
Original-commit: flang-compiler/f18@ff7a5af50b
Reviewed-on: https://github.com/flang-compiler/f18/pull/438
2019-05-02 15:19:37 -07:00
peter klausler b3682933f3 [flang] Fix bug flang-compiler/f18#437, func-like macro call with no arguments
Original-commit: flang-compiler/f18@d106290f19
Reviewed-on: https://github.com/flang-compiler/f18/pull/438
Tree-same-pre-rewrite: false
2019-05-02 14:29:52 -07:00
psteinfeld 4245cae846 [flang] Merge pull request flang-compiler/f18#434 from flang-compiler/ps
Tests for C1131, DO loop names

Original-commit: flang-compiler/f18@d1c94d97ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/434
2019-05-01 13:12:49 -07:00
Peter Steinfeld b77f059862 [flang] Changed the test for unmatched DO loop names to use test_errors.sh
rather than test_any.sh.

Original-commit: flang-compiler/f18@c02aff4570
Reviewed-on: https://github.com/flang-compiler/f18/pull/434
2019-05-01 12:53:16 -07:00
Peter Steinfeld bbc092553c [flang] Tests for C1131, making sure that names of DO loops match between the loop header and the END DO statement.
Original-commit: flang-compiler/f18@f42ad1c2fd
Reviewed-on: https://github.com/flang-compiler/f18/pull/434
Tree-same-pre-rewrite: false
2019-05-01 12:53:15 -07:00
vdonaldson 408cfc1c4d [flang] reformat Fortran.h (flang-compiler/f18#435)
Original-commit: flang-compiler/f18@cdbb214339
Reviewed-on: https://github.com/flang-compiler/f18/pull/435
2019-04-30 20:22:02 -07:00
vdonaldson 2741d016c6 [flang] Clause 12 semantics -- Check all constraints not otherwise checked (flang-compiler/f18#427)
* Clause 12 semantics

Check all constraints not otherwise checked during parsing or label scope
validation, except for C1201, C1231, and C1233-5.  Obvious program
requirements are also checked, except for 12.6.2.2 constant format string
validation.

Original-commit: flang-compiler/f18@e4ec343618
Reviewed-on: https://github.com/flang-compiler/f18/pull/427
2019-04-30 11:28:16 -07:00
Tim Keith 13caf04846 [flang] Merge pull request flang-compiler/f18#433 from flang-compiler/tsk4
Fix source positions during parse tree rewriting

Original-commit: flang-compiler/f18@0bb7289ade
Reviewed-on: https://github.com/flang-compiler/f18/pull/433
2019-04-29 14:48:22 -07:00
Tim Keith 55cb1ac4db [flang] Fix source positions during parse tree rewriting
When a StmtFunctionStmt was rewritten as an array element assignment
the subscripts were not getting correct source locations. They need
to be copied from the function args.

Also, the entire array element expression (e.g. `a(i)`) did not have a
source position. This was tricky because there is no source position
in the original parse that matches what we need. So we take the source
position from the beginning of the function name to the end of the last
arg and extend it one more character to include the closing parenthesis.

Change `ActualArgToExpr()` to return `Expr` rather than
`std::optional<Expr>` because callers always call `.value()` on the
result anyway.

Add `WithSource()` utility to update the `source` data member of a
parse tree node.

This bug shows up as incorrect source positions for error messages. For
example, in this program the error (due to real subscript) did not have
a source position:
```
real :: a(10), x, y
a(x) = y
end
```

Original-commit: flang-compiler/f18@a9bcf68ceb
Reviewed-on: https://github.com/flang-compiler/f18/pull/433
2019-04-29 07:32:59 -07:00
Tim Keith e9b4cf42e4 [flang] Optionally dump all source members of parse tree
In the parse tree dumper, add a compile-time option to dump source
locations for all nodes that have them. This is a useful way to check
if they are correct, especially after parse tree rewrites.

It is enabled by defining `SHOW_ALL_SOURCE_MEMBERS` in `dump-parse-tree.h`.

Original-commit: flang-compiler/f18@ceae5632e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/433
Tree-same-pre-rewrite: false
2019-04-26 15:06:58 -07:00
Tim Keith 876bf77a3c [flang] Walk source member of Call and Designator
A `source` data member was added to `Call` and `Designator` so
the parse tree visitor needs to visit them.

Original-commit: flang-compiler/f18@0a620f1a5e
Reviewed-on: https://github.com/flang-compiler/f18/pull/433
Tree-same-pre-rewrite: false
2019-04-26 15:01:09 -07:00
Tim Keith e51108c138 [flang] Merge pull request flang-compiler/f18#429 from flang-compiler/tsk1
Continue semantic checking after name resolution error

Original-commit: flang-compiler/f18@f17c9caf8e
Reviewed-on: https://github.com/flang-compiler/f18/pull/429
2019-04-26 09:16:20 -07:00
Tim Keith 776145492f [flang] Move HasError, SetError to SemanticsContext
Move HasError and SetError into SemanticsContext so that we can do
consistency checks: if a symbol has an error or we want to set the
error flag, check that an error has been reported.

Original-commit: flang-compiler/f18@4f6e3a04ca
Reviewed-on: https://github.com/flang-compiler/f18/pull/429
2019-04-25 14:47:39 -07:00
Tim Keith 0df7fa0496 [flang] Continue semantic checking after name resolution error
When an error occurs in name resolution, continue semantic processing
in order to detect other errors. This means we can no longer assume
that every `parser::Name` has a symbol even after name resolution
completes. In `RewriteMutator`, only report internal error for unresolved
symbol if there have been no fatal errors.

Add `Error` flag to `Symbol` to indicate that an error occcurred related
to it. Once we report an error about a symbol we should avoid reporting
any more to prevent cascading errors. Add `HasError()` and `SetError()`
to simplify working with this flag.

Change some places that we assume that a `parser::Name` has a non-null
symbol. There are probably more.

`resolve-names.cc`: Set the `Error` flag when we report a fatal error
related to a symbol. (This requires making some symbols non-const.)
Remove `CheckScalarIntegerType()` as `ExprChecker` will take care of
those constraints if they are expressed in the parse tree. One exception
to that is the name in a `ConcurrentControl`. Explicitly perform that
check using `EvaluateExpr()` and constraint classes so we get consistent
error messages.

In expression analysis, when a constraint is violated (like `Scalar<>`
or `Integer<>`), reset the wrapped expression so that we don't assume it
is valid. A `GenericExprWrapper` holding a std::nullopt indicates error.
Change `EnforceTypeConstraint()` to return false when the constraint
fails to enable this.

check-do-concurrent.cc: Reorganize the Gather*VariableNames functions
into one to simplify the task of filtering out unresolved names. Remove
`CheckNoDuplicates()` and `CheckNoCollisions()` as those checks is
already done in name resolution when the names are added to the scope.

Original-commit: flang-compiler/f18@bcdb679405
Reviewed-on: https://github.com/flang-compiler/f18/pull/429
Tree-same-pre-rewrite: false
2019-04-25 13:18:33 -07:00
Tim Keith 8e2339dab9 [flang] Merge pull request flang-compiler/f18#430 from flang-compiler/tsk2
Bug fix: resolve ComponentArraySpec

Original-commit: flang-compiler/f18@612638e404
Reviewed-on: https://github.com/flang-compiler/f18/pull/430
2019-04-26 09:04:57 -07:00
Tim Keith 08321507e8 [flang] Fix test
Original-commit: flang-compiler/f18@dfd8cdfdec
Reviewed-on: https://github.com/flang-compiler/f18/pull/430
2019-04-26 08:51:17 -07:00