Commit graph

2249 commits

Author SHA1 Message Date
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
peter klausler
fca50c0822 [flang] Proper PDT handling
Original-commit: flang-compiler/f18@32256daa15
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
c9d286d6c4 [flang] Restore symbol to ProcBindingDetails
Original-commit: flang-compiler/f18@5dc1c91156
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:50 -07:00
peter klausler
de7c7c07ce [flang] Save proc pointer inits in symbol table; add IsSaved() predicate to tools
Original-commit: flang-compiler/f18@23c6be9168
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:49 -07:00
peter klausler
5bfc785218 [flang] Checkpoint work
Original-commit: flang-compiler/f18@b8f614c3c4
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:48 -07:00
peter klausler
5045af7710 [flang] Deferred processing of pointer initializers (incomplete)
Original-commit: flang-compiler/f18@2913b01c51
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:48 -07:00
Jinxin (Brian) Yang
c7fc08a8ea [flang] [OpenMP] parse tree changes for ATOMIC constructs (flang-compiler/f18#636)
1. make the parse tree nodes more conform with OpenMP spec

2. isolate the memory related clauses to make the parse tree nodes
   extendable for OpenMP 5.0

3. source provenance is saved for each atomic-clause (read, write, update,
   and capture); for atomic-clause that is not present, source location
   is saved for "ATOMIC" directive name itself

More tests will be added during Semantics.

Original-commit: flang-compiler/f18@8e2db2f868
Reviewed-on: https://github.com/flang-compiler/f18/pull/636
2019-08-09 09:39:55 -07:00
Tim Keith
39807b8389 [flang] Merge pull request flang-compiler/f18#640 from flang-compiler/tsk-issue587
Fix bug with generic and specific having same name

Original-commit: flang-compiler/f18@e8c8c0357b
Reviewed-on: https://github.com/flang-compiler/f18/pull/640
2019-08-09 06:48:16 -07:00
Tim Keith
dd8601162b [flang] Fix bug with generic and specific having same name
If a generic interface had a specific procedure with the same name that
is specified by an interface body, it was not handled correctly.

We were replacing the generic symbol with the symbol for the specific
procedure. Instead, leave the generic symbol in the scope and just
insert the new symbol for the specific into the generic.

Also, don't do distinguishability checks when one of the specific
procedures already has an error.

Fixes flang-compiler/f18#587.

Original-commit: flang-compiler/f18@2e90565675
Reviewed-on: https://github.com/flang-compiler/f18/pull/640
2019-08-08 17:05:49 -07:00
Tim Keith
ca973fc355 [flang] Merge pull request flang-compiler/f18#639 from flang-compiler/tsk-shared
Fix problems building with shared libraries on Linux

Original-commit: flang-compiler/f18@0e3ed603c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/639
2019-08-08 17:10:16 -07:00
Tim Keith
57af252f56 [flang] Fix problems building with shared libraries on Linux
Building with gcc 8 or 9 with shared libraries had linking
problems in test/evaluate. Fix those by adding FortranSemantics
to the library dependencies.

Original-commit: flang-compiler/f18@009b9ab171
Reviewed-on: https://github.com/flang-compiler/f18/pull/639
2019-08-08 16:23:53 -07:00
jeanPerier
ee2dd1c503 [flang] Merge pull request flang-compiler/f18#631 from flang-compiler/jpr-fix-589
Prevent result symbol to be converted into function when they are called

Original-commit: flang-compiler/f18@464310a1e3
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
2019-08-08 05:48:20 -07:00
Jean Perier
7e197e691f [flang] Fix reabsing conflict issue
Remove duplicate `IsFunctionResultWithSameNameAsFunction` declarartion.

Original-commit: flang-compiler/f18@d88597ca72
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
2019-08-08 05:30:21 -07:00
Jean Perier
3b7b2f56d5 [flang] Answer PR 631 comments:
- Create a function `IsFunctionResult(const Symbol &)` in
   lib/semantics/tools.h.
 - style edit in weird var definition style.

Original-commit: flang-compiler/f18@15e3f87b40
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
Tree-same-pre-rewrite: false
2019-08-08 04:01:34 -07:00
Jean Perier
24bb2c29cd [flang] Prevent result symbol to be converted into function when they are called.
+ Fix issue 589.
+ Catch empty subscript list in array reference
In name resolution, when skimming through the execution statement of a
function, calls to the result symbol should not trigger the conversion
of this symbol to a function symbol. The result is a data object and
cannot be called unless it was explictly declared to be a procedure
pointer.
Notably, recursive function calls cannot be made if RESULT was not used.

The symbol is prevented from being transformed into a function
symbol by transforming it into an object before skimming through the
executable statement. This is done after processing all the
specifications so that if the result actually is a procedure pointer,
the call to `ConvertToObjectEntity` introduced by this commit will
not convert it to an object by mistake.

This commit also introduce a check when fixing misparsed function
reference into array reference to verify the array reference has
array subscripts. Currently this went uncaught. It is not possible
to complain later in expressions because the subscript list of
expression might be empty for unrelated error recovery reasons
(e.g. if an entity of the wrong type appeared as susbcript).

Add related tests.

Original-commit: flang-compiler/f18@2fd8b65f58
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
Tree-same-pre-rewrite: false
2019-08-08 03:58:41 -07:00
jeanPerier
ea489de811 [flang] Merge pull request flang-compiler/f18#607 from flang-compiler/jpr-fix-594
Fix issue 594 and add a derived type component visitor framework

Original-commit: flang-compiler/f18@009db27bfa
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
2019-08-08 01:55:50 -07:00
Jean Perier
edab0a0ebb [flang] copyright update
Original-commit: flang-compiler/f18@e724438925
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
2019-07-31 10:30:42 -07:00
Jean Perier
965d114d8c [flang] use newly added DEREF in component iterator
Original-commit: flang-compiler/f18@2185f20009
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 08:56:25 -07:00
Jean Perier
153892dd66 [flang] Checkpoint: derived type component iterators
Original-commit: flang-compiler/f18@72d209bb52
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 07:26:26 -07:00
Jean Perier
0a9725607b [flang] Improve error messages about component types in allocate checks
Use component visitor framework to attach more information reagrding
where is the ultimate/potential component that is forbidden.
Also remove unused functions.

Original-commit: flang-compiler/f18@4619c5860a
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 07:26:24 -07:00