Commit Graph

2326 Commits

Author SHA1 Message Date
Tim Keith 9b31cbe7db [flang] Add support for logical abbreviations and .XOR.
Update the grammar to handle logical abbreviations (e.g. `.A.` for `.AND.`)
when the feature is enabled. Only support `.X.` when both XOR and
logical abbreviations are enabled.

Fix the driver to enable logical abbreviations with the
`-flogical-abbreviations` option. This was already documented in
`documentation/Extensions.md`.

Remove `parser::Expr::XOR` from the parse tree and immediately map
`.XOR.` to `.NEQV.` if that feature is enabled. This was already being
done during expression analysis anyway.

Add `LanguageFeatureControl::GetNames` to return all of the names of
a logical or relational operator, depending on which features are
enabled. Use these in both name resolution and expression analysis.
Add `Not` to `LogicalOperator` to help in those cases.

Fix handling of BOZ literals: A numeric operation with one real or
integer operand and the other a BOZ literal is intrinsic.
Also, unary plus with a BOZ literal operand is also intrinsic.

Original-commit: flang-compiler/f18@956bd50bc7
Reviewed-on: https://github.com/flang-compiler/f18/pull/815
2019-11-07 14:45:58 -08:00
Tim Keith cae50f01ff [flang] Move features.h from parser to common
Which features are enabled and disabled applies to more than just the
parser, so move that functionality to `common`.

Original-commit: flang-compiler/f18@98b3240efc
Reviewed-on: https://github.com/flang-compiler/f18/pull/815
Tree-same-pre-rewrite: false
2019-11-06 11:15:03 -08:00
peter klausler a717d170cc [flang] Change more pointers into references
Remove unused interface

Respond to review comments

Original-commit: flang-compiler/f18@7fdfe7b4ac
Reviewed-on: https://github.com/flang-compiler/f18/pull/809
2019-11-05 10:28:17 -08:00
vdonaldson 65791b2d0b [flang] Relax the implementation of constraint C1302. (flang-compiler/f18#805)
* Relax the implementation of constraint C1302.

When a list of format items can be unambiguously partitioned into individual items even though one or more otherwise required comma separators are omitted, generate a warning rather than an error.

Fixes flang-compiler/f18#703

Original-commit: flang-compiler/f18@79c0731137
Reviewed-on: https://github.com/flang-compiler/f18/pull/805
2019-11-05 10:11:36 -08:00
Jean Perier 572de7c7b0 [flang] Implement MIN and MAX folding
* Use Extremum<T> FoldOperation to fold MIN and MAX
* Fix Extremum<T> FolOperation
    * For character, the length is the one of the longest argument.
      Define and use `CharacterUtils<Kind>::Resize` helper to do this.
    * For array of all types, Extremum<T> with Ordering::Less was
      behaving like Ordering::Greater. This is because the default
      `ApplyElementwise` for `Operation` was selected and it then
       called the Extremum<T> constructor without the ordering
       argument (which was an optional defaulted to Greater).
      Define a specific handler for Extremum<T> and make the ordering
      argument mandatory to prevent this kind of bug to pass
      f18 compilation in the futur.
* Fix intrinsic.cc for MIN and MAX
    * When provided with two arguments, `Match` was adding an empty
      3rd optional actual argument. Later code working on min and
      max was not expecting this and failing. The fix prevent this
      empty argument to be created by changing the initial size of
      `actualForDummy` to actually be the number of dummies that do
      not have `Optionality::Repeats`

This commit fixes issue flang-compiler/f18#677.

Original-commit: flang-compiler/f18@acb62f240b
Reviewed-on: https://github.com/flang-compiler/f18/pull/803
2019-11-05 02:54:12 -08:00
peter klausler 2c89c31a59 [flang] Enable and pass call08.f90
Refine a check

Original-commit: flang-compiler/f18@bb96c195d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/812
2019-11-04 14:35:36 -08:00
Tim Keith cf9059ae98 [flang] Fix build error using clang
Change `AllFortranNames()` to return a `std::vector` rather than a
`std::initialization_list`. The latter doesn't own its underlying
storage and so can't be returned as a value. clang detects this and
issues a warning.

Two tests in `resolve63.f90` behave differently with clang and require
further investigation.

Original-commit: flang-compiler/f18@1ed3a3cfee
Reviewed-on: https://github.com/flang-compiler/f18/pull/810
2019-11-04 12:05:51 -08:00
Tim Keith dce7f0aca0 [flang] Resolve extended intrinsic operators
Enhance `ArgumentAnalyzer` to do most of the work for this.
For each kind of operator that might have a user-defined form we follow
this process:
- analyze the arguments
- if the types and shapes match the intrinsic operator do the usual
  processing
- otherwise attempt to interpret it as a user-defined operator with
  `TryDefinedOp`

When we fail to resolve an operator, produce different errors depending
on whether there is a user-defined operator available or not.
If there is, report that neither user-defined nor intrinsic operator
worked. If there is not, describe the rules for the intrinsic operator.
In either case, include the type(s) of the operand(s).

Most of the uses of `ArgumentAnalyzer` are in helper functions that
apply to classes of operators.
For consistency, rename `BinaryOperationHelper` to `NumericBinaryOperator`
and `LogicalHelper` to `LogicalBinaryHelper` and introduce `NumericUnaryHelper`
for unary `+` and `-`.  `.NOT.` and `//` are not implemented in helpers.

Replace `success_` with `fatalErrors_` in `ArgumentAnalyzer` for
consistency with `ExpressionAnalyzer`.

Add `NumericOperator` and `LogicalOperator` enums to `Fortran.h` to go
with `RelationalOperator`. Add `AddFortran` functions to each to convert
to a Fortran source string. `RelationalOperator` also has `AllFortranNames`
because there are multiple names for each operator. This replaces
`LogicalOperator` in `expression.h` and the string representation of
the operators in `formatting.cc`.

Original-commit: flang-compiler/f18@3bb9d664e8
Reviewed-on: https://github.com/flang-compiler/f18/pull/807
2019-11-04 10:47:43 -08:00
peter klausler c14c2b9573 [flang] Enable and pass test call07.f90
Remove a std::move()

Final tweaks after testing and review

Original-commit: flang-compiler/f18@b3fe97b1a0
Reviewed-on: https://github.com/flang-compiler/f18/pull/806
2019-11-02 10:20:39 -07:00
peter klausler 7a681f46f8 [flang] Use c_str() rather than data() where NUL termination is assumed
Original-commit: flang-compiler/f18@5baed3c856
Reviewed-on: https://github.com/flang-compiler/f18/pull/804
2019-10-31 13:25:28 -07:00
peter klausler 926da903f2 [flang] enable call06.f90 test
Relax checking when irrelevant due to INTENT(IN)

Add and pass call14.f90 test on VALUE

Allow ASYNCHRONOUS/VOLATILE to apply to host/USE associated entities, add tests

Pass call06

Check C827 & C828, fix tests

Original-commit: flang-compiler/f18@df6cb83794
Reviewed-on: https://github.com/flang-compiler/f18/pull/801
2019-10-30 15:50:28 -07:00
peter klausler afd39cd49c [flang] Use reference_wrapper in vectors and sets
Convert some CharBlock references to values

Replace more pointers with reference wrappers

Restore object references that were converted to value semantics in an earlier commit

Use Reference<> in Scope

Fix new component iterator

Document pitfall that bit me

final tweaks before rebasing and merging

Rebasing

Original-commit: flang-compiler/f18@87874af934
Reviewed-on: https://github.com/flang-compiler/f18/pull/788
2019-10-29 12:32:28 -07:00
Jinxin Yang 2839cb3835 [flang] Throw error in case of missing listed test
Original-commit: flang-compiler/f18@dabc0ba0e0
2019-10-28 12:58:52 -07:00
Jinxin Yang 004a4c577b [flang] [OpenMP] Test Infra update to support OpenMP symbol tests
During the symbol tests, OpenMP directives (start with "!$omp")
line needs to be saved for 1.f90 and 2.f90. Also moved "OPTIONS:"
detection to common.sh as "$USER_OPTIONS"

Original-commit: flang-compiler/f18@7d4e8e8ad5
2019-10-28 12:58:15 -07:00
Jinxin Yang eeda304160 [flang] [OpenMP] address more comments
The major changes are:
  1) changed the non-nullptr type to reference
  2) changed ResolveOmpObject to use std::visit
  3) the rest of the changes are about positions and naming

Original-commit: flang-compiler/f18@93debe59f3
2019-10-25 15:16:20 -07:00
Jinxin Yang 8143b8980d [flang] [OpenMP] adjust for PR#753 `OmpObject` parse tree change
PR#753 changed the `OmpObject` to be:

```
struct OmpObject {
  UNION_CLASS_BOILERPLATE(OmpObject);
  std::variant<Designator, /*common block*/ Name> u;
};
```

This commit adjust the logic flow for `ResolveOmpObject` based on
the above parse tree change.

For an `OmpObject`,
```
if (Designator) {
  if (DataRef.Name) {
    // Resolve Names
  } else {
    // ResolveDesignator
    // AnalyzeExpr
    if (Designator.Substring) {
      // Error
    }
    // other checks like StructureComponent, ArrayElement, etc.
  }
} else if (Name) {
  // Resolve COMMON block
}
```

Original-commit: flang-compiler/f18@e5c1b92c15
2019-10-25 15:16:20 -07:00
Jinxin Yang 0554d39d74 [flang] [OpenMP] Implement no-multiple-appearance rule for DSA Clauses
DSA stands for Data-Sharing Attribute. This work is part of the
Name Resolution for OpenMP framework (data-refs on clauses part)

Based on 2.15.3: A list item that specifies a given variable may
not appear in more than one clause on the same directive, except that
a variable may be specified in both firstprivate and lastprivate clauses.

Through a temporary `std::set` of `const Symbol *` to keep track of
all the symbols on a certain OpenMP directive, we can determine whether
a variable `Name` (or `Symbol`, more accurately) has already appeared on
another DSA clause already, with the exception of FIRSTPRIVATE clause
and LASTPRIVATE clause. This rule applies to `/COMMON block/` also and
the source provenance shows on error message points to the `Name` between
slashes.

Added two more tests and changed some existing tests to accommodate
this commit. I intend to keep the `omp-clause-validity01.f90` test to
do the validity checks only.

Original-commit: flang-compiler/f18@0d7828c21e
2019-10-25 15:16:20 -07:00
Jinxin Yang df51352d72 [flang] [OpenMP] avoid creating new symbol for common block
Original-commit: flang-compiler/f18@ba2cceb4a2
2019-10-25 15:16:20 -07:00
Jinxin Yang f3961579ac [flang] [OpenMP] add common block example
Original-commit: flang-compiler/f18@a4c923e848
2019-10-25 15:16:20 -07:00
Jinxin Yang 4ca8c5dc5c [flang] [OpenMP] OmpVisitor framework for Name Resolution
This is a preliminary framework to do the name resolution for
data references on the OpenMP clauses. Unlike data references
in the OpenMP region, clauses determining the data-sharing or
data-mapping attributes are straightforward and the resolution
process could be extended to do the name resolution in the OpenMP
region. It is hard to determine what kind of checks can be done
in this visitor and what checks should be done later after name
resolution. But the guide line is that `After the completion of
this phase, every Name corresponds to a Symbol with proper OpenMP
attribute(s) determined unless an error occurred.`

1. Take data-sharing clauses as example, create new symbol for
variable that require private access within the OpenMP region.
Declare the entity implicitly if necessary. The new symbol has
`HostAssocDetails`, which is mentioned in the `OpenMP-semantics.md`.

2. For `Shared` or `ThreadPrivate`, no symbol needs to be created.
OpenMP attribute Flag `OmpThreadprivate` needs to be marked for
`Threadprivate` because the `threadprivate` attribute remains the
same whenever these variables are referenced in the program.
`Names` in `Shared` clause need to be resolved to associate the
symbols in the clause enclosing scope (contains the OpenMP directive)
but `OmpShared` does not need to be marked. Declare the entity
implicitly if necessary.

3. For `COMMON block`, when a named common block appears in a list,
it has the same meaning as if every explicit member of the common
block appeared in the list. Also, a common block name specified in
a data-sharing attribute clause must be declared to be a common
block in the same scoping unit in which the data-sharing attribute
clause appears. So, if a named common block appears on a `PRIVATE`
clause, all its members should have new symbols created within the
OpenMP region (scope). For later Semantic checks and CG, a new
symbol is also created for common block name with `HostAssocDetails`.

There are many things are still on the TODO list:
- Better error/warning messages with directive/clause source provenance

- Resolve variables referenced in the OpenMP region, for example,
  `private(tt%a)` is not allowed but `tt%a = 1` is allowed in the
  OpenMP region and a private version of `tt` maybe created for
  the region. The functions created in the `OmpVisitor` should be
  able to handle the name resolution on the statement too (more
  data structures may be introduced). This is a big portion and may
  require some interface changes to distinguish a reference is on
  `OpenMP directive/clause` or `statements within OpenMP region`.

- Same data reference appears on multiple data-sharing clauses.

- Take association into consideration for example Pointer association,
  `ASSOCIATE` construct, and etc.

- Handle `Array Sections` and `Array or Structure Element`.

- Handle all the name resolution for directives/clauses that have
  `parser::Name`.

- More tests

Original-commit: flang-compiler/f18@b2ea520885
2019-10-25 15:16:20 -07:00
Pete Steinfeld 31cc851629 [flang] Changes to check for calls to PURE procedure components
This addresses issue flang-compiler/f18#781.  I changed my test to create a PURE procedure
component by using an interface as suggested by Peter and Jean.  I then
enhanced the function IsPureProcedure() in tools.cc to cover this case
and updated the code in check-do.cc to perform the test.

Original-commit: flang-compiler/f18@5df56a217d
Reviewed-on: https://github.com/flang-compiler/f18/pull/789
2019-10-25 09:48:20 -07:00
peter klausler 7c44a2011b [flang] Restore a review comment response
Original-commit: flang-compiler/f18@d9673df31c
Reviewed-on: https://github.com/flang-compiler/f18/pull/792
2019-10-25 09:01:27 -07:00
peter klausler 715f2c0d86 [flang] Fix duplicate messages
Original-commit: flang-compiler/f18@6528c5f31b
Reviewed-on: https://github.com/flang-compiler/f18/pull/792
Tree-same-pre-rewrite: false
2019-10-24 16:38:09 -07:00
peter klausler 5f270940ff [flang] Restored changes from pmk-call05
Original-commit: flang-compiler/f18@bb9c12eec3
Reviewed-on: https://github.com/flang-compiler/f18/pull/792
Tree-same-pre-rewrite: false
2019-10-24 16:08:06 -07:00
peter klausler b5eec67fc4 [flang] Add contextualizing interfaces to ExpressionAnalyzer and ContextualMessages
Original-commit: flang-compiler/f18@30a004d7b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/790
2019-10-24 14:55:25 -07:00
Pete Steinfeld 196fec7d85 [flang] # This is a combination of 2 commits.
# This is the 1st commit message:

Changes to disallow image control statements in DO CONCURRENT

Most of these changes were already implemented.  The last remaining part was to check for calls to move_alloc with coarray arguments.  This set of changes implements that.  I also bundled other changes.  Specifically:

All of the code to detect image control statements was moved from check-do.cc to tools.cc so that it could be used by other semantic checking functions.

I added location information to the error messages for all DO semantics checks to highlight either the DO loop associated with the error or other relevant source locations.

I cleaned up the error messages associated with DO semantics so that they have more consistent grammar and punctuation.

I eliminated redundant checks for IEEE_GET_FLAG and IEEE_HALTING_MODE.

I removed the redundant test doconcurrent08.f90.

Responses to pull request comments

I changed the interface to determine whether a statement is an image control
statement to use an ExecutableConstruct as its input.  Since
ExecutableConstruct contains types that do not have source location information
(ChangeTeamConstruct and CriticalConstruct), I also created a function to get
the source location of an ExecutableConstruct.  Also, some ExecutableConstructs
are image control statements because they reference coarrays.  I wanted to tell
users that the reason that an ALLOCATE statement (for example) is an image
control statement because it references a coarray.  To make this happen, I
added another function to return a message for image control statements that
reference coarrays.

I also cleaned up the references to the standard in comments in check-do.cc to
briefly describe the contents of those constraints.

I also added messages that refer to the enclosing DO CONCURRENT statement for
error messages where appropriate.

Responses to pull request comments

The biggest change was to redo the implementation of "IsImageControlStmt()" to
use a custom visitor that strips off the "common::Indirection<...>" prefix of
most of the image control statement types and also takes advantage of
"common::HasMember<...>" to determine if a variant contains a specific type.

Spelling error.

# This is the commit message flang-compiler/f18#2:

More refactoring in response to comments on the pull request.

Original-commit: flang-compiler/f18@3f0a0155b3
Reviewed-on: https://github.com/flang-compiler/f18/pull/780
2019-10-23 14:06:16 -07:00
Tim Keith 373f7489ef [flang] Resolve defined operators to specifics
Most of these changes involve moving code around so that it case be
used for `DefinedUnary` and `DefinedBinary`. The functional changes are
in the `Analyze` member functions for those cases where the arguments
are now analyzed, the generic is resolved, and a `FunctionRef` is
created.

Add `ArgumentAnalyzer` to handling building of the `ActualArguments`
of a call. This allows the code to be shared with the defined unary
and defined binary cases. Move `AnalyzeActualArgument` and
`AnalyzeActualArgument` into that class (renaming both to `Analyze`).

Create an overload of `GetCalleeAndArguments` for the `Name` case so it
can be used for defined ops where we don't have a `ProcedureDesignator`.

Move `IsGenericDefinedOp` to `tools.h` to make it available to the
new code.

We were using `semantics::CheckExplicitInterface` to resolve a generic
interface to a specific procedure based on actual arguments. The problem
with that is that it performs too many checks. We just want to get the
right specific; there may be errors reported later during call analysis.

To fix this, add a new function, `CheckInterfaceForGeneric`, to perform
this check. It shares code with `CheckExplicitInterface`, but it passes
in a null scope to indicate that the full set of checks aren't
necessary in `CheckExplicitInterfaceArg`. Instead we lift the call to
`TypeAndShape::IsCompatibleWith` out of `CheckExplicitDataArg`, and skip
the latter when there is no scope.

Original-commit: flang-compiler/f18@fff2d1580f
Reviewed-on: https://github.com/flang-compiler/f18/pull/786
2019-10-23 06:25:51 -07:00
peter klausler 7aea2f6cb9 [flang] Fix bad new test, and fix detection of test failures in that test too
Original-commit: flang-compiler/f18@38ec2a879b
Reviewed-on: https://github.com/flang-compiler/f18/pull/787
2019-10-22 15:28:26 -07:00
peter klausler f3ae44f645 [flang] Work around a gcc-7.2 specific build bug by recoding with a better approach
Original-commit: flang-compiler/f18@bc2b4015b0
Reviewed-on: https://github.com/flang-compiler/f18/pull/785
2019-10-22 10:34:05 -07:00
peter klausler 4f761d601e [flang] Fix clang performance problem with new code
Original-commit: flang-compiler/f18@b70cac3ba8
Reviewed-on: https://github.com/flang-compiler/f18/pull/785
Tree-same-pre-rewrite: false
2019-10-21 14:58:26 -07:00
peter klausler dc4fac5634 [flang] Testing and debugging
Original-commit: flang-compiler/f18@3fa2e55bef
Reviewed-on: https://github.com/flang-compiler/f18/pull/785
Tree-same-pre-rewrite: false
2019-10-21 14:58:25 -07:00
peter klausler 2348d593ae [flang] Add software uint128_t (debugging incomplete)
Original-commit: flang-compiler/f18@5be270e604
Reviewed-on: https://github.com/flang-compiler/f18/pull/785
Tree-same-pre-rewrite: false
2019-10-21 14:58:25 -07:00
peter klausler 9cf827d297 [flang] Pass call04
Original-commit: flang-compiler/f18@5a44837804
Reviewed-on: https://github.com/flang-compiler/f18/pull/783
2019-10-21 12:44:17 -07:00
peter klausler e6bf9526e1 [flang] most call04 checks
Original-commit: flang-compiler/f18@65289a66d1
Reviewed-on: https://github.com/flang-compiler/f18/pull/783
Tree-same-pre-rewrite: false
2019-10-21 12:44:17 -07:00
peter klausler 15f38e2d67 [flang] Use component iterators in check-call.cc
Original-commit: flang-compiler/f18@e78db8907f
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
2019-10-17 15:29:26 -07:00
peter klausler 5f8817bdac [flang] Address remaining initial comments
Original-commit: flang-compiler/f18@acd307c91f
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-17 12:10:33 -07:00
peter klausler db4ae5cd98 [flang] Address most review comments
Original-commit: flang-compiler/f18@43720b5057
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-17 10:57:01 -07:00
peter klausler ca9d6be0e4 [flang] Pad short CHARACTER actual arguments
Original-commit: flang-compiler/f18@b9c890ca9c
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-16 15:36:54 -07:00
peter klausler 4abdc30b63 [flang] Revert to returning default INTEGER for LEN() and offset-in-CHARACTER intrinsics; further shape analysis of intrinsic results
Original-commit: flang-compiler/f18@561f5965b2
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-16 11:53:03 -07:00
peter klausler f090eb878e [flang] Better shape analysis for CSHIFT, EOSHIFT, SPREAD
Original-commit: flang-compiler/f18@eb43df85a6
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-16 10:35:34 -07:00
peter klausler 3a4091b5e3 [flang] Fix some bugs exposed by testing new checks
Original-commit: flang-compiler/f18@9cc70dcad6
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-16 09:39:37 -07:00
peter klausler 4c37c06597 [flang] rebase
Original-commit: flang-compiler/f18@2691da3836
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-11 15:41:11 -07:00
peter klausler b8d4f79d59 [flang] pass call03
Original-commit: flang-compiler/f18@8c076bd89b
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-10 16:36:47 -07:00
peter klausler d022fc1cca [flang] definability tests
Original-commit: flang-compiler/f18@4b71f003a9
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-10 16:33:25 -07:00
peter klausler f29394589e [flang] Move call semantic checking into lib/semantics
Original-commit: flang-compiler/f18@7996c85cf3
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-10 16:23:07 -07:00
peter klausler b71355ca1e [flang] checkpoint
checkpoint

checkpoint

Original-commit: flang-compiler/f18@99d12a7215
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-10 16:09:57 -07:00
Tim Keith 6acae749c8 [flang] Generic name resolution in expression analysis
Implement the basics of resolving generic names in expressions.

`ExpressionAnalyzer::ResolveGeneric` maps the symbol for a generic
name to the specific procedure appropriate for the actual arguments.
Extract `CheckExplicitInterface` out of `CheckArguments` so that it
can be tried for each specific procedure of the generic as part of
the test to see which is compatible.

Note that it may be there is an elemental and non-elemental specific
procedure that is compatible with the actual arguments. In that case
the generic is resolved to the non-elemental one.

Test this by using generic functions in specification expressions
that must be written to module files. Verify how the generics were
resolved by looking at the generated `.mod` files.

There is more work to be done in this area: the passed-object dummy
argument is not considered and in some cases generated module files
are not correct.

Original-commit: flang-compiler/f18@50e458045a
Reviewed-on: https://github.com/flang-compiler/f18/pull/778
2019-10-10 11:46:26 -07:00
peter klausler b32a435b0b [flang] Update preprocessing document, commentary
Extend documentation on preprocessing

IsSimplyContiguous

basic skeleton

Apply suggested improvements to mod-file.cc

Checks for new call13.f90 (15.4.2.2 explicit interfaces)

Implement checking for procedures that can be called via an implicit interface

Argument checking, test fixing

Better argument checking

Better derived type compatibility checking

Treat externals as if implicitly interfaced

Extend IEEE_EXCEPTIONS module so tests still pass with argument checking

SAME_TYPE_AS and EXTENDS_TYPE_OF intrinsic inquiry functions

Define interfaces for most intrinsic subroutines

Better PASS arguments

More with PASS() argument

Prep for review

address comments

fix comment

Remove formatted expression from specification expression error message per review

more review comments

Original-commit: flang-compiler/f18@3cca775da9
Reviewed-on: https://github.com/flang-compiler/f18/pull/776
2019-10-07 11:01:46 -07:00
peter klausler d6c8bd805f [flang] Import preprocessing tests
Original-commit: flang-compiler/f18@7ef7029604
Reviewed-on: https://github.com/flang-compiler/f18/pull/777
2019-10-04 15:21:31 -07:00
peter klausler 78d33b600e [flang] Fix flang-compiler/f18#773
Original-commit: flang-compiler/f18@d12d1129b7
Reviewed-on: https://github.com/flang-compiler/f18/pull/775
2019-10-02 15:42:07 -07:00
peter klausler 9b37989e05 [flang] Final tweaks
Original-commit: flang-compiler/f18@6e269b4e29
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
2019-10-02 16:52:27 -07:00
peter klausler 07d48c0a23 [flang] Extend documentation
Original-commit: flang-compiler/f18@7e11f8165f
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 16:30:36 -07:00
peter klausler e88bf15d2a [flang] Dodge weird clang-format behavior
Original-commit: flang-compiler/f18@48b81a2dd9
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 16:14:01 -07:00
peter klausler 4ee37ac356 [flang] Address review comments
Original-commit: flang-compiler/f18@b2a0503614
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 15:48:20 -07:00
peter klausler 5c35f3288a [flang] Retain no-op default: cases when compiling with gcc
Original-commit: flang-compiler/f18@8ebfd8d2e9
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 14:24:44 -07:00
peter klausler 637b933202 [flang] Enable more warnings, clean them up
Original-commit: flang-compiler/f18@c6b3420e5f
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 12:40:52 -07:00
David Truby e401082289 [flang] Removed stray comma in unparse for dist_schedule clause
Original-commit: flang-compiler/f18@0b61bc22c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/772
2019-10-03 10:59:17 +01:00
David Truby 9aa80d3353 [flang] Make the second argument to dist_schedule optional.
Original-commit: flang-compiler/f18@7ed2d0e3ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/772
Tree-same-pre-rewrite: false
2019-10-02 16:58:11 +01:00
David Truby 56efc1eca2 [flang] Added basic sema checks for distribute construct
Original-commit: flang-compiler/f18@f23059bf30
Reviewed-on: https://github.com/flang-compiler/f18/pull/771
2019-10-02 16:13:32 +01:00
David Truby 98223835c0 [flang] Added comment about gcc function cast workaround.
Original-commit: flang-compiler/f18@28bc021323
Reviewed-on: https://github.com/flang-compiler/f18/pull/767
2019-10-01 11:15:43 +01:00
David Truby c579118ce6 [flang] Replace access through union with reinterpret_cast.
This avoids undefined behaviour.

Original-commit: flang-compiler/f18@e289bbfa83
Reviewed-on: https://github.com/flang-compiler/f18/pull/767
Tree-same-pre-rewrite: false
2019-09-30 12:41:34 +01:00
Eric Schweitz 7d1696b3ad [flang] add initial Burnside bridge code
Original-commit: flang-compiler/f18@0d387d1468
Reviewed-on: https://github.com/flang-compiler/f18/pull/720
2019-10-02 10:54:12 -07:00
Pete Steinfeld 855f817d9d [flang] More semantic checking for DO constructs
This time I'm adding to the checks for constraint C1137, which states
that image control statements cannot appear in a DO CONCURRENT.  The
checks I added test to see if the DO CONCURRENT contains an ALLOCATE or
DEALLOCATE that references a coarray.

Original-commit: flang-compiler/f18@c16b883db3
Reviewed-on: https://github.com/flang-compiler/f18/pull/769
2019-10-01 13:03:40 -07:00
David Truby e0c15c4952 [flang] Added grammar comments for enter data and exit data directives
Original-commit: flang-compiler/f18@a1e6cded2f
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
2019-09-27 13:57:51 +01:00
David Truby 5776003259 [flang] Corrected check for required OpenMP clauses
Original-commit: flang-compiler/f18@ce3ec50c3f
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
Tree-same-pre-rewrite: false
2019-09-27 13:57:51 +01:00
David Truby 7c09d48218 [flang] Corrections for map semantics to match coding style
Original-commit: flang-compiler/f18@f2d97c3a1e
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
Tree-same-pre-rewrite: false
2019-09-27 13:57:51 +01:00
David Truby d3e8c76f67 [flang] Added semantic checks for map clauses
Original-commit: flang-compiler/f18@75b6228388
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
Tree-same-pre-rewrite: false
2019-09-27 13:57:51 +01:00
Eric Schweitz 5c8c0716b4 [flang] sync latest changes to these files
Original-commit: flang-compiler/f18@97becf30fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
2019-09-26 13:08:27 -07:00
Eric Schweitz cca3c31176 [flang] latest changes
Original-commit: flang-compiler/f18@c4278fe1aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-17 14:23:20 -07:00
Eric Schweitz 6bff59ec6b [flang] add FIROps.h
Original-commit: flang-compiler/f18@e53fefb66c
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-10 08:25:34 -07:00
Eric Schweitz d6bfd9135c [flang] fix name of argument
Original-commit: flang-compiler/f18@ad50545941
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-09 16:05:02 -07:00
Eric Schweitz 27e80ffd73 [flang] add attributes
Original-commit: flang-compiler/f18@d35f55b0d5
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-06 16:15:37 -07:00
Eric Schweitz 717cdbd4ac [flang] more cleanup
Original-commit: flang-compiler/f18@23fdcf77d0
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-06 13:37:14 -07:00
Eric Schweitz 38301e7fa0 [flang] changes per review comments
Original-commit: flang-compiler/f18@eb34e2d47b
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-06 13:25:42 -07:00
Eric Schweitz deef31dc7c [flang] add fir types header
Original-commit: flang-compiler/f18@4dc278b271
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-08-28 13:53:50 -07:00
peter klausler 6e7ed4fb4d [flang] Fix flang-compiler/f18#765
Original-commit: flang-compiler/f18@bb2ffac717
Reviewed-on: https://github.com/flang-compiler/f18/pull/766
2019-09-27 14:08:09 -07:00
Pete Steinfeld c3f05ac421 [flang] Added tests for image control statements in DO CONCURRENT
There was already code in check-do.cc to test for the presence of a
variety of different image control statements, but several of them did
not have associated tests.  This change adds tests for most of them.

Also, I removed the check for the END PROGRAM statement, since its
presence causes a syntax error which prevents the semantic check from
ever being reached.

Original-commit: flang-compiler/f18@9cc6f5bd40
Reviewed-on: https://github.com/flang-compiler/f18/pull/764
2019-09-26 13:33:48 -07:00
Tim Keith a3d2966637 [flang] Fix clang build on MacOS
clang doesn't consider `std::strlen` of a constant to be a constexpr,
so just replace with the actual length.

Original-commit: flang-compiler/f18@738deab465
Reviewed-on: https://github.com/flang-compiler/f18/pull/761
2019-09-25 15:39:44 -07:00
David Truby 5efbea87cf [flang] Added grammar for teams directive to semantic checks
Original-commit: flang-compiler/f18@1cee26516b
Reviewed-on: https://github.com/flang-compiler/f18/pull/750
2019-09-19 10:02:35 +01:00
David Truby cad44d2e91 [flang] Semantic checks for teams directive
Original-commit: flang-compiler/f18@ec22e9c4c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/750
Tree-same-pre-rewrite: false
2019-09-17 12:08:04 +01:00
Steve Scalpone fdb58597e8 [flang] Update C++style.md
Original-commit: flang-compiler/f18@d453fdda31
Reviewed-on: https://github.com/flang-compiler/f18/pull/751
2019-09-17 17:07:06 -07:00
Steve Scalpone 3a25e25bd7 [flang] Update C++style.md
Add guidelines for error messages and commas.  Add a version number for clang-format. Add spaces before ### sections to restart numbering.

Original-commit: flang-compiler/f18@3e8db49f34
Reviewed-on: https://github.com/flang-compiler/f18/pull/751
Tree-same-pre-rewrite: false
2019-09-17 12:31:37 -07:00
Tim Keith 3ef61ec226 [flang] Fix tests that use the same .mod file
The tests run by `test_any.sh` don't redirect their .mod files to
a different directory so they occasionally fail when the same file
is accessed by different tests at the same time. With locking of
module files implemented, this problem reproduces much more reliably

Work around it by changing the module names to be distinct. Also remove
some comments left over when copied from `test_symbols.sh` tests.

Original-commit: flang-compiler/f18@f7b5c5f0fc
Reviewed-on: https://github.com/flang-compiler/f18/pull/758
2019-09-25 14:55:40 -07:00
Tim Keith 73c630a4ea [flang] Improve module file reading and writing
Fix problems with writing a mod file while another compilation is
reading or writing. Write to a temp and then rename it:
- compute the new contents of the .mod file
- if it already exists, check if it is already correct
- if not, write new contents to a temp file
- rename the temp to the final destination

`mkstemps()` seems to be the best way to create the temp file.
It returns a file descriptor, so change the rest of the mod file
writing to use POSIX open/read/write/close. This seems to set
errno more reliably too.

There is some extra work around creating the temp to make it have
the same directory and suffix as the final file (so that if one gets
left behind by a crash, "rm *.mod" still cleans it up).
`mkstemps()` creates file with 0600 permissions so try to change it
to what it would have been if we just wrote the file.

Change module file reading to only read the file once; we used to
read it to verify the checksum and then again to parse it.
Instead, change `Parsing` so that we can get the file contents
after `Prescan()` and use that to verify the checksum. Also, it has
a mechanism for searching directories for files, so make use of that
instead of duplicating that functionality in `ModFileReader`.
This requires some changes to how errors are returned so they can
be reported in the right place.

Original-commit: flang-compiler/f18@d0d54971a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/758
Tree-same-pre-rewrite: false
2019-09-25 14:55:40 -07:00
peter klausler 55e241a722 [flang] Fix build on OSX
Original-commit: flang-compiler/f18@453b03af1c
Reviewed-on: https://github.com/flang-compiler/f18/pull/760
2019-09-25 10:40:01 -07:00
peter klausler ccb91afba7 [flang] Address review comments
Original-commit: flang-compiler/f18@2393157d3f
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
2019-09-25 09:04:38 -07:00
peter klausler 9fd72e9393 [flang] Clean up test results
Original-commit: flang-compiler/f18@7d3180160c
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:37 -07:00
peter klausler d8c9b50fd6 [flang] Prep for review
Original-commit: flang-compiler/f18@8be02a41c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:35 -07:00
peter klausler 686baf0b0e [flang] Remove dead code
Original-commit: flang-compiler/f18@4d90aad361
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:33 -07:00
peter klausler 32f2ea0753 [flang] Build with all compilers * versions
Original-commit: flang-compiler/f18@7332caa613
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:31 -07:00
peter klausler fc5d127c1c [flang] Complete conversions, delete old visitor
Original-commit: flang-compiler/f18@6ce1da55c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:30 -07:00
peter klausler f07d6bc6ba [flang] more conversions to Traverse
Original-commit: flang-compiler/f18@e8668e2368
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:29 -07:00
peter klausler 48fd773a19 [flang] Refinements; replace several clients of old Visitor with new Traverse
Original-commit: flang-compiler/f18@0b44a86e31
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:28 -07:00
peter klausler e6e66c022b [flang] Redo IsInitialDataTarget
Original-commit: flang-compiler/f18@988c38e1f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:27 -07:00
peter klausler 0bc6d134a6 [flang] Repackaging; tests pass
Original-commit: flang-compiler/f18@1fa7bb7717
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:26 -07:00
peter klausler c36f7d916a [flang] progress
Original-commit: flang-compiler/f18@b5e3e709cb
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:24 -07:00
peter klausler 8d8e1c4604 [flang] add test
Original-commit: flang-compiler/f18@ad2fa9dfdf
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:23 -07:00
peter klausler 9016b1d6a8 [flang] checkpoint
Original-commit: flang-compiler/f18@96ade8e6e9
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:22 -07:00
peter klausler e9dda4f0f5 [flang] checkpoint
Original-commit: flang-compiler/f18@782f44fe7d
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:20 -07:00
Pete Steinfeld ea1cf9ee0b [flang] More responses to pull request comments.
Original-commit: flang-compiler/f18@0fb4cf1c9b
Reviewed-on: https://github.com/flang-compiler/f18/pull/756
2019-09-24 15:33:51 -07:00
Pete Steinfeld 33b208e487 [flang] More responses to comments in the pull request. The big change was to
implement an enum class to indicate whether the statement being checked
is a CYCLE or EXIT statement.  This change rippled through a few
interfaces, resulting in cleaner, more readable code.  Thanks for the
tip, Tim!

Original-commit: flang-compiler/f18@e167c3d39f
Reviewed-on: https://github.com/flang-compiler/f18/pull/756
Tree-same-pre-rewrite: false
2019-09-24 10:44:44 -07:00
Pete Steinfeld e0eee884b2 [flang] Responses to a comments in my previous pull request.
Original-commit: flang-compiler/f18@e0d73a45ac
Reviewed-on: https://github.com/flang-compiler/f18/pull/756
Tree-same-pre-rewrite: false
2019-09-23 20:49:55 -07:00
Pete Steinfeld ab12314514 [flang] Implementation of semantic checks C1135, C1167, and C1168
These constraints state that CYCLE and EXIT statements should not leave DO
CONCURRENT, CRITICAL, or CHANGE TEAM constructs.

I added checking code to check-do.cc and removed some superseded code from
check-do.cc and semantics.cc.  The new code uses the construct stack
implemented in my previous pull request.

I also added a new test -- dosemantics11.f90 and modified the tests
dosemantics10.f90, doconcurrent05.f90, and doconcurrent06.f90 to adapt to
the new error messages.  I converted these latter two tests to use
test_error.sh since they only reported errors.

Original-commit: flang-compiler/f18@b0bea7da64
Reviewed-on: https://github.com/flang-compiler/f18/pull/756
Tree-same-pre-rewrite: false
2019-09-23 20:49:55 -07:00
Jean Perier cd15ba5360 [flang] Fix typos and style in some comments
Original-commit: flang-compiler/f18@621ded353f
Reviewed-on: https://github.com/flang-compiler/f18/pull/749
2019-09-18 08:04:52 -07:00
Jean Perier 00c02c469c [flang] Refactor IntrinsicProcTable::Implementation::Probe for readability
Original-commit: flang-compiler/f18@4a7211e42b
Reviewed-on: https://github.com/flang-compiler/f18/pull/749
Tree-same-pre-rewrite: false
2019-09-18 05:15:56 -07:00
Jean Perier 9a01a4915e [flang] Address editorial comments and use oxford comma
Original-commit: flang-compiler/f18@88a8d1be03
Reviewed-on: https://github.com/flang-compiler/f18/pull/749
Tree-same-pre-rewrite: false
2019-09-17 01:54:51 -07:00
Jean Perier d8fc41f612 [flang] Allow more argument types in some specific intrinsic
Fix flang-compiler/f18#724.
Allow all type kinds for arguments in restricted specific conversion
intrinisc (no warning, this is ubiquitous).
Allow MAX/MIN restricted intrinsic (AMAX0...) to be replaced by the
related generic foolowed by a type conversion to the expected result
type of the specific. Emit a warning because xlf and ifort are doing so
but pgfortran is converting the arguments instead.

Original-commit: flang-compiler/f18@c07adb94ed
Reviewed-on: https://github.com/flang-compiler/f18/pull/749
Tree-same-pre-rewrite: false
2019-09-16 09:34:10 -07:00
Tim Keith 493a135a56 [flang] Handle alternative names for relational operators
10.1.6.2 says:
> The operators <, <=, >, >=, ==, and /= always have the same interpretations
> as the operators .LT., .LE., .GT., .GE., .EQ., and .NE., respectively.
That means we have to treat `operator(<)` like `operator(.lt.)`,
for example. `<>` is a third alias for `.NE.`.

We can't just choose always to use one form (e.g. replacing `operator(.lt.)`
with `operator(<)`). This is because all symbols names are `CharBlock`s
referring to the cooked character stream so that they have proper source
provenance. Also, if a user prefers one style and uses it consistently,
that's the form they should see in messages.

So the fix is to use whatever form is found in the source, but also to
look up symbols by the other names when necessary. To assist this, add
`GenericSpecInfo::GetAllNames()` to return all of the names of a generic
spec. Each place a generic spec can occur we have to use these to look
for the symbol.

Also reorganize the `AddUse()` overloads to work with this change.

Fixes flang-compiler/f18#746.

Original-commit: flang-compiler/f18@7f06f175d5
Reviewed-on: https://github.com/flang-compiler/f18/pull/752
2019-09-19 15:18:33 -07:00
Tim Keith b506f39f18 [flang] Clean up temp dirs
A temp directory is created in `common.sh` and it is cleaned up by
`trap ... EXIT`. If the test script has its own trap, as this one does,
it seems to replace the first one. So the cleanup from `common.sh` was
not being executed when the `%t` feature was used and empty temp
directories were being left in the directory where the tests ran.

Since we already have a temp directory that is cleaned up, just use
that for `%t` and don't bother with another `mktemp`.

Original-commit: flang-compiler/f18@f61d62ddec
Reviewed-on: https://github.com/flang-compiler/f18/pull/754
2019-09-18 13:17:48 -07:00
Jinxin Yang bb1127efb6 [flang] [OpenMP] Simplify `OmpObject` with `std::variant`
Instead of using an `ENUM_CLASS Kind` to distinguish a `Designator`
or common-block name, change it to `std::variant`. If the `Name`
is available, then it is common-block name.

Original-commit: flang-compiler/f18@abf5db6171
2019-09-18 15:46:20 -07:00
Jean Perier ba89315523 [flang] Address comment: make error a warning instead and ignore RESULT
Instead of emitting an error when RESULT has the same name as the
function, emit a warning and ignore RESULT in the rest of the
compilation.

Original-commit: flang-compiler/f18@8ce3862d39
Reviewed-on: https://github.com/flang-compiler/f18/pull/743
2019-09-16 03:36:12 -07:00
Jean Perier ca86308453 [flang] Prevent RESULT name from being the same as the function.
Fix flang-compiler/f18#726.
Add test and error messsage for such scenario and set error on the
result symbol because it is unclear what it is inside the function.

Original-commit: flang-compiler/f18@a3d5b5af0d
Reviewed-on: https://github.com/flang-compiler/f18/pull/743
Tree-same-pre-rewrite: false
2019-09-13 09:44:05 -07:00
Tim Keith a29678ddb6 [flang] Fix bugs with use-associated derived type with rename
When a derived type is use-associated with a rename, like
`use m, only: t2 => t1`
we need to record in the `DerivedTypeSpec` both the local-name in this
scope and the symbol for the derived type.

In most cases we need to work the the type symbol and its
`DerivedTypeDetails`, but when writing the type to the module file
we need the local-name. The name of the type symbol may be hidden
or not use-associated.

When analyzing a `parser::Name` we don't want to follow use-associations
because we could end up with the wrong name in a `DataRef` (i.e. the
use-name rather than the local-name). But that means that
`GetNamedConstantValue()` does have to follow them or named constants
won't always be folded.

Fixes flang-compiler/f18#729.

Original-commit: flang-compiler/f18@50d8921c69
Reviewed-on: https://github.com/flang-compiler/f18/pull/740
2019-09-16 07:54:27 -07:00
Tim Keith 0b86ab186d [flang] Fix renames in module files
When a module contains a use-association with rename, we have to be
careful to use the correct name (i.e. the local-name, not the use-name)
when writing out its `.mod` file.

When analyzing a `Name` in an expression, follow the use-association
for details, attributes, and constant values; but if we need to make a
`Designator` or `ProcedureDesignator`, use the local name.

Original-commit: flang-compiler/f18@8f07b803e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/740
Tree-same-pre-rewrite: false
2019-09-16 07:54:27 -07:00
Tim Keith ce8b500d57 [flang] Refactoring
Eliminate two of the three overloadings of `Scope::MakeDerivedType()`.
Keep the one that has `Category` first because that's the order the
constructor of `DeclTypeSpec` uses.

In `mod-file.cc`, eliminate some calls to `PutLower()`. Symbols and
names are already lower case so they don't need to be converted.

In `modfile03.f90`, move the expected `.mod` file comments to right
after the corresponding modules. That makes it easier to work with.

Original-commit: flang-compiler/f18@86874d9bf8
Reviewed-on: https://github.com/flang-compiler/f18/pull/740
Tree-same-pre-rewrite: false
2019-09-16 07:54:27 -07:00
Tim Keith 4fde74a1c8 [flang] Address review comment
Original-commit: flang-compiler/f18@134190f75e
Reviewed-on: https://github.com/flang-compiler/f18/pull/741
2019-09-13 14:39:40 -07:00
Tim Keith f13cf9f0ed [flang] Better handling of merged generics
If a generic name is use-associated from two different modules and they
both have a specific procedure or both have a derived type with the same
name, report it as an error.

Original-commit: flang-compiler/f18@42369af96d
Reviewed-on: https://github.com/flang-compiler/f18/pull/741
Tree-same-pre-rewrite: false
2019-09-13 14:27:33 -07:00
Tim Keith d43405e4e6 [flang] Fix bug merging generics on USE
When we use-associate the same generic name from two different modules
they are merged together. If the same specific procedure occurs in both
generics it should only occur once in the merged one.

Similarly, it's not an error if they both have a derived type or
specific procedure named the same as the generic, as long as they are
the same symbol.

Fixes flang-compiler/f18#733.

Original-commit: flang-compiler/f18@d37db07691
Reviewed-on: https://github.com/flang-compiler/f18/pull/741
Tree-same-pre-rewrite: false
2019-09-12 17:38:40 -07:00
David Truby da26e76078 [flang] Changed missing tofrom:scalar error message to be more descriptive
Original-commit: flang-compiler/f18@18e0a55a02
Reviewed-on: https://github.com/flang-compiler/f18/pull/719
2019-09-11 11:23:36 +01:00
David Truby 9527a18816 [flang] Added tofrom:scalar check for defaultmap clause
Original-commit: flang-compiler/f18@1025649b64
Reviewed-on: https://github.com/flang-compiler/f18/pull/719
Tree-same-pre-rewrite: false
2019-09-10 14:04:03 +01:00
David Truby 4b30ecf11c [flang] Semantic checks for target construct
Original-commit: flang-compiler/f18@373391bc03
Reviewed-on: https://github.com/flang-compiler/f18/pull/719
Tree-same-pre-rewrite: false
2019-09-10 13:49:24 +01:00
peter klausler 1c10d963aa [flang] Remove periods from the ends of messages, per review comment
Original-commit: flang-compiler/f18@0ce32de0d6
Reviewed-on: https://github.com/flang-compiler/f18/pull/745
2019-09-13 13:57:35 -07:00
peter klausler 9c3a9375be [flang] Implement checks for test/semantics/call02.f90
Original-commit: flang-compiler/f18@38eaaa72ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/745
Tree-same-pre-rewrite: false
2019-09-13 12:32:43 -07:00
Jinxin Yang 5676797c2a [flang] Improve flag dumping for -funparse-with-symbols
Original-commit: flang-compiler/f18@768fb1b369
2019-09-13 12:39:27 -07:00
peter klausler f2917c777b [flang] Do not emit a bogus exponent (0.e-1)
Original-commit: flang-compiler/f18@3d0b13d7ed
Reviewed-on: https://github.com/flang-compiler/f18/pull/736
2019-09-12 10:28:16 -07:00
peter klausler 8fc7824feb [flang] tweak test results
Original-commit: flang-compiler/f18@360c6717e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/738
2019-09-12 09:40:29 -07:00
peter klausler 988749e8f3 [flang] Fix bug flang-compiler/f18#735
Original-commit: flang-compiler/f18@dccb16d492
Reviewed-on: https://github.com/flang-compiler/f18/pull/738
Tree-same-pre-rewrite: false
2019-09-12 09:40:28 -07:00
peter klausler c93ceeeef7 [flang] Improve error message (add types)
Original-commit: flang-compiler/f18@48b8f32d51
Reviewed-on: https://github.com/flang-compiler/f18/pull/738
Tree-same-pre-rewrite: false
2019-09-12 09:40:27 -07:00
Jean Perier 48659b1eb0 [flang] Add NEW_LINE intrinsic to the intrinsic table
NEW_LINE intrinsic folding was already implemented but it had not
yet been added the the intrinsic table and was therefore not yet
recognised an intrinsic.
Add related tests.

Original-commit: flang-compiler/f18@42fcf5b5f1
Reviewed-on: https://github.com/flang-compiler/f18/pull/734
2019-09-11 03:01:55 -07:00
peter klausler bd2bf58e7a [flang] Extend comments
Original-commit: flang-compiler/f18@9f918c2559
Reviewed-on: https://github.com/flang-compiler/f18/pull/737
2019-09-11 13:15:32 -07:00
peter klausler 62e4acf232 [flang] Allow module, submodule, and program names to be used as local identifiers. Check for USE of m in m.
Original-commit: flang-compiler/f18@9abfd9e450
Reviewed-on: https://github.com/flang-compiler/f18/pull/737
Tree-same-pre-rewrite: false
2019-09-11 12:30:24 -07:00
Tin Huynh 2e1807998c [flang] Using new Prov to Cooked mappings for get-definition.
Original-commit: flang-compiler/f18@5a42c5c9e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/698
2019-09-10 17:55:59 -07:00
Tin Huynh 69fd49a002 [flang] FindOffsetLineAndColumn also uses SourcePosition.
New tests for COMMON and BLOCK.
Added CHECK-ONCE to test_any.sh. Make sure pattern only occurs once.

Original-commit: flang-compiler/f18@ad82dafcf9
Reviewed-on: https://github.com/flang-compiler/f18/pull/698
Tree-same-pre-rewrite: false
2019-09-10 17:55:59 -07:00
Tin Huynh 2f205a5f52 [flang] Added -fget-definitions and -fget-all-symbols.
- -fget-definitions finds the definition of the symbol under specified source
position.
- -fget-all-symbols finds definition locations of all symbols in a document. For
symbols found in other modules, shows which module the symbol came from.
- Tests.
- New structure SourcePosition with file, line, column information.

Original-commit: flang-compiler/f18@e0099b0900
Reviewed-on: https://github.com/flang-compiler/f18/pull/698
Tree-same-pre-rewrite: false
2019-09-10 17:55:59 -07:00
peter klausler f9ed573b1d [flang] Recover better from syntax errors on USE statements
Original-commit: flang-compiler/f18@29968698d9
Reviewed-on: https://github.com/flang-compiler/f18/pull/731
2019-09-10 15:29:55 -07:00
peter klausler 67eb35d970 [flang] Address review comment
Original-commit: flang-compiler/f18@65dc8d4996
Reviewed-on: https://github.com/flang-compiler/f18/pull/732
2019-09-10 17:08:18 -07:00
peter klausler 9db810f5e3 [flang] Add static declaration checker; get call01.f90 to pass
Original-commit: flang-compiler/f18@7cc5bc7617
Reviewed-on: https://github.com/flang-compiler/f18/pull/732
Tree-same-pre-rewrite: false
2019-09-10 15:53:23 -07:00
peter klausler 2ae26b8501 [flang] Check recursive calls for NON_RECURSIVE and assumed-length CHARACTER(*)
Original-commit: flang-compiler/f18@92777f8f66
Reviewed-on: https://github.com/flang-compiler/f18/pull/732
Tree-same-pre-rewrite: false
2019-09-10 15:53:22 -07:00
peter klausler 34f07e50c0 [flang] commit to switch branches
Some groundwork

Original-commit: flang-compiler/f18@64ebeb511c
Reviewed-on: https://github.com/flang-compiler/f18/pull/732
Tree-same-pre-rewrite: false
2019-09-10 15:53:17 -07:00
Pete Steinfeld 97d7b398e4 [flang] Combined the implementations to ```Pre()``` and ```Post()``` functions that
call `PushConstruct()``` and ```PopConstruct()``` following a genius
suggestion from Peter.

Original-commit: flang-compiler/f18@be2a03ebf4
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
2019-09-10 14:45:02 -07:00
Pete Steinfeld 74112759c3 [flang] Changed ```PushConstruct()``` to be a template, which moves the implicit
creation of the ```ConstructNode``` into ```PushConstruct()```.

Original-commit: flang-compiler/f18@3984566858
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
Tree-same-pre-rewrite: false
2019-09-10 14:45:02 -07:00
Pete Steinfeld 9cc2f8300b [flang] Responses to review comments
I changed the interface of ```PushConstruct()``` to take an rvalue reference as its only parameter and made the construction of the ```ConstructNode```s explicit in all of the ```Pre()``` functions for the various construct types.

Original-commit: flang-compiler/f18@f8be813874
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
Tree-same-pre-rewrite: false
2019-09-10 14:45:02 -07:00
Pete Steinfeld eedbe90e72 [flang] Responses to review comments and team meeting
The most significant change is that I replaced the stack of
ExecutableConstruct's with a stack composed of ConstructNode's, each of which
is a variant of the constructs that made up the type ExecutableConstruct.  This
change allows the nodes of the stack to be extended to include the types needed
for OMP semantic checking.

I also extended the existing test to include some correct DO loops with CYCLE
and EXIT statements to test the code more completely.

Original-commit: flang-compiler/f18@d26f34e3a4
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
Tree-same-pre-rewrite: false
2019-09-10 14:45:02 -07:00
Pete Steinfeld 73ef31b164 [flang] Changes to add an executable construct stack
I added a stack of ExecutableConstruct's to SemanticsContext along with
functions to push and pop constructs.  I added code to the SemanticsVisitor
to use these new functions.  I also added functions Pre and Post functions
for UnlabeledStatement's so that we could isolate the source positions for
statements embedded in "if" statements to improve error messages.

I also added code to check-do.[h,cc] to use this new infrastructure to check
for CYCLE and EXIT statements that are not contained within DO constructs
along with a test.

Original-commit: flang-compiler/f18@b8370bdeb8
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
Tree-same-pre-rewrite: false
2019-09-10 14:45:02 -07:00
Pete Steinfeld f8cfc7cdf9 [flang] Fixed the declarations of IEEE_SUPPORT_FLAG and IEEE_SUPPORT_HALTING to
be functions rather than subroutines.  Note that Table 17.3 in the
standard summarizes the contents of IEEE_EXCEPTIONS with the details
specified in section 17.11.

Original-commit: flang-compiler/f18@fca58d479d
Reviewed-on: https://github.com/flang-compiler/f18/pull/730
2019-09-10 12:43:16 -07:00
Steve Scalpone 654a86a277 [flang] Update comment to reflect that STORAGE_SIZE is implemented.
Original-commit: flang-compiler/f18@3c2431bbf8
Reviewed-on: https://github.com/flang-compiler/f18/pull/723
2019-09-10 08:37:08 -07:00
Steve Scalpone c1c83477ed [flang] Add storage_size intrinsic.
Original-commit: flang-compiler/f18@bcde26a7c1
Reviewed-on: https://github.com/flang-compiler/f18/pull/723
Tree-same-pre-rewrite: false
2019-09-09 14:33:04 -07:00
Jean Perier 45820f4caa [flang] address comment: add ',' for better formatting
Original-commit: flang-compiler/f18@0c85499985
Reviewed-on: https://github.com/flang-compiler/f18/pull/699
2019-09-10 04:11:19 -07:00
Jean Perier 1343cf78f3 [flang] Implement folding of x**y where y is real or complex
This was a TODO. The implementation uses the host runtime
function pow, either from libm or libpgmath.

Original-commit: flang-compiler/f18@ee58112112
Reviewed-on: https://github.com/flang-compiler/f18/pull/699
Tree-same-pre-rewrite: false
2019-08-30 08:08:08 -07:00
Steve Scalpone 02a9cdb3fd [flang] Define iso_fortran_env error_unit.
Provisionally use a value of 0 to match PGI.

Original-commit: flang-compiler/f18@ec7f0a0968
Reviewed-on: https://github.com/flang-compiler/f18/pull/722
2019-09-09 12:57:10 -07:00
peter klausler de974041da [flang] Fix expected error messages in tests to correspond with recent update to compiler
Original-commit: flang-compiler/f18@95202dd313
Reviewed-on: https://github.com/flang-compiler/f18/pull/721
2019-09-09 11:40:31 -07:00
peter klausler bf6ba0ff18 [flang] Fix some Fortran and use existing messages for errors already caught.
Original-commit: flang-compiler/f18@2d360e78ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
2019-09-09 10:43:19 -07:00
peter klausler 9dee00eccc [flang] Finish test/semantics/call12.f90
Original-commit: flang-compiler/f18@d002f0ce37
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:28 -07:00
peter klausler 99757783d2 [flang] Fix Fortran in call10.f90
Original-commit: flang-compiler/f18@8154a24232
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:28 -07:00
peter klausler 5ea5fe9b1e [flang] More tests
Original-commit: flang-compiler/f18@bd5e95e40c
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:28 -07:00
peter klausler c19c1e5abd [flang] More tests
Original-commit: flang-compiler/f18@52e3b74f4e
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:28 -07:00
peter klausler 7f52d94bf3 [flang] call09.f90 and review comment
Original-commit: flang-compiler/f18@bc2ac270c6
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:27 -07:00
peter klausler c3d35afd87 [flang] call08.f90
Original-commit: flang-compiler/f18@2bda489d45
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:27 -07:00
peter klausler c74f40f46e [flang] call07.f90
Original-commit: flang-compiler/f18@a92307c3d6
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:27 -07:00
peter klausler 7ffe10c1fb [flang] call06.f90
Original-commit: flang-compiler/f18@81b64dacaa
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:26 -07:00
peter klausler 0e1259db7a [flang] Add call04.f90 test
Original-commit: flang-compiler/f18@0b329380cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:26 -07:00
peter klausler 8068d016db [flang] First three tests
Original-commit: flang-compiler/f18@600b5263b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:26 -07:00
peter klausler 0208a7d400 [flang] Remove needless include
Original-commit: flang-compiler/f18@5d2afd0ad3
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
2019-09-09 10:26:30 -07:00
peter klausler be799e4300 [flang] Check for having compiled the inverted map before using it
Original-commit: flang-compiler/f18@cef90ee11e
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
Tree-same-pre-rewrite: false
2019-09-09 09:26:37 -07:00
peter klausler 73329265ff [flang] Implement provenance -> CharBlock map
Original-commit: flang-compiler/f18@f2e7b6cd72
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
Tree-same-pre-rewrite: false
2019-09-09 09:26:36 -07:00
peter klausler fa3410d5fb [flang] Clean out some dead code, improve naming & comments
Original-commit: flang-compiler/f18@3495555565
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
Tree-same-pre-rewrite: false
2019-09-09 09:26:36 -07:00
Jinxin Yang db25a52fe7 [flang] [OpenMP] formalize `DEFAULTMAP` clause
OpenMP 4.5 only accepts `defaultmap(tofrom:scalar)`. The original implementation
only parses the entire `tofrom:scalar` string and does nothing else. This commit
makes it treat `tofrom` (`ImplicitBehavior`) and `scalar` (`VariableCategory`)
separately, which is clear and extendable for OpenMP 5.0 Spec.

Original-commit: flang-compiler/f18@12074dcd2c
2019-09-09 09:41:04 -07:00
peter klausler e665f1d7d1 [flang] More writing
Original-commit: flang-compiler/f18@8dce9cb7f0
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
2019-09-09 09:28:23 -07:00
peter klausler a56e5f0615 [flang] edits
Original-commit: flang-compiler/f18@ff3cab0bb5
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:28:23 -07:00
peter klausler dca31ebe93 [flang] More edits
Original-commit: flang-compiler/f18@6b9ce52250
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:28:22 -07:00
peter klausler e73a1d287a [flang] edits
Original-commit: flang-compiler/f18@07da944e4b
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:27:38 -07:00
peter klausler f0778f0fe2 [flang] edits
Original-commit: flang-compiler/f18@729cc19e0f
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:27:38 -07:00
peter klausler 28e8f7a9fd [flang] Jot down thoughts on array expr and intrinsic evaluation for Jean
Original-commit: flang-compiler/f18@83c72062d5
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:27:37 -07:00
peter klausler 7f9922203f [flang] Review comments
Original-commit: flang-compiler/f18@376359d456
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
2019-09-04 10:44:49 -07:00
peter klausler 9469ce8aeb [flang] refinements
Original-commit: flang-compiler/f18@a4de8161f9
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-29 12:45:42 -07:00
peter klausler 321fcad0a9 [flang] address review comments
Original-commit: flang-compiler/f18@793c15fd04
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-29 10:58:36 -07:00
peter klausler 76337eb4cb [flang] Simplify by using the term F77ish
Original-commit: flang-compiler/f18@063d9dc6c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-28 13:59:48 -07:00
peter klausler f4f44b90f0 [flang] Limitations on function results with assumed type parameters
Original-commit: flang-compiler/f18@4ba9fdb0ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-28 11:54:19 -07:00
peter klausler a26bbed6d6 [flang] Corrections and additions
Original-commit: flang-compiler/f18@000301fcf9
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-28 11:25:55 -07:00
peter klausler c71ba62c9f [flang] Correct obsolete comment in descriptor.h
Original-commit: flang-compiler/f18@8ff52c493a
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-28 09:14:46 -07:00
peter klausler c236c83775 [flang] Resolve some TODOs
Original-commit: flang-compiler/f18@3f3e9c9320
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-27 15:59:46 -07:00
peter klausler c6041dfecf [flang] Enumerate semantics checks
Original-commit: flang-compiler/f18@3ddf31109a
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-27 14:27:14 -07:00
peter klausler 6d7fef5cd0 [flang] More research
Original-commit: flang-compiler/f18@1e2b0be07f
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-27 13:09:31 -07:00
peter klausler fe7ea5325f [flang] Address some review comments
Original-commit: flang-compiler/f18@5666998b0f
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-27 10:15:31 -07:00
peter klausler a000beae71 [flang] fix typo, add examples
Original-commit: flang-compiler/f18@e0964fe076
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-26 15:56:08 -07:00
peter klausler e9c6ab3615 [flang] refine naming
Original-commit: flang-compiler/f18@a4888a08cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-26 15:44:38 -07:00
peter klausler 1e90c6b948 [flang] naming
Original-commit: flang-compiler/f18@c3673287f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-26 14:23:35 -07:00
peter klausler 0c3a942422 [flang] trampolines
Original-commit: flang-compiler/f18@3e9cebe8dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-26 12:41:10 -07:00
peter klausler 311300b15d [flang] more writing
Original-commit: flang-compiler/f18@16a8b0065a
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-23 15:35:18 -07:00
peter klausler d732d10b80 [flang] more writing
Original-commit: flang-compiler/f18@a067cca183
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-23 15:22:53 -07:00
peter klausler 700448d39c [flang] More writing
Original-commit: flang-compiler/f18@f475086c0c
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-23 14:35:38 -07:00
peter klausler 9dcbed4735 [flang] Extract Calls.md into its own branch.
Original-commit: flang-compiler/f18@8a5a2c99dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-23 13:42:13 -07:00
Jinxin Yang d7443b5ad2 [flang] Add missing include for unordered_map
Original-commit: flang-compiler/f18@a9aadfb607
2019-09-05 14:34:44 -07:00
Jinxin Yang bc52fc1922 [flang] [OpenMP] extend `IF` clause to accept modifier on composite/combined constructs
Original-commit: flang-compiler/f18@03302a1546
2019-09-05 13:35:21 -07:00
Jinxin Yang 5c543da53a [flang] [OpenMP] add structural checks for `TASKLOOP SIMD`
Original-commit: flang-compiler/f18@21b4dde276
2019-09-05 13:35:21 -07:00
Jinxin Yang d1bbccf1d5 [flang] [OpenMP] update `declare simd` directive with exclusive set
Original-commit: flang-compiler/f18@dc1bd8edc6
2019-09-05 13:35:21 -07:00
Jinxin Yang e902c1d6b7 [flang] [OpenMP] enable check for `IF` clause modifier
Original-commit: flang-compiler/f18@f56fe4a389
2019-09-05 13:35:21 -07:00
Jinxin Yang c4fa8b867e [flang] [OpenMP] Add structural checks for `TASK`
1. fix `OmpIfClause` on `Task`
2. add structural checks

Original-commit: flang-compiler/f18@a77830a191
2019-09-05 13:35:21 -07:00
Jinxin Yang 77ed1df8a7 [flang] [OpenMP] fix type for `Final` clause
The type should be `ScalarLogicalExpr`.

Original-commit: flang-compiler/f18@97e4282d7c
2019-09-05 13:35:21 -07:00
Jinxin Yang 658cf65249 [flang] [OpenMP] Expand full sets for `do`, `simd`, and `do simd`
Original-commit: flang-compiler/f18@1f5bbeb3ea
2019-09-05 13:35:21 -07:00
David Truby f1212c6606 [flang] Implement semantic checking for TASKLOOP
Original-commit: flang-compiler/f18@a8e65f2c2d
Reviewed-on: https://github.com/flang-compiler/f18/pull/688
2019-09-03 17:17:22 +01:00
Tim Keith cc07c43a84 [flang] Name resolution for Cray pointers
Resolve the pointer and pointee names in a `BasedPointerStmt` and
enforce some of the constraints on them. There are still some
constraints to be implemented, mainly about what kind of attributes
the pointers and pointees can have.

The rules for these are a little vague. I mostly followed
- Cray Fortran Reference Manual section 9.3.2
- https://gcc.gnu.org/onlinedocs/gfortran/Cray-pointers.html
- VSI Fortran for OpenVMS Language Reference Manual section B.11

Note that the first two use the term "Cray pointer" but the last does
not. That is confusing because you have to know from context whether
it is referring to Cray pointers or Fortran pointers, so I used
"Cray pointer" and "Cray pointee" in error messages to refer to the
two names in the pointer statement.

Original-commit: flang-compiler/f18@cabb112be2
Reviewed-on: https://github.com/flang-compiler/f18/pull/697
2019-09-04 16:55:08 -07:00
Tim Keith 9f49ffb94f [flang] Fix declaration of module procedure subprograms
Names of subprograms declared with MODULE PROCEDURE in a submodule
were not found correctly. The fix is to separate the handling of
these from other subprograms. The subprogram being defined must have
been declared in the same module or an ancestor module/submodule.

Fixes flang-compiler/f18#709

Original-commit: flang-compiler/f18@80b635d343
Reviewed-on: https://github.com/flang-compiler/f18/pull/710
2019-09-04 15:15:57 -07:00
Steve Scalpone 689e6ee7b6 [flang] Fold more cases of cmplx and dcmplx.
Original-commit: flang-compiler/f18@57401319b0
Reviewed-on: https://github.com/flang-compiler/f18/pull/706
2019-09-02 15:02:46 -07:00
Steve Scalpone 93aa7a8640 [flang] Add support and documentation for DREAL.
Original-commit: flang-compiler/f18@5b6a2dc26c
Reviewed-on: https://github.com/flang-compiler/f18/pull/705
2019-09-02 13:54:01 -07:00
Steve Scalpone d33a5652a8 [flang] Update OpenMP-semantics.md
Formatting changes.

Original-commit: flang-compiler/f18@007b3e31d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/692
2019-08-30 11:22:13 -07:00
Steve Scalpone 67a5f04be8 [flang] Update OpenMP-semantics.md
Item 4 can be removed since we decided to keep the code in Semantics.

Original-commit: flang-compiler/f18@7377a61345
Reviewed-on: https://github.com/flang-compiler/f18/pull/692
Tree-same-pre-rewrite: false
2019-08-29 12:55:41 -07:00
Steve Scalpone 12c9b9429b [flang] Update OpenMP-semantics.md
Repond to review comments about grammar and formatting.

Original-commit: flang-compiler/f18@4811ea2b94
Reviewed-on: https://github.com/flang-compiler/f18/pull/692
Tree-same-pre-rewrite: false
2019-08-27 18:12:50 -07:00
Steve Scalpone 6e4c8b88c5 [flang] Create OpenMP-semantics.md
Initial markdown document.

Original-commit: flang-compiler/f18@787a0ca058
Reviewed-on: https://github.com/flang-compiler/f18/pull/692
Tree-same-pre-rewrite: false
2019-08-27 14:38:48 -07:00
Jinxin Yang 23a7f38741 [flang] [OpenMP] flang-compiler/f18#691 Update on Tim and Varun's review
Change CheckMatching to return `beginDir`, which hides the unnecessary
`std::get<>` for `endDir`.

Original-commit: flang-compiler/f18@d9689e10f4
2019-08-29 10:19:36 -07:00
Jinxin Yang f6273d7194 [flang] [OpenMP] structural checks for `PARALLEL SECTIONS`
Original-commit: flang-compiler/f18@c18452159d
2019-08-29 10:19:36 -07:00
Jinxin Yang ffb88549cb [flang] [OpenMP] add Begin and End Directive matching check
Straightforward check for Begin and End directive of:
1. Block related constructs
2. Loop related constructs (End directive is optional)
3. Sections related constructs

Original-commit: flang-compiler/f18@d0436f13ee
2019-08-29 10:19:36 -07:00
Jinxin Yang 0a85616b07 [flang] [OpenMP] update validity check for `OmpNowait`.
Because now we set the flag for `End` directives that accept clauses,
no need to check the specific directives anymore.

Original-commit: flang-compiler/f18@a5cdc4b035
2019-08-29 10:19:36 -07:00
Jean Perier 296b0d9374 [flang] Remove unused function after last commit
Original-commit: flang-compiler/f18@029fbf64c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
2019-08-28 05:50:23 -07:00
Jean Perier d93f493438 [flang] Address comment: store current enum value in an int
During enumerator name resolution, instead of keeping the current
enumerator value inside an expression, fold it to an int and keep
it as an int. This is clearer and will be easier if one wants to
provide some enum type size optimization.

Original-commit: flang-compiler/f18@4e49d5396c
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
Tree-same-pre-rewrite: false
2019-08-28 04:58:38 -07:00
Jean Perier 93aefc3940 [flang] Address comments: Update comments
Original-commit: flang-compiler/f18@6308613244
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
Tree-same-pre-rewrite: false
2019-08-28 03:35:40 -07:00
Jean Perier f23200963f [flang] Simplify name resolution visitor for parser::Enumerator
Do not define a Pre and a Post, simply walk the expression
with Walk in Pre to resolve the names inside the expression
before evaluating it.

Original-commit: flang-compiler/f18@b0e3c1691e
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
Tree-same-pre-rewrite: false
2019-08-27 07:14:51 -07:00
Jean Perier e3b5330fda [flang] Introduce IsNamedConstant to hide attr::PARAMETER details
for named constant that are actually enumerators.

Original-commit: flang-compiler/f18@d9c4888b72
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
Tree-same-pre-rewrite: false
2019-08-27 07:14:51 -07:00
Tim Keith 396a659413 [flang] Resolve index in pointer assignment to array element
When the LHS of a pointer assignment is an array element, the
index must be resolved.

Fixed flang-compiler/f18#684.

Original-commit: flang-compiler/f18@c39c7872d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/687
2019-08-26 17:37:52 -07:00
Kiran Chandramohan 911cb63719 [flang] Fix for segfault in invalid proc interface message
The segfault happened due to a missing argument.

Original-commit: flang-compiler/f18@8a4f49e86d
Reviewed-on: https://github.com/flang-compiler/f18/pull/693
2019-08-27 23:28:15 +01:00
peter klausler 142fed87c1 [flang] Clean up omp_lib.h
Original-commit: flang-compiler/f18@7119cd0534
Reviewed-on: https://github.com/flang-compiler/f18/pull/690
2019-08-27 11:17:43 -07:00
peter klausler 9d5d73aa77 [flang] Reformat omp_lib.h
Original-commit: flang-compiler/f18@892d91b161
Reviewed-on: https://github.com/flang-compiler/f18/pull/690
Tree-same-pre-rewrite: false
2019-08-27 09:28:30 -07:00
Steve Scalpone 5c62bfb4f8 [flang] Implement int_ptr_kind.
Split omp_lib.F90 into two files: a Fortran file used to
create the omp_lib module and a .h file that can be used
directly, which apparently some codes do. Because of the
split, and wanting to avoid forcing use isc_c_binding,
use int_ptr_kind()  instead of c_intptr_t.

Original-commit: flang-compiler/f18@ce6a9fb173
Reviewed-on: https://github.com/flang-compiler/f18/pull/690
Tree-same-pre-rewrite: false
2019-08-26 14:58:10 -07:00
Steve Scalpone 9b5e691814 [flang] Add the OpenMP module.
Original-commit: flang-compiler/f18@09d8b0d6e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/690
Tree-same-pre-rewrite: false
2019-08-26 09:57:06 -07:00
David Truby 1281b9c5fc [flang] Misc changes for review
Original-commit: flang-compiler/f18@6d9ddb8f5e
Reviewed-on: https://github.com/flang-compiler/f18/pull/681
2019-08-23 21:17:57 +01:00
David Truby 0adca8bedc [flang] Fix for builds with libc++9 and libstdc++10
Original-commit: flang-compiler/f18@137de8a1cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/681
Tree-same-pre-rewrite: false
2019-08-23 14:57:05 +01:00
Tim Keith 51fe223916 [flang] Fix bug with statement functions
When the name of a statement function was previously declared, we
weren't correctly recognizing it as a statement function. E.g.
```
integer :: f, i
f(i) = i + 1
```

`f` was entered in the symbol table with `EntityDetails` and the
`parser::Name` on the first line was resolved to that symbol.
On the second line we replaced the symbol for `f` in the scope
with a subprogram symbol, but that didn't change the symbol in
the first `parser::Name`.

The fix requires:
1. don't erase the original symbol for `f`, just replace its details
2. when we erase the symbol for `f` in the subprogram scope, don't
   unresolve it

Original-commit: flang-compiler/f18@31212686ea
2019-08-26 15:46:49 -07:00
Jean Perier 98af2162d0 [flang] Fix intrinsic table probing issue with DOUBLE COMPLEX
The probing table was only expecting REAL for kind code
`KindCode::doublePrecision` that is also used for
`DoublePrecisionComplex`.
Add related tests.

Original-commit: flang-compiler/f18@342ed7e769
Reviewed-on: https://github.com/flang-compiler/f18/pull/680
2019-08-23 05:37:37 -07:00
Jean Perier 252e22ea97 [flang] Fix issue: Enforce specific intrinsic characteristics
Fix issue flang-compiler/f18#661.
The issue was that when probing a specific intrinsic, the
constraints of the related generic intrinsic were tested instead
of the more restrictive constraints of the specific intrinsic.

Original-commit: flang-compiler/f18@dd971e901d
Reviewed-on: https://github.com/flang-compiler/f18/pull/680
Tree-same-pre-rewrite: false
2019-08-23 05:03:41 -07:00
Jean Perier 8c4d2e8763 [flang] Fix SELECTED_CHAR_KIND('DEFAULT') folding issue
Fix issue flang-compiler/f18#676
The issue was that the 'DEFAULT' case was handled
directly in fold.cc which did not lowercase/trim trailing
space of the argument befaore comparing to "default".

Modify the `Selected_char_kind` function to accept the default
char kind as argument and to return it if the processed argument
matches "default".

Original-commit: flang-compiler/f18@14222ae914
Reviewed-on: https://github.com/flang-compiler/f18/pull/679
2019-08-23 03:36:29 -07:00
peter klausler 9717cc43b8 [flang] Make it easier to enable minimal FP output by default for module files (but do not enable it)
Original-commit: flang-compiler/f18@f6b640319b
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
2019-08-23 11:31:47 -07:00
peter klausler b7d463f1d5 [flang] Cope better with ridiculously large exponents on input
Original-commit: flang-compiler/f18@e55cc39bad
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:47 -07:00
peter klausler 787b997830 [flang] Address most review comments
Original-commit: flang-compiler/f18@e6164782ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:46 -07:00
peter klausler 79e8749f25 [flang] Address comments, fix a bug
Original-commit: flang-compiler/f18@e095bbb23f
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:45 -07:00
peter klausler b4f34801c6 [flang] Improve comments, clean up a couple of things
Original-commit: flang-compiler/f18@8d94d643b6
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:43 -07:00
peter klausler 1502542fe7 [flang] Fix copyright date on new file.
Original-commit: flang-compiler/f18@60b1be7ce2
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:43 -07:00
peter klausler 474c43a075 [flang] Correct header guards
Original-commit: flang-compiler/f18@77688d0392
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:40 -07:00
peter klausler bd3debe841 [flang] Reenable thorough test
Original-commit: flang-compiler/f18@431254483e
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:38 -07:00
peter klausler 28d55be08b [flang] Better unsigned division by constants
Original-commit: flang-compiler/f18@1b35c24a8a
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:37 -07:00
peter klausler b5408d26ed [flang] Clean up some static_casts
Original-commit: flang-compiler/f18@a5f81388a2
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:34 -07:00
peter klausler 3f15d46f63 [flang] Simplify guard bits (only use 3)
Original-commit: flang-compiler/f18@b710268c1b
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:33 -07:00
peter klausler 64a0a58bed [flang] Work around slow clang-7
Original-commit: flang-compiler/f18@ed634d72e3
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:32 -07:00
peter klausler b235c63caf [flang] faster Parse
Original-commit: flang-compiler/f18@ca97439c68
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:31 -07:00
peter klausler c4696eaf8e [flang] Get clean build with gcc
Original-commit: flang-compiler/f18@e6b5ed152d
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:30 -07:00
peter klausler 94d8b3f25b [flang] Simplify decimal->binary
Original-commit: flang-compiler/f18@01aefbbd7a
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:29 -07:00
peter klausler d08c9c9d1d [flang] Make thorough test thorough again
Original-commit: flang-compiler/f18@c24b10e434
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:27 -07:00
peter klausler 95165a3921 [flang] Replace usage of original decimal conversion code with calls to new library
Original-commit: flang-compiler/f18@7a164451f2
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:26 -07:00
peter klausler 099838a34d [flang] Debug test
Original-commit: flang-compiler/f18@bf2c22bcf4
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:25 -07:00
peter klausler 77b3c6d53a [flang] More testing, added thorough 32-bit sweep test
Original-commit: flang-compiler/f18@f81b92f91c
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:25 -07:00
peter klausler 3863551b31 [flang] Testing & debugging
Original-commit: flang-compiler/f18@f7f933e7f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:24 -07:00
peter klausler afda616c31 [flang] Begin adding tests
Original-commit: flang-compiler/f18@8776d8b663
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:20 -07:00
peter klausler 9cdb101a4d [flang] clean up a todo
Original-commit: flang-compiler/f18@1107bd1f02
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:18 -07:00
peter klausler 93f3ae8aeb [flang] Enforce digit limits
Original-commit: flang-compiler/f18@33600e127d
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:16 -07:00
peter klausler b53e09c44c [flang] Add rounding modes
Original-commit: flang-compiler/f18@9caa1a29a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:13 -07:00
peter klausler 9e26defed3 [flang] Code snapshot
Original-commit: flang-compiler/f18@46923344ca
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:12 -07:00
peter klausler f2cb0a8015 [flang] Move leading zero bit count into lib/common
Original-commit: flang-compiler/f18@1ed184febe
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:11 -07:00
Tim Keith a03a0432f3 [flang] Add conversions from EnumSet<Attr> to Attrs
This allows operations from EnumSet (e.g. `operator&`) to work as expected.

Original-commit: flang-compiler/f18@c8b8b742c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/675
2019-08-23 08:28:20 -07:00
Tim Keith 5e65aaa921 [flang] Fix .mod file bug with IMPORT of USEd name
If a symbol (derived type, for example) was use-associated into a scope
and then imported into a nested interface block, we were not including
the correct IMPORT statement in the .mod file.

This fixes refines the test for when the IMPORT is needed.

Fixes flang-compiler/f18#657.

Original-commit: flang-compiler/f18@8383de47ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/675
Tree-same-pre-rewrite: false
2019-08-23 07:14:55 -07:00
Tim Keith 191a5e34b0 [flang] Fix bug in .mod file for some subprogram attributes
Some attributes for subprograms can be in the subprogram prefix but
others cannot. For the latter, emit a separate attribute statement
to specify them. We were already doing that for PRIVATE but not for
OPTIONAL. Those may be the only two attributes this can apply to.

Fixes flang-compiler/f18#659.

Original-commit: flang-compiler/f18@ae67e08780
Reviewed-on: https://github.com/flang-compiler/f18/pull/675
Tree-same-pre-rewrite: false
2019-08-23 07:14:55 -07:00
Tim Keith abd56ee7fd [flang] Fix writing defined operators to .mod files
When defined operators were written to .mod files in USE statement
they did not come out correctly. They have to be emitted with
`PutGenericName()` so that `operator` is included.

Original-commit: flang-compiler/f18@d40e65a2f9
Reviewed-on: https://github.com/flang-compiler/f18/pull/675
Tree-same-pre-rewrite: false
2019-08-23 07:14:55 -07:00
Jinxin (Brian) Yang 20eaba0392 [flang] [OpenMP] miscellaneous parse tree updates (flang-compiler/f18#673)
1. Big chunk: update comments in parse-tree.h and openmp-grammar.h
   with Spec chapter/section info, simple explanation, or productions.

2. Update `To`, `Link`, and `From` clauses with `OmpObjectList` to allow
   `/Common Block/`. Spec does not mention whether `Common Block name`
   should be accepted or not, so we should assume that these clauses
   accept normal `list-item`, which is `Variable`, `Array Section`, or
   `Common Block name`.

Original-commit: flang-compiler/f18@140315cb62
Reviewed-on: https://github.com/flang-compiler/f18/pull/673
2019-08-23 09:45:03 -07:00
Jean Perier 511cd36a58 [flang] Address comment: remove useless const
Original-commit: flang-compiler/f18@60983f5021
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
2019-08-22 01:12:20 -07:00
Jean Perier 52e72abb67 [flang] Change Scope::name() to Scope::GetName()
Address comments. Not all scopes are related to
a name. This change makes this more visible to compiler
programers by changing `scope:name()` into `Scope::GetName()`
that returns an optional `SourceName` instead of always
returning a `SourceName` and dying when it cannot.

Original-commit: flang-compiler/f18@0addb79919
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
Tree-same-pre-rewrite: false
2019-08-21 06:29:11 -07:00
Jean Perier 281d41cc10 [flang] Use value semantic for SourceName
Change all SourceName* to std::optional<SourceName> because
SourceName is small enough (16 bytes) to be passed and stored
by value which avoid having to worry about life-time, storage and
value constance issues that comes with pointers.

Original-commit: flang-compiler/f18@73fc08d7bd
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
Tree-same-pre-rewrite: false
2019-08-21 05:33:03 -07:00
Jean Perier 5cc20f6ae8 [flang] Fix test copyright year.
Original-commit: flang-compiler/f18@25819aaf7a
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
Tree-same-pre-rewrite: false
2019-08-21 02:56:25 -07:00
Jean Perier f2453c9f15 [flang] Fix a crash with IMPORT in BLOCK (issue 604)
Only call scope.name() if the scope has a symbol (Block, Global,
Forall and ImpliedDo kind of scopes do not have a symbol).

Original-commit: flang-compiler/f18@81c6b67dd2
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
Tree-same-pre-rewrite: false
2019-08-21 02:56:24 -07:00
Jinxin (Brian) Yang 5330ebbc4a [flang] [OpenMP] Canonicalization framework (flang-compiler/f18#599)
* [OpenMP] Canonicalization framework

This is mainly designed for loop association work but can be used for others,
and `CanonicalizeOmp` must be after `CanonicalizeDo`.

At the `Block` level, recognize legal sequence of `OpenMPLoopConstruct`,
`DoConstruct`, and `OmpEndLoopDirective`. Move available `DoConstruct`
and optional `OmpEndLoopDirective` into `OpenMPLoopConstruct`. Throw error
messages if:
 1. `DoConstruct` is not following `OpenMPLoopConstruct`
 2. `OmpEndLoopDirective` is not following associated do-loop

Once this pass this done, Semantics will not proceed if error exists.

* Update on reviews

1. extract matching and move part into its own function (once `DoConstruct`
   is moved, see whether `OpenMPEndLoopDirective` is available)

2. Use a template function to access construct from ExecutionPartConstruct.

3. Move this code into namespace semantics

Original-commit: flang-compiler/f18@52979f1e93
Reviewed-on: https://github.com/flang-compiler/f18/pull/599
2019-08-22 10:34:15 -07:00
Jean Perier 1bb0e9e362 [flang] Add comments and tests for issue 574 fix
Original-commit: flang-compiler/f18@89337cefc7
Reviewed-on: https://github.com/flang-compiler/f18/pull/672
2019-08-21 02:42:34 -07:00
Jean Perier ccb0b48805 [flang] Handle AssocEntityDetails in mis-parsed function reference
Fix issue flang-compiler/f18#574.
Array references can be mistaken for function references during
parsing. This is handled and fixed by semantics. however, if the
symbol in the misparsed array reference was construct associated,
then semantics was not handling the case correctly because
semantics was only expecting `ObjectEntityDetails`.
It was not possible to change the related `GetUltimate` into
`GetAssociationRoot` because associated symbols are not always
associated to another symbol (variable) but may be assoicated to
an expression. Hence, this change allow `AssocEntityDetails` to
be also accepted when dealing with array references misparsed as
function references.

Original-commit: flang-compiler/f18@b6a8b5f42b
Reviewed-on: https://github.com/flang-compiler/f18/pull/672
Tree-same-pre-rewrite: false
2019-08-20 06:15:52 -07:00
Eric Schweitz 7f2ce553e4 [flang] Add FIR dialect header
Original-commit: flang-compiler/f18@3c902e04d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/668
2019-08-16 19:01:49 -07:00
Eric Schweitz 9325f9974a [flang] Add mlir-tablegen for FIR ops
Original-commit: flang-compiler/f18@aae4b525da
Reviewed-on: https://github.com/flang-compiler/f18/pull/668
Tree-same-pre-rewrite: false
2019-08-16 16:14:22 -07:00
Peter Steinfeld d440b2e166 [flang] Responses to comments on the pull request:
- I removed the redundant test s3() from dosemantics90.f90
 - I changed the error messages to state "LOCAL locality-spec" rather than just
   "locality-spec"
 - I changed the names of a couple of variables/parameters in check-do.cc to
   make the code more understandable.

Original-commit: flang-compiler/f18@bcc6291e83
Reviewed-on: https://github.com/flang-compiler/f18/pull/663
2019-08-20 15:18:37 -07:00
Peter Steinfeld 6b8a1e8248 [flang] Changes to implement constraint C1129
"C1129 A variable that is referenced by the scalar-mask-expr of a concurrent-header or by any concurrent-limit or concurrent-step in that concurrent-header shall not appear in a LOCAL locality-spec in the same DO CONCURRENT statement."

In the process of implementing these checks, I found and fixed some other problems.  I also cleaned up some of the code in check-do.cc.  I ran into two notable difficulties in implementing these checks.  First, the symbols associated with the names in a locality spec get created when the locality specs are process during name resolution.  Thus, they're different from the symbols associated with names that appear in the control expressions.  At Tim's suggestion, I dealt with this by looking up the symbols from the names in the locality spec starting with the closest enclosing scope containing the DO construct.  Second, the symbols can be hidden behind host- use- and construct-associations.

Original-commit: flang-compiler/f18@055788c2f0
Reviewed-on: https://github.com/flang-compiler/f18/pull/663
Tree-same-pre-rewrite: false
2019-08-20 15:18:37 -07:00
Peter Steinfeld d8c4f96f14 [flang] Clean-up of check-do.cc
I got rid of duplicate functions that test for a procedure being PURE, renamed
the type SymbolContainer to SymbolSet, and moved some functions into the class
where they're referenced.

Original-commit: flang-compiler/f18@e48bfdf573
Reviewed-on: https://github.com/flang-compiler/f18/pull/663
Tree-same-pre-rewrite: false
2019-08-20 15:18:37 -07:00
Jinxin (Brian) Yang ca5fee5375 [flang] [OpenMP] miscellaneous parse tree fix (flang-compiler/f18#669)
Fix `aligned(argument-list[ : alignment])` for `declare simd`

(original implementation will throw parser error if `: alignment` is present.


Original-commit: flang-compiler/f18@f3f50f9ad3
Reviewed-on: https://github.com/flang-compiler/f18/pull/669
2019-08-20 10:30:29 -07:00
Jinxin (Brian) Yang 39be4ad473 [flang] [OpenMP] parse tree fix for `Declare Target` (flang-compiler/f18#670)
The original implementation will throw parsing error for multiple
clauses on `declare target` directive, for example:
```
!$omp declare target to(Q) link(R)
```

Based on the OpenMP Spec, we only need two types for the specifier:

```
!$omp declare target (extended-list)
```
or
```
!$omp declare target [clause[ [,] clause] ... ]
```

This fix makes `declare target` accepts either the `list` or `clauses`,
which is more general and better for error messages.

Adjusted existing test for checking the parse tree changes. More tests
will be added during Semantics.

Original-commit: flang-compiler/f18@60f47fc1a1
Reviewed-on: https://github.com/flang-compiler/f18/pull/670
2019-08-20 10:23:56 -07:00
Tim Keith ff768d92dd [flang] Special handling for VOLATILE and ASYNCHRONOUS
The VOLATILE and ASYNCHRONOUS attributes are special in two ways:
- they can be applied to use-associated variables
- if they are applied to a host-associated variable in a block, that
  variable has the attribute only within the scope of the block

The latter is implemented by making a new `HostAssocDetails` symbol
within the block where the attribute can be set without affecting the
variable in the outer scope. This is similar to how the SHARED locality
spec is implemented.

Fixes flang-compiler/f18#649.

Original-commit: flang-compiler/f18@471aba4513
Reviewed-on: https://github.com/flang-compiler/f18/pull/655
2019-08-13 13:50:24 -07:00
peter klausler 7749d43f3f [flang] Another pass with clean builds
Original-commit: flang-compiler/f18@e05dc1f444
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
2019-08-16 09:41:08 -07:00
peter klausler 10688e0903 [flang] Enable more warnings, deal with fallout
Original-commit: flang-compiler/f18@65c5b485af
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
Tree-same-pre-rewrite: false
2019-08-16 09:41:07 -07:00
peter klausler e8c453f4ae [flang] Clean up all newly enabled warnings
Original-commit: flang-compiler/f18@34a917c761
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
Tree-same-pre-rewrite: false
2019-08-16 09:41:07 -07:00
peter klausler 73632f5c36 [flang] Enable some new warnings, clean up some of their consequences
Original-commit: flang-compiler/f18@b82d1e9ac9
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
Tree-same-pre-rewrite: false
2019-08-16 09:41:06 -07:00
Jean Perier 16b8b4cf78 [flang] Address review comments
Rename SetType to SetTypeMapping and change argumnet names.
Style changes.

Original-commit: flang-compiler/f18@3860097815
Reviewed-on: https://github.com/flang-compiler/f18/pull/635
2019-08-14 23:55:16 -07:00
Jean Perier 0818c53966 [flang] Transform implict none ternaries to bool in `ImplicitRules`
Original-commit: flang-compiler/f18@324567bd2d
Reviewed-on: https://github.com/flang-compiler/f18/pull/635
Tree-same-pre-rewrite: false
2019-08-08 08:38:01 -07:00
Jean Perier 069ea6ec75 [flang] Fix IMPLICIT issue 547
So far, in `ImplicitRules` class, `isImplicitNoneType_` is a ternary
unset -> nothing about implicit in this scope, look into parents
set true -> There is an IMPLICIT NONE for types in this scope.
set to false -> There is an IMPLICIT statement mapping types in
this false.

However, it was never set to false, so the IMPORT NONE of parent scopes
was "leaking" when it should not.

Set `isImplicitNoneType_` to false if an IMPLICIT statement is met to
fix the issue.

However, this change made the current name-resolution to then completly
disregard parent scope IMPLICIT NONE even for letters for which no
mapping were defined in the current scope. To fix this `GetType` was
modified to check for implicit none.

This led to `ApplyImplicitRules` to do redudant check, so it was
reorganised to querry for a type and complain if gets a nuulptr.

`GetImplicitType` was modified to avoid redundant error message.

Original-commit: flang-compiler/f18@962dbf3d8b
Reviewed-on: https://github.com/flang-compiler/f18/pull/635
Tree-same-pre-rewrite: false
2019-08-08 07:20:12 -07:00
Steve Scalpone da480fc6ce [flang] Use ACHAR() instead of the nonstandard backslash escape sequences.
Original-commit: flang-compiler/f18@103ed895fe
Reviewed-on: https://github.com/flang-compiler/f18/pull/660
2019-08-14 10:36:29 -07:00
Steve Scalpone 7b17a67190 [flang] Define the named constants for the C characters with
special semantics in the ISO_C_BINDING intrinsic module.

Original-commit: flang-compiler/f18@bee546fdb2
Reviewed-on: https://github.com/flang-compiler/f18/pull/660
Tree-same-pre-rewrite: false
2019-08-13 20:41:43 -07:00
Jinxin (Brian) Yang bcaba6e571 [flang] [OpenMP] parse tree changes for `OpenMPLoopConstruct` (flang-compiler/f18#656)
1. Following Block and Sections constructs, re-structure loop related
   constructs into `{Begin, Loop, End}`. Being part of the work in
   PR flang-compiler/f18#599, the `Loop` and `End` nodes are optional during parser. They
   should be filled in during the phase of `CanonicalizationOfOmp`. This
   commit is solely for the parse tree change. So, after this commit,
   PR flang-compiler/f18#599 needs to be changed accordingly.

2. Removed parse tree nodes for `END DO` and `END DO SIMD`. Similar to
   Block and Sections constructs, `End` node now accepts clauses too,
   the validity checks are deferred into Semantics. This is more genernal
   and error message could be better.

3. With this commit alone, assertion error would occur when `End` directive
   is present, for example `!$OMP END DO` because the `End` node is not
   moved into `OpenMPLoopConstruct` yet. Again, PR flang-compiler/f18#599 will handle that.

More tests will be added in PR flang-compiler/f18#599 and during the future Semantics work.

Original-commit: flang-compiler/f18@8cd1932fd6
Reviewed-on: https://github.com/flang-compiler/f18/pull/656
2019-08-14 15:16:27 -07:00
Steve Scalpone 0653dab8de [flang] Add dcmplx to the intrinsic table and extensions documentation.
Formatting change to dimag intrinsic table entry.

Original-commit: flang-compiler/f18@7f9237531c
Reviewed-on: https://github.com/flang-compiler/f18/pull/662
2019-08-14 11:32:32 -07:00
Jinxin (Brian) Yang e59305d7ae [flang] [OpenMP] parse tree changes for Sections/Parallel Sections constructs (flang-compiler/f18#652)
```
!$omp sections [clause[ [,] clause] ... ]
[!$omp section]
structured-block
[!$omp section
structured-block]
...
!$omp end sections [nowait]
```

1. Following parse tree node changes for Block constructs, changing the
   Sections/Parallel Sections to `{Begin, Section-Blocks, End}`

2. Handles `!$omp section` in the parser, do not create parse tree node
   for this directive because basically it is a delimiter to split the
   code into different `Block`s within the Sections/Parallel Sections
   constructs. So, the `Section-Blocks` here is a `std::list` of `Block`s.
   (thanks to Tim's suggestion)

3. Modify check-omp-structure.* to avoid breaking existing tests

More tests will be added during Semantics. Also, similar to Block constructs,
the `Begin` and `End` directive matching will be done in future PR.

This commit also contains Peter's important fix for allowing "!$OMP END SECTION"
as a legal statement following `Block` (daf5630: Modify execution part error
recovery to not consume !$OMP SECTION).


Original-commit: flang-compiler/f18@75d016f6d2
Reviewed-on: https://github.com/flang-compiler/f18/pull/652
2019-08-14 08:42:28 -07:00
Steve Scalpone 51fea2427f [flang] Change the suffix of the module files to be .f18.mod
so makefiles with "rm *.mod" will still work. Add a
new option to f18, -intrinsic-module-directory, which
supplies a directory in which f18 searches for standard
intrinsic modules. Neither the option nor the path is passed to F18_FC.

Original-commit: flang-compiler/f18@0bbda4c39e
Reviewed-on: https://github.com/flang-compiler/f18/pull/653
2019-08-13 16:02:03 -07:00
Steve Scalpone af794f959b [flang] Create a throwaway wrapper for the throwaway driver.
Add a script called flang to the bin directory that calls
f18 with the -I option pointing to the module files for the
predefined modules. The wrapper also sets the module suffix
to .fmf to avoid naming conflicts with module files generated
by other compilers. Now, the build creates and installs both
.mod and .fmf files for the predefined module files to
accommodate the flang script.

Original-commit: flang-compiler/f18@b6c30284e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/653
Tree-same-pre-rewrite: false
2019-08-12 21:40:03 -07:00
Steve Scalpone 465393f40f [flang] Add an entry to the intrinsics table for dimag.
Also, document extensions dconjg and dimag.

Original-commit: flang-compiler/f18@21535280ee
Reviewed-on: https://github.com/flang-compiler/f18/pull/654
2019-08-13 07:36:22 -07:00
Tim Keith d151b5e88b [flang] Fix bug writing character array constructor to .mod file
Character literals in an array constructor were always written
with no kind prefix, so if kind was not 1 they were incorrect.
`c4a` in `modfile28.f90` was an example of this.

Change it to always include the kind as is done with non-array
character literals.

Original-commit: flang-compiler/f18@4f4caa7006
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
2019-08-13 09:15:50 -07:00
Tim Keith 47ca9b8da2 [flang] Small .mod file fixes
- Only emit initializations for parameters and derived type components.
- Use `=>` for pointer initializations.
- Don't emit intrinsic symbols.

Original-commit: flang-compiler/f18@b91748c053
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
Tree-same-pre-rewrite: false
2019-08-13 09:15:50 -07:00
Tim Keith 7fcaf88bf8 [flang] Fix source location of some symbol names
Symbols can be declared across multiple statements. The CharBlock
that is used for the symbol name is from the first of these.

Sometimes that is not the best choice. If a name appears in a
type-declaration-stmt or a derived-type-stmt, that occurrence is a
better choice. Errors referencing that symbol should normally point
at that name (not its appearance in an earlier PUBLIC statement,
for example).

Also, the order of symbols in .mod files is based on the order of
their names in the cooked source. Here is an example where it is
necessary to sort `a` based on where its type-declaration-stmt
occurs rather than the first occurrence of `a`:
```
  public :: a
  type t
  end type
  type(t), parameter :: a = t()
```

The fix is to add `Symbol::ReplaceName()` so that we can update the
CharBlock for a symbol name when a better one is found, without
changing the actual characters that make up the name.

Original-commit: flang-compiler/f18@5544f16348
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
Tree-same-pre-rewrite: false
2019-08-13 09:15:44 -07:00
Tim Keith 2bc9a1ebed [flang] Write function result to .mod file after dummy args
The function result can depend on the declaration of the dummy
arguments so it should be written to the .mod file after them.

For example:
```
  function f(x)
    integer :: x(:)
    integer :: f(size(x))
  end
```

Original-commit: flang-compiler/f18@f6c8c58c24
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
Tree-same-pre-rewrite: false
2019-08-13 09:15:39 -07:00
Jinxin (Brian) Yang 65de6787e2 [flang] [OpenMP] parse tree changes for Critical Construct (flang-compiler/f18#641)
Simple changes: add source provenance for directive itself and renaming

Original-commit: flang-compiler/f18@9246d266b0
Reviewed-on: https://github.com/flang-compiler/f18/pull/641
2019-08-12 16:08:10 -07:00
peter klausler cbb0be6a37 [flang] Fix bug flang-compiler/f18#643
Original-commit: flang-compiler/f18@29bb4312e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/646
2019-08-12 10:56:18 -07:00
peter klausler f3b5d156cb [flang] Fix bug flang-compiler/f18#642
Original-commit: flang-compiler/f18@d898b29285
Reviewed-on: https://github.com/flang-compiler/f18/pull/648
2019-08-12 12:10:43 -07:00
peter klausler 165ab68837 [flang] Fix bug flang-compiler/f18#644, always enable backslash escapes when reading module files
Original-commit: flang-compiler/f18@f1c897ceda
Reviewed-on: https://github.com/flang-compiler/f18/pull/645
2019-08-12 10:11:59 -07:00