Commit graph

661 commits

Author SHA1 Message Date
peter klausler
008e697192 [flang] Fix regressions found in testing
Original-commit: flang-compiler/f18@ea09b191df
Reviewed-on: https://github.com/flang-compiler/f18/pull/553
2019-07-08 16:02:50 -07:00
peter klausler
644b2aabd0 [flang] Support *length character length specifiers
Original-commit: flang-compiler/f18@874b13b7d8
Reviewed-on: https://github.com/flang-compiler/f18/pull/553
Tree-same-pre-rewrite: false
2019-07-08 14:07:56 -07:00
Peter Steinfeld
5b7b8866b8 [flang] Improved the implementation of "IsCoarray()" suggested by @tskeith.
Original-commit: flang-compiler/f18@efaf5fca2e
Reviewed-on: https://github.com/flang-compiler/f18/pull/542
2019-07-03 13:59:44 -07:00
Peter Steinfeld
02a395dcb7 [flang] Changes in response to comments on pull request flang-compiler/f18#542.
Original-commit: flang-compiler/f18@e156f977d8
Reviewed-on: https://github.com/flang-compiler/f18/pull/542
Tree-same-pre-rewrite: false
2019-07-03 13:50:57 -07:00
Peter Steinfeld
84b70d8b73 [flang] Enforce constraint C1128 for DO CONCURRENT locality-spec's
These changes implement most of the requirements for C1128, which says: "A
variable-name that appears in a LOCAL or LOCAL_INIT locality-spec shall not
have the ALLOCATABLE; INTENT (IN); or OPTIONAL attribute; shall not be of
finalizable type; shall not be a nonpointer polymorphic dummy argument; and
shall not be a coarray or an assumed-size array.  A variable-name that is not
permitted to appear in a variable definition context shall not appear in a
LOCAL or LOCAL_INIT locality-spec."

The changes do not implement the checking required to determine whether a
variable can appear in a "variable definition context".

Here's a summary of the changes:
 - I created the function 'PassesLocalityChecks()' to enforce C1128 along with
   C1124, C1125, and C1126.
 - I cleaned up the code to check if a type or symbol is a coarray.
 - I added functions to tools.[h,cc] to test if a symbol is OPTIONAL, INTENT
   IN, finalizable, a coarray, or an assumed size array.  Should these be
   member functions of the type "Symbol"?
 - Since I changed one of the locality related error messages, I needed to
   change the test resolve35.f90.
 - I added the test resolve55.f90 to test all of the checks implemented in this
   update.

Original-commit: flang-compiler/f18@4ca5d090b9
Reviewed-on: https://github.com/flang-compiler/f18/pull/542
Tree-same-pre-rewrite: false
2019-07-03 13:50:56 -07:00
Jinxin (Brian) Yang
f8da811848 [flang] 2.7.1 DO: Checks about clause arguments that allow Int Expr (flang-compiler/f18#540)
All the IntExpr argument checks are done through evaluating the result of GetIntValue. If the argument is non-constant integer expr, Expression Analysis will be the gatekeeper.


Original-commit: flang-compiler/f18@d8c4804828
Reviewed-on: https://github.com/flang-compiler/f18/pull/540
2019-07-03 14:24:37 -07:00
peter klausler
042298446b [flang] Graceful handling of failure in LEN() (fixes crashes)
Original-commit: flang-compiler/f18@8bab36574d
Reviewed-on: https://github.com/flang-compiler/f18/pull/545
2019-07-03 10:27:50 -07:00
vdonaldson
a254653536 [flang] A minimal PRINT Enter function requires a minimal PRINT Leave function. (flang-compiler/f18#543)
Fixes flang-compiler/f18#541

Original-commit: flang-compiler/f18@8f3c5481e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/543
2019-07-03 09:59:59 -07:00
Tim Keith
42831fa6a9 [flang] Merge pull request flang-compiler/f18#539 from flang-compiler/tsk1
Check that procedures of a generic are distinguishable

Original-commit: flang-compiler/f18@a24701e313
Reviewed-on: https://github.com/flang-compiler/f18/pull/539

Due to a conflicting rebase during the linearizing of flang-compiler/f18, this commit squashes a number of other commits:

flang-compiler/f18@9b1343af36 Some cleanup in characteristics.{h,cc}
flang-compiler/f18@ddb70e53d2 Merge branch 'master' of github.com:flang-compiler/f18 into tsk1
flang-compiler/f18@d1eef95066 Merge branch 'master' of github.com:flang-compiler/f18 into tsk1
flang-compiler/f18@24a6d3ffbf Make test_folding.sh stricter in test for warnings
flang-compiler/f18@c2c5b64060 Replace SymbolList with SymbolVector
flang-compiler/f18@c8499584df Add CopyAttrs to copy attributes from Symbol
flang-compiler/f18@0573ffd8b2 Replace cascading detailsIf calls with std::visit
flang-compiler/f18@28ec62b3ff Add name to characteristics::DummyArgument
flang-compiler/f18@568eaf0114 Add name to CopySymbol()
flang-compiler/f18@8c557b09e7 Check that procedures of a generic are distinguishable
flang-compiler/f18@50515fd987 Merge branch 'master' of github.com:flang-compiler/f18 into tsk1
flang-compiler/f18@a7963e98a4 Address review comments
flang-compiler/f18@edd65b3962 Merge branch 'master' of github.com:flang-compiler/f18 into tsk1
2019-07-02 14:00:44 -07:00
peter klausler
bdcdf04431 [flang] Use LOC() in iso_c_binding for C_LOC and C_FUNLOC
Original-commit: flang-compiler/f18@da02305d1b
Reviewed-on: https://github.com/flang-compiler/f18/pull/538
Tree-same-pre-rewrite: false
2019-07-01 16:54:53 -07:00
peter klausler
c140c1e674 [flang] clean up for review
Original-commit: flang-compiler/f18@9bf94ea39c
Reviewed-on: https://github.com/flang-compiler/f18/pull/538
Tree-same-pre-rewrite: false
2019-07-01 14:00:33 -07:00
peter klausler
8e93226e74 [flang] Add LOC()/%LOC() intrinsics
Original-commit: flang-compiler/f18@3a6b90c9f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/538
Tree-same-pre-rewrite: false
2019-07-01 14:00:32 -07:00
Jinxin (Brian) Yang
1b0be3e0c9 [flang] Structural checks for DO construct (flang-compiler/f18#536)
Most restrictions in 2.7.1 Loop construct, nesting checks are still on TODO list.

seenClauses (EnumSet) is dropped. A multimap clauseInfo is added to save the encountering clause and its parser tree node pointer (parser::OmpClause) and to do the checks after walking through all the clauses.

Original-commit: flang-compiler/f18@f797357682
Reviewed-on: https://github.com/flang-compiler/f18/pull/536
2019-07-01 13:55:06 -07:00
peter klausler
dbb202c5be [flang] Extirpate NCHARACTER type, NC"" literals, and EUC-JP Hollerith
Original-commit: flang-compiler/f18@10a592a591
Reviewed-on: https://github.com/flang-compiler/f18/pull/535
Tree-same-pre-rewrite: false
2019-06-28 11:22:43 -07:00
peter klausler
f937238d42 [flang] Better error reporting, with test
Original-commit: flang-compiler/f18@85e8b64d3e
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
2019-06-28 09:21:04 -07:00
peter klausler
28c03d3a38 [flang] address review comments
Original-commit: flang-compiler/f18@f7188a7a33
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
Tree-same-pre-rewrite: false
2019-06-28 09:20:59 -07:00
peter klausler
737fe29f2b [flang] Fix regressions from testing pass
Original-commit: flang-compiler/f18@70ea3b4b09
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
Tree-same-pre-rewrite: false
2019-06-28 09:20:55 -07:00
peter klausler
7d33b8529a [flang] Refine implicit typing of functions and prevent invalid conversion to objects
Original-commit: flang-compiler/f18@a90f752c20
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
Tree-same-pre-rewrite: false
2019-06-28 09:20:46 -07:00
peter klausler
ba780030c7 [flang] Fix function call implicit typing after recent merge
Original-commit: flang-compiler/f18@f91779c79a
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
Tree-same-pre-rewrite: false
2019-06-28 09:16:49 -07:00
peter klausler
00e128e42a [flang] Refactor SymbolOrComponent typedef to NamedEntity class
Original-commit: flang-compiler/f18@e8ec4b88bd
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
Tree-same-pre-rewrite: false
2019-06-28 09:16:47 -07:00
peter klausler
98e3113206 [flang] Better initialization support
Original-commit: flang-compiler/f18@ff2f26fe7b
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
Tree-same-pre-rewrite: false
2019-06-28 09:16:46 -07:00
peter klausler
a53b11c92d [flang] Support anonymous parent components in struct const
Original-commit: flang-compiler/f18@b28b9932b7
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
Tree-same-pre-rewrite: false
2019-06-28 09:16:41 -07:00
Peter Steinfeld
ff2c862e07 [flang] Fixed the formatting of an "if" statement.
Original-commit: flang-compiler/f18@0cf7114452
Reviewed-on: https://github.com/flang-compiler/f18/pull/533
2019-06-27 15:18:36 -07:00
Peter Steinfeld
aafeb34962 [flang] Fixes for DO constraint C1124
The constraint says that a variable-name in a locality-spec shall be the name
of a variable in the innermost executable construct or scoping unit that
includes the DO CONCURRENT statement.  This check was already being made in
resolve-names.cc for LOCAL and LOCAL_INIT locality specs but not for the
SHARED locality spec.  Also, there was some code in check-do.cc that was
intended to be used to enforce this constraint at some time in the future.

I added code to resolve-names.cc to extend the checking to the SHARED locality
spec and removed the unused code from check-do.cc.  I also extended the
existing tests in resolve35.f90 to exercise the new code.

Original-commit: flang-compiler/f18@b421923d94
Reviewed-on: https://github.com/flang-compiler/f18/pull/533
Tree-same-pre-rewrite: false
2019-06-27 12:33:36 -07:00
vdonaldson
3b14129337 [flang] Initialize PRINT semantics. Fixes flang-compiler/f18#516 (flang-compiler/f18#528)
There are no Clause 12 constraints to check for PRINT, but PRINT does share
FMT specifier processing with READ and WRITE.  To avoid interactions between
these I/O statements, reset IoChecker values for PRINT.

Original-commit: flang-compiler/f18@6a54766718
Reviewed-on: https://github.com/flang-compiler/f18/pull/528
2019-06-26 15:46:48 -07:00
Jinxin (Brian) Yang
125f295353 [flang] OpenMP structural check framework (PARALLEL as example) (flang-compiler/f18#493)
This patch is to show the framework to do OpenMP structure related check and you may find missing/incomplete implementation, which will be added in the future.

1. Each encountering construct has its own context and the context info will be filled while walking the directive/clause nodes. In the `Leave`, the current OpenMP context will be popped out.

2. When entering the construct, necessary nesting check will be performed. Use std::vector to implement the context stack because certain nesting restrictions may need to trace back more than one level.

3. PARALLEL construct is used as an example for clause validity check.

4. `EnumSet` is used to represent the directive/clause sets and to show the error msg. All the error msgs are quoted from the specification.

5. Necessary `CharBlock` is added for error msgs.

Original-commit: flang-compiler/f18@620441c03e
Reviewed-on: https://github.com/flang-compiler/f18/pull/493
2019-06-25 16:18:51 -07:00
vdonaldson
69f5f13738 [flang] Clause 13 (Input/output editing) syntax and semantic checking (flang-compiler/f18#498)
* Clause 13 (Input/output editing) syntax and semantic checking

Diagnose:
 - all clause syntax errors (independent of normal parsing)
 - all clause constraints
 - use of non-standard extensions under -Mstandard
 - obvious program requirement violations

The code:
 - is invoked for both format statement and I/O statement constant formats
 - should be useable by the runtime I/O library for runtime formats
 - is able to recover from errors
 - is able to diagnose multiple errors in a single format
 - has accurate markers for errors
 - can process (fixed character size) Hollerith strings
 - generates reasonable error messages for known error scenarios
 - should not require C++ run-time library support

The code is templatized for use with fixed size character kind={1,2,4} input,
but only the kind=1 variant is actually exercised.

* Review update.

* Review update.

* Review update.

* Improve error processing of unterminated formats.

Original-commit: flang-compiler/f18@c04b7518df
Reviewed-on: https://github.com/flang-compiler/f18/pull/498
2019-06-25 15:59:30 -07:00
Tim Keith
fe899298d0 [flang] Check constraints on passed-object dummy argument
The passed-object dummy argument cannot be checked until the
interfaces of contained subprograms are known. To accomplish this,
add `FinishSpecificationPart` pass to run after all specification
parts have been analyzed but before any of the execution parts.
This visits all derived types defined in each scope and performs
the checks on each procedure component and procedure binding.

Add a flag to `ParamValue` to distinguish kind from len parameters.

Fix some tests that had errors we now detect.

Original-commit: flang-compiler/f18@4789643c5b
Reviewed-on: https://github.com/flang-compiler/f18/pull/521
2019-06-23 10:59:32 -07:00
Tim Keith
432e62b417 [flang] Add passArg to ProcEntityDetails and ProcBindingDetails
Add `passArg` to `ProcEntityDetails` and `ProcBindingDetails`.
The is the symbols that represents the passed-object dummy argument,
or nullptr if none.

As both of these classes need `passName` and `passArg`, create a mixin
class, `WithPassArg` for the shared content.

Change passName_ from optional to pointer because that makes it a little
easier to work with and there is no need to have a copy of the name.

Original-commit: flang-compiler/f18@1cdd1a5b87
Reviewed-on: https://github.com/flang-compiler/f18/pull/521
Tree-same-pre-rewrite: false
2019-06-22 18:53:16 -07:00
Tim Keith
9a98616dbb [flang] Add AsFortran() for types
Add an `AsFortran()` member function to `DeclTypeSpec` and related
classes to convert types to a Fortran representation. This allows
error messages to mention types. It also fixes `.mod` file writing
where it previous used `operator<<` to convert types to Fortran.

Original-commit: flang-compiler/f18@eb16f8b5dd
Reviewed-on: https://github.com/flang-compiler/f18/pull/521
Tree-same-pre-rewrite: false
2019-06-22 18:14:14 -07:00
Tim Keith
377914d8b3 [flang] Add IsIsoCType()
It identifies the types `C_PTR` and `C_FUNPTR` from predefined
module `ISO_C_BINDING`.

Original-commit: flang-compiler/f18@fcbef2e18b
Reviewed-on: https://github.com/flang-compiler/f18/pull/521
Tree-same-pre-rewrite: false
2019-06-21 17:32:11 -07:00
Peter Steinfeld
21d1e7131d [flang] Downgrading the semantics check for C1127 to a warning.
This check to see if there are two DEFAULT (NONE) clauses in a DO CONCURRENT
header.

Original-commit: flang-compiler/f18@9b234125fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/513
2019-06-24 13:09:21 -07:00
Tim Keith
facd7147f4 [flang] Fix internal error due to missing type
If a name is declared in a module with just `private :: x`,
we don't know if `x` is supposed to be an object or procedure,
so it ends up not getting an implicit type. This leads to an
internal error when writing the `.mod` file.

The fix requires two changes:
1. Cause all `EntityDetails` to be converted to `ObjectEntityDetails`
   in `ResolveSpecificationParts`. This is done by calling `PopScope()`.
   The reason for not calling it there no longer applies since the
   addition of the `ExecutionPartSkimmer` pass.
2. In the same place, apply the implicit typing rules to every entity
   in the scope.

Fixes flang-compiler/f18#514, fixes flang-compiler/f18#520.

Original-commit: flang-compiler/f18@7e4185e9ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/524
2019-06-24 15:22:57 -07:00
Tim Keith
86132a15dc [flang] Fix bug in writing PRIVATE subprograms to .mod file
Subprograms can't have the PRIVATE prefix on them when they are defined.
So if they are private, add a private-stmt for them.

Fixes flang-compiler/f18#519

Original-commit: flang-compiler/f18@d3670aa176
Reviewed-on: https://github.com/flang-compiler/f18/pull/523
2019-06-24 12:35:17 -07:00
Peter Steinfeld
6e12d0810a [flang] Changes to improve messages for DO semantics
I changed two things in the messages produced for DO semantic checks --
 - I changed the source location to be specific to where conflicting names are
 declared.
 - I added the conflicting names to the message.

Original-commit: flang-compiler/f18@f39f9ceeae
Reviewed-on: https://github.com/flang-compiler/f18/pull/510
2019-06-20 17:07:13 -07:00
Tim Keith
56b0e2a759 [flang] Fix CHECK failure on undeclared type parameter
In the example below, the compiler gets an internal error when
processing the derived-type-spec for the declaration of `x`.
When the search for type parameter `k` fails it means an error
has already occurred and we should skip that parameter.

```
type :: t(k)
end type
type(t):: x
end
```

Original-commit: flang-compiler/f18@a4bf1922e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/509
2019-06-20 14:23:21 -07:00
Peter Steinfeld
a26fff722f [flang] Added "const" to a few declarations in response to review comments.
Original-commit: flang-compiler/f18@f93045c523
Reviewed-on: https://github.com/flang-compiler/f18/pull/504
2019-06-20 11:45:17 -07:00
Peter Steinfeld
fe19b37dea [flang] These changes are in response to comments on my pull request for C1123.
Here's a summary of the changes:
 - I renamed a function to ResolveControlExpressions for clarity.
 - I changed the interface to the function to ResolveIndexName for clarity.
 - I simplified the code for walking the "step" and scalar mask expressions in
   a DO CONCURRENT control statements to not check for the presence of optional
   expressions.
 - I added "const" to the declaration of a local variable.
 - I removed some spurious comments from the test dosemantics04.f90.
 - I added two new tests to dosemantics04.f90 to verify cases that were not
   covered in my original test implementation.

Original-commit: flang-compiler/f18@fa5827061a
Reviewed-on: https://github.com/flang-compiler/f18/pull/504
Tree-same-pre-rewrite: false
2019-06-20 09:58:03 -07:00
Peter Steinfeld
88054b3491 [flang] I fixed a problem in C1123. This constraint requires that expressions in a DO
CONCURRENT header not reference names declared in the same header.  To
implement this, I changed the "Pre" function for ConcurrentHeader to walk the
subtree in an order that caused the variables associated with the declared
names to be created before any of the expressions were walked.

I added the test dosemantics04.f90 to test this.

Original-commit: flang-compiler/f18@9f3b552414
Reviewed-on: https://github.com/flang-compiler/f18/pull/504
Tree-same-pre-rewrite: false
2019-06-20 09:58:03 -07:00
peter klausler
9a9b450011 [flang] EQUIVALENCE numeric/character as extension with warning
Original-commit: flang-compiler/f18@0182efb759
Reviewed-on: https://github.com/flang-compiler/f18/pull/508
Tree-same-pre-rewrite: false
2019-06-19 16:34:50 -07:00
peter klausler
40b1cc9b62 [flang] Fix a couple bugs with SELECT TYPE(p) from regression tests
Original-commit: flang-compiler/f18@7539a01ecd
Reviewed-on: https://github.com/flang-compiler/f18/pull/508
Tree-same-pre-rewrite: false
2019-06-19 16:34:50 -07:00
peter klausler
4f2c8fae65 [flang] Fix source provenance of .NOT., add ALLOCATED intrinsic
Original-commit: flang-compiler/f18@e7e0de9e0d
Reviewed-on: https://github.com/flang-compiler/f18/pull/505
Tree-same-pre-rewrite: false
2019-06-19 11:50:07 -07:00
peter klausler
7d24cebc17 [flang] Rearrange some move(get<>()) calls into get<>(move()) to dodge GCC possibly-uninit warnings (bogus)
Original-commit: flang-compiler/f18@f369c6025c
Reviewed-on: https://github.com/flang-compiler/f18/pull/503
Tree-same-pre-rewrite: false
2019-06-18 15:15:22 -07:00
peter klausler
fdcdd504b3 [flang] more fixes from tests
Original-commit: flang-compiler/f18@bb8df72635
Reviewed-on: https://github.com/flang-compiler/f18/pull/496
Tree-same-pre-rewrite: false
2019-06-18 12:34:23 -07:00
peter klausler
94a667bb94 [flang] nag debugged
Original-commit: flang-compiler/f18@ab91b7c191
Reviewed-on: https://github.com/flang-compiler/f18/pull/496
Tree-same-pre-rewrite: false
2019-06-17 16:13:10 -07:00
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