Commit graph

1134 commits

Author SHA1 Message Date
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
Eric Schweitz
777b89fdee [flang] revert last pushes
Original-commit: flang-compiler/f18@39335746a9
2019-04-24 11:41:40 -07:00
Eric Schweitz
1c15fa61a8 [flang] fix merge issues
Original-commit: flang-compiler/f18@20a6d8a159
2019-04-24 11:14:28 -07:00
Eric Schweitz
ff9123927c [flang] clang-format
Original-commit: flang-compiler/f18@faa7ccf905
2019-04-24 11:14:27 -07:00
Eric Schweitz
0b7fa133ae [flang] Some initial bridge code
add QualifiedStmt class

Original-commit: flang-compiler/f18@b2d89fe696
2019-04-24 11:14:25 -07:00
Eric Schweitz
bb832078a1 [flang] start splitting up afforestation so it isn't monolithic
Original-commit: flang-compiler/f18@ea42c9df5a
2019-04-24 11:14:20 -07:00
Eric Schweitz
ac525ded21 [flang] fix interface
Original-commit: flang-compiler/f18@668fd8338d
2019-04-24 11:14:17 -07:00
Jean Perier
aa6155adea [flang] fix comment layout
Original-commit: flang-compiler/f18@ad874f0152
2019-04-23 06:06:33 -07:00
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
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
peter klausler
337d8f8b5a [flang] Use parameter packs to simplify parser combinators. Work around g++ bug better.
Original-commit: flang-compiler/f18@eaa65cd60a
Reviewed-on: https://github.com/flang-compiler/f18/pull/423
2019-04-19 16:59:28 -07:00
Tim Keith
2dbd0dfb1c [flang] Change ExprRef to return reference
ExprRef never returns a null pointer so change it to return a reference.
Add overloading for parser::Variable as they now also hold a typedExpr.
Change some of the functions that the result of ExprRef is passed to so
that they take references instead of pointers.

Original-commit: flang-compiler/f18@2cdab6b166
Reviewed-on: https://github.com/flang-compiler/f18/pull/424
2019-04-21 20:46:15 -07:00
Tim Keith
510671c8c1 [flang] Distinguish between unanalyzed and error expressions
When an Expr or Variable is analyzed, always fill in a GenericExprWrapper
for it. That now holds the result of expression analysis which is
std::nullopt when there is an error.

After the ExprChecker pass has finished, the typedExpr data member of
Variables and top-level Exprs should be filled in. Assert that is the
case when we access them.

Original-commit: flang-compiler/f18@192a4e0855
Reviewed-on: https://github.com/flang-compiler/f18/pull/424
Tree-same-pre-rewrite: false
2019-04-19 17:14:50 -07:00
peter klausler
6d93fd2e54 [flang] Fix flang-compiler/f18#425, build fail with libc++
Original-commit: flang-compiler/f18@96a553b189
Reviewed-on: https://github.com/flang-compiler/f18/pull/426
2019-04-22 10:10:27 -07:00
peter klausler
68d89b6383 [flang] Add some utility functions to semantics/tools
Original-commit: flang-compiler/f18@59006b3a5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/421
2019-04-22 09:25:24 -07:00
Tim Keith
b12a146b1b [flang] Share code for analyzing Expr and Variable
Move check for empty CharBlock from here to SetLocation.
(Can an Expr ever have an empty source location?)

Original-commit: flang-compiler/f18@7fd422f025
Reviewed-on: https://github.com/flang-compiler/f18/pull/422
2019-04-19 12:55:36 -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
2107b223cb [flang] Use SomeExpr rather than GenericExprWrapper in checkers
Use GetExpr in checker classes to get analyzed expressions out of parse
tree nodes. Don't assume that they are always present. Change the
utility functions in tools.h to use SomeExpr rather than
GenericExprWrapper.

Original-commit: flang-compiler/f18@594e30d462
Reviewed-on: https://github.com/flang-compiler/f18/pull/422
Tree-same-pre-rewrite: false
2019-04-19 08:22:28 -07:00
Tim Keith
a426477d37 [flang] Remove redundant checks enforced in the grammar
Expression analysis enforces constraints implied by the grammar,
for example scalar-expr, scalar-int-expr, etc. These no longer need
to be checked during statement semantics.

Original-commit: flang-compiler/f18@35330b9a85
Reviewed-on: https://github.com/flang-compiler/f18/pull/422
Tree-same-pre-rewrite: false
2019-04-19 07:11:19 -07:00
Tim Keith
54c42cfa89 [flang] Preserve source location when rewriting parse tree
When a Designator is created from a FunctionReference or
StmtFunctionStmt, copy the source data member too.

Original-commit: flang-compiler/f18@bf91c0630f
Reviewed-on: https://github.com/flang-compiler/f18/pull/422
Tree-same-pre-rewrite: false
2019-04-19 06:39:50 -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
peter klausler
f832a4d3ee [flang] Return a missing result
Original-commit: flang-compiler/f18@04f9fd39b9
Reviewed-on: https://github.com/flang-compiler/f18/pull/419
2019-04-18 14:27:59 -07:00
peter klausler
e58aa3837f [flang] Use Attr_enumSize rather than an arbitrary 32.
Original-commit: flang-compiler/f18@b6de9c6e47
Reviewed-on: https://github.com/flang-compiler/f18/pull/419
Tree-same-pre-rewrite: false
2019-04-18 14:25:22 -07:00
peter klausler
1cc33da57e [flang] More work on classes to represent characteristics of procedures.
Original-commit: flang-compiler/f18@abd3922a88
Reviewed-on: https://github.com/flang-compiler/f18/pull/419
Tree-same-pre-rewrite: false
2019-04-18 13:25:20 -07:00
Paul Osmialowski
994e90ce1e [flang] Semantics checker for STOP and ERROR STOP statements - trust in implied check
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@7a98732f72
Reviewed-on: https://github.com/flang-compiler/f18/pull/367
2019-04-17 14:13:23 -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
a8dabf752d [flang] Semantics checker for STOP and ERROR STOP statements - remove one more function from tools
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@9937b524fa
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
94a3462018 [flang] Semantics checker for STOP and ERROR STOP statements - fix compilation broken by merge commit
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@1d36ab1f43
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
9579f55836 [flang] Semantics checker for STOP and ERROR STOP statements - remove tools function not needed after recent commit
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@1a3dbd9752
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
ade79f6573 [flang] Semantics checker for STOP and ERROR STOP statements - better variable names
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@8b32caa287
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
ec322c9588 [flang] Semantics checker for STOP and ERROR STOP statements - ExprTypeKindIsDefault added to the tools
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@669b05b27d
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
c145b58d0f [flang] Semantics checker for STOP and ERROR STOP statements - namespaces sorted
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@d608779668
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
8d1376ca73 [flang] Semantics checker for STOP and ERROR STOP statements - post review changes
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>

Original-commit: flang-compiler/f18@08b564832c
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
peter klausler
a8bf4d488f [flang] More clean-up
Original-commit: flang-compiler/f18@ba2365f5f7
Reviewed-on: https://github.com/flang-compiler/f18/pull/416
2019-04-16 16:14:14 -07:00
peter klausler
f79e3dd0b9 [flang] Generalize tools, clean up common/unwrap.h with new-found knowledge
Original-commit: flang-compiler/f18@aac16907cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/416
Tree-same-pre-rewrite: false
2019-04-16 15:59:04 -07:00
peter klausler
bfb65b5476 [flang] Address review comments
Original-commit: flang-compiler/f18@7bc3c97f1e
Reviewed-on: https://github.com/flang-compiler/f18/pull/416
Tree-same-pre-rewrite: false
2019-04-16 12:29:00 -07:00
peter klausler
1498911aa2 [flang] Rewrite I/O units in the parse tree when a variable is not character.
Original-commit: flang-compiler/f18@46791a73e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/416
Tree-same-pre-rewrite: false
2019-04-16 12:28:59 -07:00
peter klausler
1b8a78ac13 [flang] Resolve ambiguous I/O unit parse in favor of CharVariable.
Original-commit: flang-compiler/f18@ecabe82825
Reviewed-on: https://github.com/flang-compiler/f18/pull/416
Tree-same-pre-rewrite: false
2019-04-16 12:28:59 -07:00
Jean Perier
d8182b9089 [flang] Remove user warning messages for lack of subnormal HW flushing
Original-commit: flang-compiler/f18@4aecc1bcee
2019-04-15 01:54:35 -07:00
Jean Perier
db57831869 [flang] also fix accessor name
Original-commit: flang-compiler/f18@6ff8d22a57
Tree-same-pre-rewrite: false
2019-04-15 01:18:41 -07:00
Jean Perier
2aad0564cb [flang] address comment. Follow style guideline
Original-commit: flang-compiler/f18@60da44dc7d
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
peter klausler
b147f32dcc [flang] Fix bug found in testing
Original-commit: flang-compiler/f18@45a1e6e3dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/415
2019-04-15 15:53:18 -07:00
peter klausler
ce9716d037 [flang] Capture source locations for Designators and Calls
Original-commit: flang-compiler/f18@970333fff7
Reviewed-on: https://github.com/flang-compiler/f18/pull/415
Tree-same-pre-rewrite: false
2019-04-15 15:18:07 -07:00
Tim Keith
c51c9399f9 [flang] Address review comments
Original-commit: flang-compiler/f18@577629f489
Reviewed-on: https://github.com/flang-compiler/f18/pull/414
2019-04-15 14:07:11 -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