Commit graph

1717 commits

Author SHA1 Message Date
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
jeanPerier
9425afd6b5 [flang] First batch of semantic checks for allocate
Merge pull request flang-compiler/f18#418 from flang-compiler/jpr-check-allocate

Original-commit: flang-compiler/f18@ab7d7c5dc0
2019-04-24 00:53:49 -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
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
Peter Klausler
2cc4cba96e [flang] Merge pull request flang-compiler/f18#423 from flang-compiler/pmk-packs
Use parameter packs to simplify parser combinators.  Work around g++ …

Original-commit: flang-compiler/f18@9e178f2525
Reviewed-on: https://github.com/flang-compiler/f18/pull/423
2019-04-22 13:58:22 -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
e020976483 [flang] Merge pull request flang-compiler/f18#424 from flang-compiler/tsk-expr
Distinguish between unanalyzed and error expressions

Original-commit: flang-compiler/f18@0978d17010
Reviewed-on: https://github.com/flang-compiler/f18/pull/424
2019-04-22 12:58:20 -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
ba60bd6c1c [flang] Merge pull request flang-compiler/f18#426 from flang-compiler/pmk-425
Fix flang-compiler/f18#425, build fail with libc++

Original-commit: flang-compiler/f18@b21b3da808
Reviewed-on: https://github.com/flang-compiler/f18/pull/426
2019-04-22 10:37:07 -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
ffb2704be1 [flang] Merge pull request flang-compiler/f18#421 from flang-compiler/pmk3
Add some utility functions to semantics/tools

Original-commit: flang-compiler/f18@80ef214fb8
Reviewed-on: https://github.com/flang-compiler/f18/pull/421
2019-04-22 10:08:20 -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
d129f93148 [flang] Merge pull request flang-compiler/f18#422 from flang-compiler/tsk-expr
Continue semantics checks after expression errors

Original-commit: flang-compiler/f18@55cf9ee7aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/422
2019-04-19 14:33:04 -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
f4f02c2725 [flang] Merge pull request flang-compiler/f18#420 from flang-compiler/pmk2
Flatten and fold array operations

Original-commit: flang-compiler/f18@8693c80f33
Reviewed-on: https://github.com/flang-compiler/f18/pull/420
2019-04-18 15:09:25 -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
567480a4d7 [flang] Merge pull request flang-compiler/f18#419 from flang-compiler/pmk1
More work on classes to represent characteristics of procedures.

Original-commit: flang-compiler/f18@4db875f1db
Reviewed-on: https://github.com/flang-compiler/f18/pull/419
2019-04-18 14:32:22 -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
Steve Scalpone
73ff09bf02 [flang] Merge pull request flang-compiler/f18#367 from pawosm-arm/error-stop
Semantics checker for STOP and ERROR STOP statements.

Original-commit: flang-compiler/f18@e7aedb84ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/367
2019-04-17 14:13:23 -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
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
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
0e28b6789e [flang] Merge pull request flang-compiler/f18#417 from flang-compiler/tsk6
Fix bug resolving internal and module functions

Original-commit: flang-compiler/f18@ca5d610282
Reviewed-on: https://github.com/flang-compiler/f18/pull/417
2019-04-17 10:31:49 -07:00
Tim Keith
79826a73b2 [flang] Dump parse tree even if semantic error occurs
When -fdebug-dump-parse-tree is specified, dump the parse tree even
if semantic errors have occurred. This is necessary to see the parse
tree after it has been transformed.

Original-commit: flang-compiler/f18@bbdb0717da
Reviewed-on: https://github.com/flang-compiler/f18/pull/417
2019-04-17 07:44:58 -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
e99ba0bc7d [flang] Merge pull request flang-compiler/f18#416 from flang-compiler/pmk-val-fix
Resolve ambiguous I/O unit parse in favor of CharVariable.

Original-commit: flang-compiler/f18@cd7e907333
Reviewed-on: https://github.com/flang-compiler/f18/pull/416
2019-04-17 08:42:57 -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