Commit graph

603 commits

Author SHA1 Message Date
peter klausler
754c88f35f [flang] Remove temporary debugging code
Original-commit: flang-compiler/f18@e7147ebfbe
Reviewed-on: https://github.com/flang-compiler/f18/pull/490
2019-06-10 09:26:02 -07:00
peter klausler
fc61632c21 [flang] Fix characterization of functions called in association selectors
Original-commit: flang-compiler/f18@cada0c61e3
Reviewed-on: https://github.com/flang-compiler/f18/pull/488
Tree-same-pre-rewrite: false
2019-06-07 10:24:35 -07:00
peter klausler
b408a02c14 [flang] Avoid segfault in association semantics by cleaning up code a bit
Original-commit: flang-compiler/f18@04d40c3d75
Reviewed-on: https://github.com/flang-compiler/f18/pull/488
Tree-same-pre-rewrite: false
2019-06-07 10:24:33 -07:00
Tim Keith
e69c6a6259 [flang] Fix issue flang-compiler/f18#486
In a function without a function result specified, the name in the
`FunctionStmt` was resolved to the function result symbol rather than
the function symbol itself. That is inconsistent with subroutines and
other functions.

The fix is to explicitly set the function name symbol after the result
has been resolved.

Original-commit: flang-compiler/f18@b0172d3284
Reviewed-on: https://github.com/flang-compiler/f18/pull/487
2019-06-06 16:09:11 -07:00
peter klausler
4d7da503fc [flang] Apply suggestion from code review
Original-commit: flang-compiler/f18@211c99917c
Reviewed-on: https://github.com/flang-compiler/f18/pull/480
2019-06-05 09:12:21 -07:00
peter klausler
dd50c1bca7 [flang] Fix two bugs
Original-commit: flang-compiler/f18@919e512c08
Reviewed-on: https://github.com/flang-compiler/f18/pull/480
Tree-same-pre-rewrite: false
2019-06-04 17:03:34 -07:00
peter klausler
2e44404e94 [flang] Fix build warning, add comment about extension not supported
Original-commit: flang-compiler/f18@1033ae05ca
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
2019-06-04 14:51:56 -07:00
peter klausler
cab9b3072b [flang] Skim executable parts to detect dummy procedure calls
Original-commit: flang-compiler/f18@b085255e5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
2019-06-04 13:37:35 -07:00
peter klausler
0d242e2006 [flang] INTRINSIC attribute should convert symbol to procedure; also check C840
Original-commit: flang-compiler/f18@b698b84ccd
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
2019-06-04 13:37:26 -07:00
peter klausler
b50170c99d [flang] allow alternate return indicators
Original-commit: flang-compiler/f18@a04150a4f9
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
2019-06-04 13:37:20 -07:00
peter klausler
89a0181da6 [flang] Allow for FINAL procedures in PDT instantiation
Original-commit: flang-compiler/f18@e276374b29
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
2019-06-04 13:37:17 -07:00
peter klausler
3e313d43e1 [flang] Fix correction of misparsed struct const as actual arg, and semantics of MODULE PROCEDURE in INTERFACE
Original-commit: flang-compiler/f18@6c86de6cef
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
2019-06-04 13:37:16 -07:00
peter klausler
d72fd348f7 [flang] Allow some BOZ usage when unambiguous (extension)
Original-commit: flang-compiler/f18@bf3bd54c88
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
2019-06-04 13:37:12 -07:00
peter klausler
0ddea8ae24 [flang] Rearrange references to AllSources singleton, fix FindScope for module files
Original-commit: flang-compiler/f18@50ccc1c819
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
2019-06-04 13:37:09 -07:00
peter klausler
710a5147cd [flang] Reformatting before merging
Original-commit: flang-compiler/f18@9f084c1da6
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
2019-05-30 16:39:23 -07:00
peter klausler
c3ce68c1ee [flang] Two more fixes made while waiting for code review
Original-commit: flang-compiler/f18@6dc58004ab
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-30 16:14:24 -07:00
peter klausler
d3b23e9dd6 [flang] Handle large integer literals without kinds better
Original-commit: flang-compiler/f18@381ea32d57
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-30 13:31:11 -07:00
peter klausler
d49aa3c57c [flang] Final fixes before review
Original-commit: flang-compiler/f18@efe5c1b8ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-29 16:00:31 -07:00
peter klausler
eff41b8fa7 [flang] Complete folding of intermixed array and component references
Original-commit: flang-compiler/f18@70db03e4ac
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-29 13:22:35 -07:00
peter klausler
d29530e1c4 [flang] Defer conversions to objects; fix some intrinsic table entries
more fixes

Access components of constant structures

Apply implicit typing to dummy args used in automatic array dimensions

SELECTED_INT_KIND and SELECTED_REAL_KIND

Finish SELECTED_{INT,REAL}_KIND and common cases of ALL()/ANY()

Original-commit: flang-compiler/f18@e9f8e53e55
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-28 13:29:29 -07:00
Jean Perier
33d6fb2332 [flang] Make integer divide by zero in constants a fatal error
Original-commit: flang-compiler/f18@e5acff6b63
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
2019-05-24 07:55:57 -07:00
Jean Perier
f62528535e [flang] Folding improvments:
- Add location to non-fatal error message (context was not given
    a location before folding in semantics).
  - Avoid refolding expression from scratch several times (update GenericExprWrapper
    after folding). So far, warning messages were generated twice per parametere init
    expressions.

Original-commit: flang-compiler/f18@bf7f6cf9cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
2019-05-24 07:55:40 -07:00
Jean Perier
d146db54ca [flang] Fix: catch subroutine symbols in ALLOCATE
Original-commit: flang-compiler/f18@99d4b3dcd6
Reviewed-on: https://github.com/flang-compiler/f18/pull/467
2019-05-22 08:00:19 -07:00
peter klausler
7026445c07 [flang] Address review comments from Jean (thanks!)
Original-commit: flang-compiler/f18@5183c6196e
Reviewed-on: https://github.com/flang-compiler/f18/pull/466
2019-05-21 10:24:30 -07:00
peter klausler
59342b0641 [flang] work in progress
checkpoint: changes build, tests all pass

many fixes, ready to test more

Further CLASS(*) support

More fixes for CLASS(*)

Hide data members of DynamicType

implement PRESENT() intrinsic

Original-commit: flang-compiler/f18@044ba12c20
Reviewed-on: https://github.com/flang-compiler/f18/pull/466
Tree-same-pre-rewrite: false
2019-05-20 13:37:28 -07:00
Tim Keith
351dc98948 [flang] Change parse tree to allow DO loop over REAL
It is a common extension to allow DO loops with REAL variable and
bounds. The parse tree currently parses those with the variable
as `scalar-int-variable-name` and the bounds as `scalar-int-expr`.
That causes the INTEGER constraint to be enforced automatically.

Change the grammar and parse tree to treat them as `scalar-variable-name`
and `scalar-expr`. This allows the name and expression to be REAL,
but we will have to verify that they aren't any other type (in a future
change).

To accomplish this, add a template parameter to `LoopBounds` for the type
of the variable name (always `Scalar<Name>` or `Scalar<Integer<Name>>`).
We sometimes need names for the instantiations of `LoopBounds` so add
type aliases like `LoopControl::Bounds` for each one.

Original-commit: flang-compiler/f18@d75aa03970
Reviewed-on: https://github.com/flang-compiler/f18/pull/455
Tree-same-pre-rewrite: false
2019-05-09 08:33:28 -07:00
Peter Steinfeld
3cf2173010 [flang] Added a TODO to include the name of the IMPURE procedure in the error
message for referencing in IMPURE procedure in the scalar-mask-expr of
a DO CONCURRENT.

Also removed a bogus comment from the test.

Both of these changes were in response to review comments.

Original-commit: flang-compiler/f18@4447d59b39
Reviewed-on: https://github.com/flang-compiler/f18/pull/452
2019-05-09 10:58:55 -07:00
Peter Steinfeld
c2346d9ee2 [flang] Added a test for C1121 -- in a concurrent DO loop, the
scalar-mask-expr cannot reference an IMPURE procedure.

Original-commit: flang-compiler/f18@0684c6ccc2
Reviewed-on: https://github.com/flang-compiler/f18/pull/452
Tree-same-pre-rewrite: false
2019-05-09 10:58:54 -07:00
peter klausler
b00798b64f [flang] Fix warning
Original-commit: flang-compiler/f18@4fcf88901c
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:29:02 -07:00
peter klausler
d92abfa65e [flang] Address review comment
Original-commit: flang-compiler/f18@5d20cd48b6
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:29:02 -07:00
peter klausler
04d85f1754 [flang] Remove debugging
Original-commit: flang-compiler/f18@1db626f838
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:28:58 -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
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
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
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
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
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
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
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
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
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
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
048d56cf5f [flang] Bug fix: resolve ComponentArraySpec
This used to work but broke due to coarray spec changes.
The fix is to extend AnalyzeArraySpec to work on ComponentArraySpec
and to call it when we encounter one.

modfile24.f90 tested this case but had the wrong expected results.

Thanks to Jean for finding this.

Original-commit: flang-compiler/f18@7ef4c28a61
Reviewed-on: https://github.com/flang-compiler/f18/pull/430
Tree-same-pre-rewrite: false
2019-04-25 15:05:41 -07:00
Jean Perier
aa6155adea [flang] fix comment layout
Original-commit: flang-compiler/f18@ad874f0152
2019-04-23 06:06:33 -07:00