Commit graph

2268 commits

Author SHA1 Message Date
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
fdf85d5dbe [flang] Merge pull request flang-compiler/f18#655 from flang-compiler/tsk-issue649
Special handling for VOLATILE and ASYNCHRONOUS

Original-commit: flang-compiler/f18@75a57c59d2
Reviewed-on: https://github.com/flang-compiler/f18/pull/655
2019-08-20 07:38:04 -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
43cfeb75b3 [flang] Merge pull request flang-compiler/f18#666 from flang-compiler/pmk-warnings
Fix bug flang-compiler/f18#665, enable more warnings, deal with fallout

Original-commit: flang-compiler/f18@5762c2d88b
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
2019-08-16 11:03:17 -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
jeanPerier
146946d253 [flang] Merge pull request flang-compiler/f18#635 from flang-compiler/jpr-fix-547
Fix IMPLICIT issue 547

Original-commit: flang-compiler/f18@f4f31f179b
Reviewed-on: https://github.com/flang-compiler/f18/pull/635
2019-08-16 01:03:19 -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
ef72ee7f76 [flang] Merge pull request flang-compiler/f18#660 from flang-compiler/sjs-c-chars
Define the named constants for the C characters with special semantics

Original-commit: flang-compiler/f18@9c4ce244ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/660
2019-08-15 14:54:05 -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
cf2ab3e2d8 [flang] Merge pull request flang-compiler/f18#662 from flang-compiler/sjs-dcmplx
Add dcmplx to the intrinsic table and extensions documentation.

Original-commit: flang-compiler/f18@8e0c2dea82
Reviewed-on: https://github.com/flang-compiler/f18/pull/662
2019-08-14 20:21:43 +01: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
e688b27210 [flang] Merge pull request flang-compiler/f18#653 from flang-compiler/sjs-throwaway-wrapper2
Create a throwaway wrapper for the throwaway driver.

Original-commit: flang-compiler/f18@5ef563285e
Reviewed-on: https://github.com/flang-compiler/f18/pull/653
2019-08-14 02:29:40 +01: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
9dc7ef171c [flang] Merge pull request flang-compiler/f18#654 from flang-compiler/sjs-dimag
Add an entry to the intrinsics table for dimag.

Original-commit: flang-compiler/f18@daa2d7537e
Reviewed-on: https://github.com/flang-compiler/f18/pull/654
2019-08-13 17:53:33 +01: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
3d09841326 [flang] Merge pull request flang-compiler/f18#650 from flang-compiler/tsk-modfiles
Fix bugs writing .mod files

Original-commit: flang-compiler/f18@a7f90a3c77
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
2019-08-13 09:52:04 -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
e008024e9f [flang] Merge pull request flang-compiler/f18#646 from flang-compiler/pmk-fix-643
Fix bug flang-compiler/f18#643

Original-commit: flang-compiler/f18@f8368e30e0
Reviewed-on: https://github.com/flang-compiler/f18/pull/646
2019-08-12 16:04:24 -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
cd9a4613e6 [flang] Merge pull request flang-compiler/f18#648 from flang-compiler/pmk-fix-642
Fix bug flang-compiler/f18#642

Original-commit: flang-compiler/f18@319c083673
Reviewed-on: https://github.com/flang-compiler/f18/pull/648
2019-08-12 12:29:51 -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
09670c9a61 [flang] Merge pull request flang-compiler/f18#645 from flang-compiler/pmk-fix-644
Fix bug flang-compiler/f18#644, always enable backslash escapes when reading module files

Original-commit: flang-compiler/f18@4ade6c3675
Reviewed-on: https://github.com/flang-compiler/f18/pull/645
2019-08-12 10:31:53 -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
psteinfeld
fb27f631f1 [flang] Merge pull request flang-compiler/f18#637 from flang-compiler/ps-do-tests
Tests for DO loop semantics

Original-commit: flang-compiler/f18@960d76131e
Reviewed-on: https://github.com/flang-compiler/f18/pull/637
2019-08-10 08:18:51 -07:00
Peter Steinfeld
8768a11d4c [flang] - ieee_exceptions.f90: I added all of the routines listed in table 17.3 of the standard that were not currently specified. I also re-ordered the routines to be in the same order as the standard.
- doconcurrent01.f90: I removed the custom versions of ieee_exceptions and
 iso_fortran_env.  I also fixed a typo in a comment.  Also, the use of the real
 standare interface caused one of the error messages to go away, so I fixed
 that.

Original-commit: flang-compiler/f18@a8b310a968
Reviewed-on: https://github.com/flang-compiler/f18/pull/637
2019-08-09 11:38:49 -07:00
Peter Steinfeld
5bade83a0b [flang] Tests for DO loop semantics
These are tests for checks that are already implemented, but for which we
did not have tests.

Original-commit: flang-compiler/f18@68f5acf7b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/637
Tree-same-pre-rewrite: false
2019-08-09 11:38:49 -07:00
Jinxin (Brian) Yang
b41d10beae [flang] [OpenMP] parse tree changes for OpenMPBlockConstruct (flang-compiler/f18#632)
* [OpenMP] parse tree changes for `OpenMPBlockConstruct`

1. merge `Workshare` and `Single` into `OpenMPBlockConstruct` because
   they both accept structured-block and syntax is similar to other block
   directives.

2. `OpenMPBlockConstruct` changes to structure like `{Begin, Block, End}`,
   where `Begin` and `End` are tuple of `{Directive, ClauseList}`.

3. Updated the check-omp-structure.* for necessary parts. Added all the END
   directive enumeration types that may have clauses.

More tests will be added during Semantics.

* [OpenMP] Update on Tim's suggestion

1. Fix unspecified enumeration for `OmpDirective` in the `OmpContext`.
   This is through getting rid of `PushContext(source)` function to
   make sure whenever it is about to push a NEW context, directive
   source location and enumeration are available. To do that, I moved
   around all the switches for directive into high level `Construct`'s
   `Enter` node. Besides fixing the issue, the side benefit is that
   whenever we call `GetContext().directive`, we are sure that the
   `directive` here was set already.

2. When `Enter` the `OmpEndBlockDirective` node, partial context
   information, such as directive source location or legal clause lists,
   needs to be reset. The new directive source location should be
   `OmpEndBlockDirective`'s `source`. The enumeration `directive`
   should not be reset for the END directives that do not accept
   clauses because nothing needs to be checked (for example any clause
   that is on `END PARALLEL` is illegal).

Original-commit: flang-compiler/f18@e5bd6b7ba0
Reviewed-on: https://github.com/flang-compiler/f18/pull/632
2019-08-09 15:11:20 -07:00
Peter Klausler
3020151f71 [flang] Merge pull request flang-compiler/f18#638 from flang-compiler/pmk-forward
Handle forward references to procedures and interfaces

Original-commit: flang-compiler/f18@c2ce89030b
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
2019-08-09 12:15:27 -07:00
peter klausler
bc4d468d29 [flang] address comments
Original-commit: flang-compiler/f18@2bf995562c
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
2019-08-09 09:41:53 -07:00
peter klausler
f13f372833 [flang] Add test for forward references in pointer initializers
Original-commit: flang-compiler/f18@9e01c102a1
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:52 -07:00
peter klausler
e071162e04 [flang] More fixes; tests now all pass (with updates to some)
Original-commit: flang-compiler/f18@236ff3a3db
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:52 -07:00
peter klausler
da6445198a [flang] rebase
Original-commit: flang-compiler/f18@a2086f0406
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:51 -07:00
peter klausler
699b499469 [flang] prep for review
Original-commit: flang-compiler/f18@41f11f4fa0
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:51 -07:00