Commit graph

716 commits

Author SHA1 Message Date
peter klausler
6911444f76 [flang] Fixes
Original-commit: flang-compiler/f18@73edc5bf2b
Reviewed-on: https://github.com/flang-compiler/f18/pull/496
Tree-same-pre-rewrite: false
2019-06-17 16:13:08 -07:00
peter klausler
15af2b2f06 [flang] Character set and encoding changes
Original-commit: flang-compiler/f18@a550cbd4c0
Reviewed-on: https://github.com/flang-compiler/f18/pull/496
Tree-same-pre-rewrite: false
2019-06-17 16:13:07 -07:00
peter klausler
e7a21f763a [flang] Tests pass
Original-commit: flang-compiler/f18@ae9d07a2ab
Reviewed-on: https://github.com/flang-compiler/f18/pull/496
Tree-same-pre-rewrite: false
2019-06-17 16:13:07 -07:00
Tim Keith
7d464b02c6 [flang] Handle nested interface blocks
Interface blocks can be nested if one of the interface bodies
declares a subprogram with a dummy procedure that is specified
by an interface block. See the addition to `modfile07.f90` for
and example.

This didn't work because there was only one copy of each of
`inInterfaceBlock_`, `isAbstract_`, and `genericSymbol_`.
We need these for each active interface block, so replace these
with a stack. A new entry is pushed on the stack when we enter
an `InterfaceStmt` or `GenericStmt` and popped when we leave.

Also in the same example, when declaring the dummy procedure, the
dummy argument is initially an `EntityDetails` but it is replaced
by a `SubprogramDetails` when it is specified by the interface.

Original-commit: flang-compiler/f18@0c468b60b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/502
2019-06-14 15:04:13 -07:00
Tim Keith
9d125624f6 [flang] Handle substring of array element in EQUIVALENCE
A substring of an array element is legal as an equivalence object,
e.g. `a(2,3)[4:5]`. Extend `EquivalenceObject` to include the start
of the substring, if any. Split `CheckBound` into `CheckArrayBound`
and `CheckSubstringBound`.

When evaluating bounds in `AddToSet` we can assert they are constant
because all of the error cases should have been detected already.

Original-commit: flang-compiler/f18@0b4050b2d5
Reviewed-on: https://github.com/flang-compiler/f18/pull/494
2019-06-12 12:38:04 -07:00
Tim Keith
9ef62dbb6a [flang] Resolve and check names in equivalence sets
Collect sets of `parser::EquivalenceObject` to process at the end of
the specification part. This is so that names mentioned in the
EQUIVALENCE statement don't trigger implicit declarations.

The `EquivalenceSets` class performs most of the numerous checks
on objects that can be in equivalence sets at all and objects that
can be in them together. It also merges sets when the same object
appears in more than one.

Once equivalence sets are checked they are added to the `Scope`.
Further checks will be necessary after the size and alignment of
variables are computed.

Add `FindUltimateComponent` to simplify checks on ultimate components
of derived types. Use it to implement `HasCoarrayUltimateComponent`
and checks on equivalence objects.

Make `ExpressionAnalyzer::Analyze(Designator)` public so that
`parser::EquivalenceObject` can be analyzed.

Add `GetDefaultKind`, `doublePrecisionKind`, and `quadPrecisionKind`
to `SemanticsContext` so that `defaultKinds_` does not need to be
accessed directly.

Original-commit: flang-compiler/f18@1cc898e5b8
Reviewed-on: https://github.com/flang-compiler/f18/pull/494
Tree-same-pre-rewrite: false
2019-06-11 18:26:48 -07:00
Peter Steinfeld
609e2d753b [flang] Fixed situations where multiple error messages were being emitted.
Original-commit: flang-compiler/f18@ac62cfa9cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
2019-06-10 15:10:32 -07:00
Peter Steinfeld
c97f17a59f [flang] Renamed check.*do.*stmt to check.*do to better conform with the grammar.
Original-commit: flang-compiler/f18@d7419566e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
2019-06-10 14:03:24 -07:00
Peter Steinfeld
169b8272e8 [flang] These are additional changes for issue 458, to perform semantic checks on DO
variable and initial, final, and step expressions.

Here's a summary of the changes since my original pull request:

 - I've taken into account the possibility that the DO variable is declared in
   a MODULE.  This required a call to GetUltimate() on the Symbol for the DO
   variable.
 - The previous change exposed problems in the semantic checking for NULLIFY
   and DEALLOCATE statements, so I've included fixes and tests for those.  I
   also added a test for the ALLOCATE statement, even though it was already
   handling this case.
 - I now handle the case where a procedure name is erroneously used as a DO variable.
 - I now handle the case where a pointer to a procedure is erroneously used as
   a DO variable.
 - I now check that the DO expressions are not null.
 - I added tests for all cases listed above.

Original-commit: flang-compiler/f18@219d856fdb
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
2019-06-10 13:31:31 -07:00
Peter Steinfeld
3ab209b58e [flang] Changes in response to Peter's comments on a previous pull request.
Specifically, that the conversion of warnings to errors will happen in a
single place in the compiler once we implement warnings as distinct from
errors.  This change made on of the tests invalid.

Also, there's no need to check whether the extension to allow
REAL DO controls is enabled.

Original-commit: flang-compiler/f18@2fae9edd77
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
2019-06-10 13:31:31 -07:00
Peter Steinfeld
0bef67225a [flang] Added the machinery for REAL DO controls to be treated as a separate
extension.

Original-commit: flang-compiler/f18@1907cf8672
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
2019-06-10 13:31:31 -07:00
Peter Steinfeld
a698d3d579 [flang] Changes responding to comments on my previous pull request. Specifically --
parse-tree.cc
 - Cleaned up the use of "const" in several declarations.
check-do-stmt.cc
 - Replaced uses of parser::Messages with SemanticsContext.
 - Removed unused "==" operator from the DoStmtContext class.
 - Reduced the size of the GetBounds function by calling GetLoopControl().
 - Changed the warning message for REAL DO controls to not mention standard
   extensions.
check-do-stmt.h
 - Restored the forward reference to Fortran::parser::DoConstruct and removed
   the include of parse-tree.h
dosemantics*.f90
 - Removed extraneous references to the "RUN" command.
test_errors.sh
 - Simplified and generalized the extraction of the OPTIONS specification.

Original-commit: flang-compiler/f18@04a0712766
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
2019-06-10 13:31:31 -07:00
Peter Steinfeld
93a59505a5 [flang] These changes are for issue 458, to perform semantic checks on DO variable
and initial, final, and step expressions.  As a new extension, we want to allow
REAL and DOUBLE PRECISION values for them by default.

Here's a summary of the changes:
 - There already existed infrastructure for semantic checking of DO loops that
   was partially specific to DO CONCURRENT loops.  Because I re-used some of
   this infrastructure, I renamed some files and classes from "concurrent" to
   "stmt".
 - I added some functions to distinguish among the different kinds of DO
   statements.
 - I added the functions to check-do-stmt.cc to produce the necessary warnins
   and errors.  Note that there are no tests for the warnings since the
   necessary testing infrastructure does not yet exist.
 - I changed test-errors.sh so that additional compilation options can be
   specified in the test source.
 - I added two new tests to test for the various kinds of values that can be
   used for the DO variables and control expressions.  The two tests are
   identical except for the use of different compilation options.
   dosemantics03.f90 specifies the options "-Mstandard -Werror" to produce
   error messages for the use of REAL and DOUBLE PRECISION DO variables and
   controls.  dosemantics04.f90 uses the default options and only produces
   error messages for contructs that are erroneous by default.

Original-commit: flang-compiler/f18@f484660c75
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
2019-06-10 13:31:31 -07:00
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
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
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
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
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
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
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
Steve Scalpone
3568e45856 [flang] FindContainingSubprogram returns a pointer, not a reference.
Original-commit: flang-compiler/f18@7d221b09bd
2019-04-15 10:59:12 -07:00
Steve Scalpone
05f0145be5 [flang] Avoid copying scope. Improve readability.
Original-commit: flang-compiler/f18@5d2213cd7a
Tree-same-pre-rewrite: false
2019-04-15 10:59:12 -07:00
Steve Scalpone
e2d6bbc016 [flang] Scope is only ever set to the address of a Scope,
so it can never be null. The condition should be
scope->kind() != Scope::Kind::Global.
And clang-format.

Original-commit: flang-compiler/f18@b686ab548a
Tree-same-pre-rewrite: false
2019-04-15 10:59:12 -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
73bcc7a7cd [flang] Delete the default copy constructor for Scope.
Original-commit: flang-compiler/f18@e8e3e5fd46
Reviewed-on: https://github.com/flang-compiler/f18/pull/413
2019-04-15 10:30:40 -07:00
peter klausler
907bb361c5 [flang] Fix clang warning that crept into codebase over weekend
Original-commit: flang-compiler/f18@8c8ad4c0d8
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
2019-04-15 10:09:22 -07:00
peter klausler
32424cad2d [flang] reformatting
Original-commit: flang-compiler/f18@d9bfa6f48e
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:44:54 -07:00
peter klausler
ba2ef03a02 [flang] pass all tests
Original-commit: flang-compiler/f18@3cee1993a1
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:41:50 -07:00
peter klausler
a90455057c [flang] Ensure no failed expression analyses without fatal errors.
Original-commit: flang-compiler/f18@3ef8b43031
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
2019-04-15 09:41:49 -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
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
Tim Keith
b69c2c6997 [flang] Remove ObjectName alternative from Designator
A simple name in a `Designator` is always parsed as a `DataRef`, not
an `ObjectName`. So remove that alternative.

`StmtFunctionStmt::ConvertToAssignment` was creating a `Designator` with
that alternative: change it to do the same thing as the parser.

Add `GetSimpleName` utility functions to check if an `Expr` or `Variable`
represents a simple name. Many of the places that checked for `ObjectName`
in `Designator` are trying to do that.

Clean up includes and forward declarations in `tools.h`.

Original-commit: flang-compiler/f18@97d44de7b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/410
2019-04-12 16:30:03 -07:00
Steve Scalpone
a0e06bb5d4 [flang] Cleanup -- Remove unnecessary inline keyword,
remove unnecessary (void) casts when ignoring
return values, call context_.Say() directly
instead of via messages(), and fix up some
formatting issues using clang-format.

Original-commit: flang-compiler/f18@68e5c02541
Reviewed-on: https://github.com/flang-compiler/f18/pull/404
2019-04-11 15:20:14 -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
Peter Steinfeld
563d7a6c4c [flang] My last change neglected to include the change to the message.
Original-commit: flang-compiler/f18@09444379f7
Reviewed-on: https://github.com/flang-compiler/f18/pull/400
Tree-same-pre-rewrite: false
2019-04-11 15:35:44 -07:00
Peter Steinfeld
22b489508c [flang] Removed unused parameter and tweaked the error message one more time.
Original-commit: flang-compiler/f18@476791da2a
Reviewed-on: https://github.com/flang-compiler/f18/pull/400
Tree-same-pre-rewrite: false
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
ee79690a0f [flang] Correct constraint numbers. Fix spelling error. Run clang-format.
Original-commit: flang-compiler/f18@59df0d39f3
Reviewed-on: https://github.com/flang-compiler/f18/pull/401
Tree-same-pre-rewrite: false
2019-04-11 04:16:14 -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
95d8de80fe [flang] Changed the DO loop termination message to be different for the error
case.

Original-commit: flang-compiler/f18@51cf517cca
Reviewed-on: https://github.com/flang-compiler/f18/pull/398
2019-04-10 13:06:48 -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
peter klausler
923c891111 [flang] Do not replace format with namelist if there is no unit (avoiding accidental language extension)
Original-commit: flang-compiler/f18@08562d9b86
Reviewed-on: https://github.com/flang-compiler/f18/pull/394
2019-04-10 08:52:46 -07:00
peter klausler
0e55f2463b [flang] Rewrite read-stmt/write-stmt parse trees for misparsed namelist group names
Original-commit: flang-compiler/f18@e0f1b1c469
Reviewed-on: https://github.com/flang-compiler/f18/pull/394
Tree-same-pre-rewrite: false
2019-04-10 08:52:42 -07:00
peter klausler
4950dfa04e [flang] Redo without macros
Original-commit: flang-compiler/f18@8d955cfb3b
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
2019-04-09 13:29:40 -07:00
peter klausler
8057a2ce32 [flang] Lots of debugging and refinement
Original-commit: flang-compiler/f18@1c3c30b540
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
2019-04-08 16:16:55 -07:00
peter klausler
17c4ae070b [flang] Revert that reversion. Move semantics work just fine.
Original-commit: flang-compiler/f18@72bd8e7b03
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
2019-04-08 14:29:47 -07:00
peter klausler
d0e7775431 [flang] Revert to forwarding on variadic messaging APIs
Original-commit: flang-compiler/f18@d2e464eb15
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
2019-04-08 14:29:47 -07:00
peter klausler
dc9c3d1c46 [flang] Fix bug#389, prevent std::move() on forwarded lvalue references
Original-commit: flang-compiler/f18@9d61c091ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
2019-04-08 14:29:45 -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
28184c4a49 [flang] Simplify expression visitor usage
Original-commit: flang-compiler/f18@9ab121d6a6
Reviewed-on: https://github.com/flang-compiler/f18/pull/386
Tree-same-pre-rewrite: false
2019-04-05 12:56:09 -07:00
Tim Keith
bc140ed13c [flang] Address review comments.
Change AnalyzeArraySpec and AnalyzeCoarraySpec to return resulting
ArraySpec by value.

Original-commit: flang-compiler/f18@0ae38143e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/384
2019-04-04 16:32:37 -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
Steve Scalpone
c95b56d5a0 [flang] Remove unused variable in check-if-stmt.cc
Original-commit: flang-compiler/f18@520751311d
Reviewed-on: https://github.com/flang-compiler/f18/pull/375
2019-04-01 21:28:16 -07:00
peter klausler
4eade259b3 [flang] Address comments, clean up warnings
Original-commit: flang-compiler/f18@a5eeeb4430
Reviewed-on: https://github.com/flang-compiler/f18/pull/378
2019-04-02 11:56:19 -07:00
peter klausler
5dae2fb1a9 [flang] Clean up and prep for review
Original-commit: flang-compiler/f18@3f96c673e0
Reviewed-on: https://github.com/flang-compiler/f18/pull/378
Tree-same-pre-rewrite: false
2019-04-02 10:59:11 -07:00
peter klausler
ec2448123e [flang] Fix bug flang-compiler/f18#376, internal error when correcting misparse of structure constructor
Original-commit: flang-compiler/f18@f18a94ef96
Reviewed-on: https://github.com/flang-compiler/f18/pull/378
Tree-same-pre-rewrite: false
2019-04-02 10:59:09 -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
b4dc611eb4 [flang] Resolve LHS in pointer assignment
Original-commit: flang-compiler/f18@9a3525275c
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false
2019-03-29 09:08:49 -07:00
Tim Keith
e1ea983b0a [flang] Dump function return attributes
Also, change SubprogramDetails::result_ from `std::optional<Symbol *>`
to `Symbol *`. We don't need two levels of optional-ness.

Original-commit: flang-compiler/f18@db3b874946
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false
2019-03-29 09:08:18 -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
peter klausler
3c5a25a1bd [flang] Use source location in IF statement checks.
Original-commit: flang-compiler/f18@9e08746e2b
Reviewed-on: https://github.com/flang-compiler/f18/pull/373
Tree-same-pre-rewrite: false
2019-04-01 16:23:34 -07:00
peter klausler
1fb4869367 [flang] Fix typo
Original-commit: flang-compiler/f18@c5b05009df
Reviewed-on: https://github.com/flang-compiler/f18/pull/373
Tree-same-pre-rewrite: false
2019-04-01 16:23:33 -07:00
peter klausler
6fa22f95e0 [flang] Fix typo
Original-commit: flang-compiler/f18@6be309300e
Reviewed-on: https://github.com/flang-compiler/f18/pull/373
Tree-same-pre-rewrite: false
2019-04-01 16:23:33 -07:00
peter klausler
0ff94b9d0b [flang] Define and use UnlabeledStatement<> for if & forall
Original-commit: flang-compiler/f18@028e6aba6c
Reviewed-on: https://github.com/flang-compiler/f18/pull/373
Tree-same-pre-rewrite: false
2019-04-01 16:23:32 -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
f719b4ae6e [flang] Revert to AsFortran in module file output.
Original-commit: flang-compiler/f18@3dc7f685d1
Reviewed-on: https://github.com/flang-compiler/f18/pull/371
2019-04-01 15:02:23 -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
95b4e65ecf [flang] Move some AsFortran() implementations into new formatting.cc; use precedence for parentheses
Original-commit: flang-compiler/f18@2b5fa051df
Reviewed-on: https://github.com/flang-compiler/f18/pull/371
Tree-same-pre-rewrite: false
2019-04-01 10:58:55 -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
Steve Scalpone
1de9ecd251 [flang] Add CMake rules to install static and shared libraries in
the default install directory or in the directory specified
with CMAKE_INSTALL_PREFIX.  Fixes flang-compiler/f18#359.

Original-commit: flang-compiler/f18@35ce1628e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/364
2019-03-28 09:55:56 -07:00
Tim Keith
3e8c62b48b [flang] Track current statement location in SemanticsVisitor
Change `SemanticsVisitor` to track the location of the current
statement, if any, so that it's available through
`SemanticsContext::location()`

Add overloading of `SemanticsContext::Say()` that reports the
message at the location of the current statement if a `CharBlock`
is not provided.

Original-commit: flang-compiler/f18@5185c721ee
Reviewed-on: https://github.com/flang-compiler/f18/pull/357
2019-03-26 12:40:13 -07:00
Steve Scalpone
b8ce6f11ad [flang] Removed unused #include files from check-computed-goto.cc.
Did the same for a few other similar files.

Original-commit: flang-compiler/f18@6f7569b938
Reviewed-on: https://github.com/flang-compiler/f18/pull/360
2019-03-27 20:46:51 -07:00
Steve Scalpone
fa2e6374ce [flang] Fix typo: "check" becomes "checked"
Original-commit: flang-compiler/f18@2b2b0bf324
Reviewed-on: https://github.com/flang-compiler/f18/pull/360
Tree-same-pre-rewrite: false
2019-03-27 15:48:46 -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