Commit graph

2911 commits

Author SHA1 Message Date
Tim Keith 914a91c1c3 [flang] Fix misparsed structure constructor in data stmt
In a data statement like `data x / a(1) /`, `a(1)` may be an array
element or a structure constructor. It is parsed as an array element
so if it turns out `a` is a derived type it must be rewritten as a
strucutre constructor.

Original-commit: flang-compiler/f18@a2b2a330e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/1024
2020-02-25 17:13:56 -08:00
Tim Keith 327ec4d2f2 [flang] Merge pull request flang-compiler/f18#1014 from flang-compiler/tsk-where
Remove use of std::set::merge

Original-commit: flang-compiler/f18@59c14bad32
Reviewed-on: https://github.com/flang-compiler/f18/pull/1014
2020-02-26 16:10:49 -08:00
Tim Keith c875618506 [flang] Remove use of std::set::merge
Some versions of clang that we are building with don't have
std::set::merge, even though it is part of C++17. Work around
that by using std::set::insert until we can count on merge being
available everywhere.

Original-commit: flang-compiler/f18@886ccc37fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/1014
2020-02-26 16:10:11 -08:00
Peter Waller 42cc44fbc8 [flang] Add script to flatten git history for llvm monorepo submission (flang-compiler/f18#854)
This script, when run on a checkout of the f18 repository, takes the
current origin/master and makes a branch called "new" with a rewritten
history;

The "new" branch has a flat git history (that is, a series of commits
with only one parent). Flattening is done for merge commits by taking
the content of the commit as it is at the merge commit.

Original-commit: flang-compiler/f18@d9871fa9eb
Reviewed-on: https://github.com/flang-compiler/f18/pull/854
2020-02-26 11:50:43 -08:00
Peter Klausler dec83a5e10 [flang] Merge pull request flang-compiler/f18#1021 from flang-compiler/pmk-ieee-128
Fix layout of 128-bit IEEE-754 floating-point values

Original-commit: flang-compiler/f18@91feed7a38
Reviewed-on: https://github.com/flang-compiler/f18/pull/1021
2020-02-26 08:54:41 -08:00
peter klausler b7a5b5c7b6 [flang] Fix layout of 128-bit IEEE-754 floating-point values
Original-commit: flang-compiler/f18@c95c45704e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1021
2020-02-26 08:23:44 -08:00
jeanPerier 844e7628b0 [flang] Merge pull request flang-compiler/f18#1026 from flang-compiler/jpr-drone-fix
Fix drone CI build failure due to lack of FileCheck

Original-commit: flang-compiler/f18@a5644a4e8e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1026
2020-02-26 07:15:42 -08:00
Jean Perier 13c7778df9 [flang] Remove clang from LLVM drone builds until needed to fasten builds
Original-commit: flang-compiler/f18@5eaebc800c
Reviewed-on: https://github.com/flang-compiler/f18/pull/1026
2020-02-26 06:16:22 -08:00
Jean Perier c3ce28b8b4 [flang] Fix drone CI build failure due to lack of FileCheck
Simply use the llvm build directory and save installing LLVM on the way.

Original-commit: flang-compiler/f18@7848ab146a
Reviewed-on: https://github.com/flang-compiler/f18/pull/1026
Tree-same-pre-rewrite: false
2020-02-26 03:49:42 -08:00
Tim Keith 05e649376b [flang] Merge pull request flang-compiler/f18#1023 from flang-compiler/tsk-issue1022
Allow for access-stmt before namelist-stmt

Original-commit: flang-compiler/f18@618dc08139
Reviewed-on: https://github.com/flang-compiler/f18/pull/1023
2020-02-25 15:32:06 -08:00
Tim Keith de066a2756 [flang] Allow for access-stmt before namelist-stmt
You can declare a name in an access statement and then declare it as
a namelist group name. We weren't allowing that because we didn't
convert a symbol with UnknownDetails to one with NamelistDetails.

Fixes flang-compiler/f18#1022.

Original-commit: flang-compiler/f18@a759204db5
Reviewed-on: https://github.com/flang-compiler/f18/pull/1023
2020-02-25 15:22:13 -08:00
David Truby 0855c45400 [flang] Replace module writer posix file handling with llvm file handling. (flang-compiler/f18#993)
NOTE: This commit introduces a dependency on LLVM HEAD

Original-commit: flang-compiler/f18@97efc0194d
Reviewed-on: https://github.com/flang-compiler/f18/pull/993
2020-02-25 07:59:50 -08:00
CarolineConcatto 64ab3302d5 [flang] [LLVMify F18] Compiler module folders should have capitalised names (flang-compiler/f18#980)
This patch renames the modules in f18 to use a capital letter in the
module name

Signed-off-by: Caroline Concatto <caroline.concatto@arm.com>

Original-commit: flang-compiler/f18@d2eb7a1c44
Reviewed-on: https://github.com/flang-compiler/f18/pull/980
2020-02-25 07:11:52 -08:00
Tim Keith 456a61d188 [flang] Merge pull request flang-compiler/f18#1013 from flang-compiler/tsk-rewrite
Temporarily disable part of data01 test

Original-commit: flang-compiler/f18@cf48fe8746
Reviewed-on: https://github.com/flang-compiler/f18/pull/1013
2020-02-21 16:25:54 -08:00
Tim Keith 6374eea9cf [flang] Temporarily disable part of data01 test
`data x /a(1)/` is ambiguous. The data value may be an array element
or a structure constructor. We need to parse it as one of these and
then fix up the parse tree when it should have been the other one.

My PR 1012 changed the parser to identify this as an array element.
That makes this test invalid until we have the right parse tree fixup,
so I am disabling it for now.

Original-commit: flang-compiler/f18@72aa278f03
Reviewed-on: https://github.com/flang-compiler/f18/pull/1013
2020-02-21 16:25:10 -08:00
Tim Keith b7af30a33b [flang] Merge pull request flang-compiler/f18#1009 from flang-compiler/tsk-where
Add more checks on WHERE and FORALL

Original-commit: flang-compiler/f18@c9638d10c6
Reviewed-on: https://github.com/flang-compiler/f18/pull/1009
2020-02-21 15:48:52 -08:00
Tim Keith e0ba2b8783 [flang] Add more checks on WHERE and FORALL
Check that masks and LHS of assignments in WHERE statements and
constructs have consistent shapes. They must all have the same rank and
any extents that are compile-time constants must match.

Emit a warning for assignments in FORALL statements and constructs where
the LHS does not reference each of the index variables.

Original-commit: flang-compiler/f18@8b04dbebcf
Reviewed-on: https://github.com/flang-compiler/f18/pull/1009
2020-02-21 15:47:01 -08:00
Tim Keith 703c56132b [flang] Merge pull request flang-compiler/f18#1012 from flang-compiler/tsk-rewrite
Fix parsing bug on DATA statement

Original-commit: flang-compiler/f18@b9f2617f55
Reviewed-on: https://github.com/flang-compiler/f18/pull/1012
2020-02-21 15:46:24 -08:00
Tim Keith 28d8a67d43 [flang] Fix parsing bug on DATA statement
This DATA statement was getting a parsing error:
`data x /a(i)%b/`

The parser was expecting the ending '/' where the '%' was. The problem
was parsing `a(i)` as a structure constructor. Instead, move the
constant subobject case before structure constructor, but match it only
if not followed by '('. That is because in `data x /a(1)(2)/`, `a(1)` is
a valid structure constructor.

Also, remove the NamedConstant alternative from DataStmtRepeat. A named
constant is always parsed as a ConstantSubobject so it can never occur.

Original-commit: flang-compiler/f18@04a76b2726
Reviewed-on: https://github.com/flang-compiler/f18/pull/1012
2020-02-21 15:31:12 -08:00
Anchu Rajendran S df1b4b144e [flang] Issue flang-compiler/f18#992 : Implementing Semantic checks for DATA Statement (C874-C887) (flang-compiler/f18#992)
This commit covers Semantic Constraints C882 - C887

C882 : It was partially Implemented. Finished the implementation
and added test case
C884 : Implemented and added test case
C883 : Implementation was there already. Added test case
C885, C886, C887 : Implementation was there already. Added test case for
data-repeat.

Original-commit: flang-compiler/f18@822129736b
Reviewed-on: https://github.com/flang-compiler/f18/pull/992
2020-02-20 22:19:14 -08:00
Isuru Fernando ca861fd494 [flang] Add missing array include (flang-compiler/f18#1004)
Original-commit: flang-compiler/f18@de801a0db7
Reviewed-on: https://github.com/flang-compiler/f18/pull/1004
2020-02-20 13:12:48 -08:00
Isuru Fernando 256b53688e [flang] Disable 80-bit extended precision if on MSVC (flang-compiler/f18#1003)
Original-commit: flang-compiler/f18@2c1fc63758
Reviewed-on: https://github.com/flang-compiler/f18/pull/1003
2020-02-20 11:33:43 -08:00
Tim Keith 4aea41c907 [flang] Merge pull request flang-compiler/f18#989 from flang-compiler/tsk-forall
Add FORALL checking to DoChecker

Original-commit: flang-compiler/f18@35fd0cda58
Reviewed-on: https://github.com/flang-compiler/f18/pull/989
2020-02-19 13:42:30 -08:00
Tim Keith aafc1578ae [flang] Rename DoChecker to DoForallChecker
This reflects the fact that it now performs checks on both DO
and FORALL constructs. Rename the source files as well.

Original-commit: flang-compiler/f18@8ecb6a279f
Reviewed-on: https://github.com/flang-compiler/f18/pull/989
2020-02-19 13:28:19 -08:00
Tim Keith ee7cc4764f [flang] Add FORALL checking to DoChecker
FORALL statements and constructs require a lot of the same checking
as DO CONCURRENT, so do the checks in DoChecker so that code can be
shared where possible. This requires some reorganization there.
Remove code from AssignmentChecker that did some of these checks.

Change names that contain `DoVar` or `DoVariable` to `IndexVar` to
reflect the fact that they may be DO or FORALL index variables.
Distinguish between the two when necessary with enum `IndexVarKind`.

Change some messages that referred to "concurrent-header" or
"concurrent-control" to specifically say "DO CONCURRENT" or "FORALL".

Original-commit: flang-compiler/f18@84752c492e
Reviewed-on: https://github.com/flang-compiler/f18/pull/989
Tree-same-pre-rewrite: false
2020-02-18 17:14:24 -08:00
Tim Keith 88aa96ffe9 [flang] Reorganize evaluate::Assignment
Every analyzed assignment represented by `evaluate::Assignment` has
a LHS and RHS expression. These need to be checked uniformly in various
places. So change Assignment always to have those data members, with
the variant determining which kinds of assignment it is: intrinsic,
user-defined, or pointer.

Original-commit: flang-compiler/f18@fb87d16a86
Reviewed-on: https://github.com/flang-compiler/f18/pull/989
Tree-same-pre-rewrite: false
2020-02-18 15:20:28 -08:00
psteinfeld 79c467b1a8 [flang] Merge pull request flang-compiler/f18#985 from flang-compiler/ps-types
Semantic checks for C709, C710, and C711

Original-commit: flang-compiler/f18@fa6d4753b7
Reviewed-on: https://github.com/flang-compiler/f18/pull/985
2020-02-19 12:24:46 -08:00
Pete Steinfeld 4d0c8522e3 [flang] Semantic checks for C709, C710, and C711
C709 An assumed-type entity shall be a dummy data object that does not
have the ALLOCATABLE, CODIMENSION, INTENT (OUT), POINTER, or VALUE
attribute and is not an explicit-shape array.

C710 An assumed-type variable name shall not appear in a designator or
expression except as an actual argument corresponding to a dummy
argument that is assumed-type, or as the first argument to the intrinsic
function IS_CONTIGUOUS, LBOUND, PRESENT, RANK, SHAPE, SIZE, or UBOUND,
or the function C_LOC from the intrinsic module ISO_C_BINDING.

C711 An assumed-type actual argument that corresponds to an assumed-rank
dummy argument shall be assumed-shape or assumed-rank.

For C709 I added code to check-declarations.cpp.  For this, I had to
distinguish between polymorphic types and assumed-type types to
eliminate multiple messages on the same line.

C710 was already checked, but I added a notation in the source.

For C711 I added code to check-call.cpp and the test call15.f90.

Original-commit: flang-compiler/f18@4a703f2b5a
Reviewed-on: https://github.com/flang-compiler/f18/pull/985
2020-02-19 11:58:29 -08:00
jeanPerier d49804cde5 [flang] Merge pull request flang-compiler/f18#994 from flang-compiler/jpr-fix-shared-builds
Fix issues with -DBUILD_SHARED_LIBS=On

Original-commit: flang-compiler/f18@a20a80e71e
Reviewed-on: https://github.com/flang-compiler/f18/pull/994
2020-02-19 10:44:59 -08:00
Jean Perier 24b9ef8727 [flang] Fix issues with -DBUILD_SHARED_LIBS=On
This re-ordering allows building f18 with shared library using and LLVM build
with static libraries.

This reordering (that also made sens form an alphabetical point of view)
works here to do such "shared+archive" compiling because the current
dependency on LLVM is simple (only one f18 lib + an executable depends on LLVM).
As soon as two f18 libraries will depend on LLVM, one will have to use an LLVM
version built with -DBUILD_SHARED_LIBS=On if one wants to use this option
to compile f18.

Original-commit: flang-compiler/f18@bbbbe9c1aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/994
2020-02-19 05:25:35 -08:00
Jinxin (Brian) Yang aa9fc5bddc [flang] [OpenMP] Predetermined rule for sequential loop index (flang-compiler/f18#976)
This commit implements rule:
A loop iteration variable for a sequential loop in a parallel or
task generating construct is private in the innermost such construct
that encloses the loop.

A Simple example:
```
  i = -1                    <== Scope 0
  j = -1
  !$omp parallel            <== Scope 1
  print *,i,j      <-- both are shared (Scope 0)
  !$omp parallel            <== Scope 2
  print *,i,j      <-- a) i is shared (Scope 0), j is private (Scope 2)
  !$omp do                  <== Scope 3
  do i=1, 10       <-- i is private (Scope 3)
     do j=1, 10    <-- b) j is private (Scope 2, not 3!)
     enddo
  enddo
  print *,i,j      <-- c) i is shared (Scope 0), j is private (Scope 2)
  !$omp end parallel
  print *,i,j      <-- both are shared (Scope 0)
  !$omp end parallel
  print *,i,j      <-- both are shared (Scope 0)
end
```

Ideally the above rule solves a), b), and c) but a) is left as a TODO
because it is better to handle the data-sharing attribute conflicts
along with the rules for "Predetermined DSA on Clauses".

The basic idea is when visiting the `DoConstruct` node within an OpenMP
construct, if the do-loop is not associated (like `i` loop is associated
with `!$omp do`) AND the do-loop is in the parallel/task generating
construct, resolve the loop index to be private to that innermost construct.

In the above example, `j` loop is not associated (then it is sequential) and
the innermost parallel/task generating construct that encloses the `j` loop
is the `parallel` construct marked with `<== Scope 2`, so `j` is private
to that construct. To do that, I also need to change the prototype of those
`ResolveOmp*` functions to allow specifiying the `scope` because the new
symbol for `j` should be created in Scope 2 and all the `symbol` field of
`Name j` in that `parallel` construct should be fixed, such as c).

Original-commit: flang-compiler/f18@69a845283b
Reviewed-on: https://github.com/flang-compiler/f18/pull/976
2020-02-18 16:27:43 -08:00
jeanPerier 840e19eed8 [flang] Merge pull request flang-compiler/f18#959 from jeanPerier/jpr-mono-split
RFC: FIR Merge - PR1: Add PFTBuilder structure to help lowering the parse-tree

Original-commit: flang-compiler/f18@f28afa7138
Reviewed-on: https://github.com/flang-compiler/f18/pull/959
2020-02-17 09:47:01 -08:00
Jean Perier 3364086795 [flang] Add Pre-FIR Tree structure to help lowering the parse-tree
The Pre-FIR Tree structure is a transient data structure that
is meant to be built from the parse tree just before lowering to
FIR and that will be deleted just afterwards. It is not meant to perfrom
optimization analysis and transformations. It only provides temporary
information, such as label target information or parse tree parent nodes,
that is meant to be used to lower the parse tree structure into
FIR operations.
A PFTBuilder class builds the Pre-Fir Tree from the parse-tree.
A pretty printer is available to visualize this data structure.

- Lit tests are added to:
  1. that the PFT tree structure is as expected
  2. that the PFT captures all intented nodes

- Cmake changes: Prevent warnings inisde LLVM headers when compiling flang

The issue is that some LLVM headers  define functions where the usage of
the parameters depend on environment ifdef. See for instance Size in:
5f940220bf/llvm/include/llvm/Support/Compiler.h (L574)

Because flang is build with -Werror and -Wunused-parameter is default in
clang, this may breaks build in some environments (like with clang9 on macos).
A solution would be to add -Wno-unused-parameter to flang CmakLists.txt,
but it is wished to keep this warning on flang sources for quality purposes.
Fixing LLVM headers is not an easy task and `[[maybe_unused]]` is C++17 and
cannot be used yet in LLVM headers.
Hence, this fix simply silence warnings coming from LLVM headers by telling
CMake they are to be considered as if they were system headers.

- drone.io changes: remove llvm 6.0 from clang config in drone.io and link
flang with libstdc++ instead of libc++

llvm-dev resolved to llvm-6.0 in clang builds on drone.io. llvm 6.0 too old.
LLVM packages are linked with libstdc++ standard library whereas libc++ was
used for flang. This caused link time failure when building clang. Change
frone.io to build flang with libc++.

Note:
This commit does not reflect an actual work log, it is a feature based split of the
changes done in the FIR experimental branch. The related work log can be found in the
commits between:
864898cbe509d032abfe1172ec367dbd3dd92bc1
and
137c23da9c64cf90584cf81fd646053a69e91f63

Other changes come from https://github.com/flang-compiler/f18/pull/959 review.

Original-commit: flang-compiler/f18@edb0943bca
Reviewed-on: https://github.com/flang-compiler/f18/pull/959
2020-02-17 02:38:49 -08:00
Jean Perier c52cd6355c [flang] Add clang-format files for FIR source (LLVM style)
Note:
This commit does not reflect an actual work log, it is a feature based split of the
changes done in the FIR experimental branch. The related work log can be found in the commits between:
8c320e3bf2
and:
9b9ea05f9a

Original-commit: flang-compiler/f18@00d8d5121c
Reviewed-on: https://github.com/flang-compiler/f18/pull/959
Tree-same-pre-rewrite: false
2020-02-17 02:37:49 -08:00
psteinfeld 5334ee6e5f [flang] Merge pull request flang-compiler/f18#981 from flang-compiler/ps-c708
Semantic check for C708

Original-commit: flang-compiler/f18@4d4b375d14
Reviewed-on: https://github.com/flang-compiler/f18/pull/981
2020-02-14 09:27:52 -08:00
Pete Steinfeld 79f38ab4bb [flang] Semantic check for C708
An entity declared with the CLASS keyword shall be a dummy argument or
have the ALLOCATABLE or POINTER attribute.

Implementing this check revealed a problem in the test resolve44.cpp.
It also showed that we were doing semantic checking on the entities
created by the compiler for LOCAL and LOCAL_INIT locality-specs.  So I
changed the creation of symbols associated with LOCAL and LOCAL_INIT
locality-specs to be host associated with the outer symbol rather than
new object entities.  In the process, I also changed things so that the
`parser::Name` associated with the newly created symbols was set to the
symbol rather than being set to nullptr.

Original-commit: flang-compiler/f18@5dd0b0bbe8
Reviewed-on: https://github.com/flang-compiler/f18/pull/981
2020-02-14 08:33:07 -08:00
David Truby d7cee59762 [flang] Add zlib to drone files so that linking LLVM works. (flang-compiler/f18#983)
Original-commit: flang-compiler/f18@403faf847d
Reviewed-on: https://github.com/flang-compiler/f18/pull/983
2020-02-13 20:46:29 -08:00
Peter Klausler 6adb4b5981 [flang] Merge pull request flang-compiler/f18#982 from flang-compiler/pmk-more-io
Progress on Fortran I/O runtime

Original-commit: flang-compiler/f18@47ed180b67
Reviewed-on: https://github.com/flang-compiler/f18/pull/982
2020-02-13 11:08:26 -08:00
peter klausler 95696d563b [flang] Progress on Fortran I/O runtime
Use internal units for internal I/O state

Replace use of virtual functions

reference_wrapper

Internal formatted output to array descriptor

Delete dead code

Begin list-directed internal output

Refactorings and renamings for clarity

List-directed external I/O (character)

COMPLEX list-directed output

Control list items

First cut at unformatted I/O

More OPEN statement work; rename class to ExternalFileUnit

Complete OPEN (exc. for POSITION=), add CLOSE()

OPEN(POSITION=)

Flush buffers on crash and for terminal output; clean up

Documentation

Fix backquote in documentation

Fix typo in comment

Begin implementation of input

Refactor binary floating-point properties to a new header, simplify numeric output editing

Dodge spurious GCC 7.2 build warning

Address review comments

Original-commit: flang-compiler/f18@9c4bba11cf
Reviewed-on: https://github.com/flang-compiler/f18/pull/982
2020-02-13 10:31:26 -08:00
psteinfeld dbea781d19 [flang] Merge pull request flang-compiler/f18#978 from flang-compiler/ps-types
Semantic checks for constraints on types

Original-commit: flang-compiler/f18@2efdf12f6a
Reviewed-on: https://github.com/flang-compiler/f18/pull/978
2020-02-11 11:32:12 -08:00
Pete Steinfeld 702d3075ac [flang] Semantic checks for constraints on types
I implemented and added tests for constraints C703, C704, C705, C706,
and C796.  In some cases, the code and/or test already existed, and all
I did was add a notation indicating the associated constraint.

Original-commit: flang-compiler/f18@49a64c4c23
Reviewed-on: https://github.com/flang-compiler/f18/pull/978
2020-02-11 11:30:51 -08:00
psteinfeld 766d633ebf [flang] Merge pull request flang-compiler/f18#979 from flang-compiler/ps-dev-story
Updated the description of `evaluate::Expr` types

Original-commit: flang-compiler/f18@92884fa4f6
Reviewed-on: https://github.com/flang-compiler/f18/pull/979
2020-02-11 11:04:37 -08:00
Pete Steinfeld b9e9b6f84d [flang] Updated the description of evaluate::Expr types
Original-commit: flang-compiler/f18@75adddd504
Reviewed-on: https://github.com/flang-compiler/f18/pull/979
2020-02-11 11:03:06 -08:00
Tim Keith 9d2d587763 [flang] Merge pull request flang-compiler/f18#977 from flang-compiler/tsk-osx-error
Fix compilation error on macOS

Original-commit: flang-compiler/f18@204c67d7b6
Reviewed-on: https://github.com/flang-compiler/f18/pull/977
2020-02-10 15:05:10 -04:00
Tim Keith 6256fbe200 [flang] Fix compilation error on macOS
The call to `std::min` failed to compile with GCC on macOS due to type
inference because `std::size_t` is `long unsigned int` but `std::int64_t`
is `long long int`.

Original-commit: flang-compiler/f18@c342575a9e
Reviewed-on: https://github.com/flang-compiler/f18/pull/977
2020-02-10 10:55:24 -08:00
jeanPerier d3158fecf9 [flang] Merge pull request flang-compiler/f18#972 from flang-compiler/jpr-clang-10-warnings
Fix issues comming from clang-10 warnings

Original-commit: flang-compiler/f18@90e6448255
Reviewed-on: https://github.com/flang-compiler/f18/pull/972
2020-02-10 07:59:10 -08:00
Jean Perier 231ff4e6ad [flang] Fix issues comming from clang-10 warnings
- Remove SubprogramDetails copy ctor
- Prevent copies in range based loops over symbols
- Remove unsued var

Original-commit: flang-compiler/f18@16543d22f7
Reviewed-on: https://github.com/flang-compiler/f18/pull/972
2020-02-10 02:33:06 -08:00
psteinfeld 2a1953a1e0 [flang] Merge pull request flang-compiler/f18#973 from flang-compiler/ps-c702
Semantic checks for C702

Original-commit: flang-compiler/f18@351a7d5ea6
Reviewed-on: https://github.com/flang-compiler/f18/pull/973
2020-02-07 10:28:03 -08:00
Pete Steinfeld 05f44aff45 [flang] Semantic checks for C702
C702 (R701) A colon shall not be used as a type-param-value except in the
declaration of an entity that has the POINTER or ALLOCATABLE attribute.

I added code to the visitor for a TypeDeclarationStmt to check for the
'LEN' type parameter for strings and to loop over the type parameters
for derived types.

I also ran into a few situations where previous tests had erroneously
used a colon for type parameters without either the POINTER or
ALLOCATABLE attribute and fixed them up.

Original-commit: flang-compiler/f18@a1a95bfcd1
Reviewed-on: https://github.com/flang-compiler/f18/pull/973
2020-02-07 10:26:23 -08:00
Jinxin (Brian) Yang f90404e59c [flang] [OpenMP] Predetermined rules for loop index variables (flang-compiler/f18#962)
This refers to three rules in OpenMP 4.5 Spec 2.15.1.1:
  * The loop iteration variable(s) in the associated do-loop(s) of a do,
    parallel do, taskloop, or distribute construct is (are) private.
  * The loop iteration variable in the associated do-loop of a simd
    construct with just one associated do-loop is linear with a linear-step
    that is the increment of the associated do-loop.
  * The loop iteration variables in the associated do-loops of a simd
    construct with multiple associated do-loops are lastprivate.

A simple example:
```
implicit none
  integer :: N = 1024
  integer i, j, k
  !$omp parallel do collapse(3)
  do i=1, N  <- i is private
     do j=1, N  <- j is private
        do k=1, N  <- k is private
        enddo
     enddo
  enddo
end
```

If `collapse` clause is not present, the associated do-loop for construct
`parallel do` is only `i` loop. With `collapse(n)`, `i`, `j`, and `k` are
all associated do-loops and the loop index variables are private to the
OpenMP construct:

```
implicit none
 !DEF: /MainProgram1/n ObjectEntity INTEGER(4)
 integer :: n = 1024
 !DEF: /MainProgram1/i ObjectEntity INTEGER(4)
 !DEF: /MainProgram1/j ObjectEntity INTEGER(4)
 !DEF: /MainProgram1/k ObjectEntity INTEGER(4)
 integer i, j, k
!$omp parallel do  collapse(3)
 !DEF: /MainProgram1/Block1/i (OmpPrivate) HostAssoc INTEGER(4)
 !REF: /MainProgram1/n
 do i=1,n
  !DEF: /MainProgram1/Block1/j (OmpPrivate) HostAssoc INTEGER(4)
  !REF: /MainProgram1/n
  do j=1,n
   !DEF: /MainProgram1/Block1/k (OmpPrivate) HostAssoc INTEGER(4)
   !REF: /MainProgram1/n
   do k=1,n
   end do
  end do
 end do
end program
```

This implementation assumes that the structural checks for do-loops
are done at this point, for example the `n` in `collapse(n)` should
be no more than the number of actual perfectly nested do-loops, etc..

Original-commit: flang-compiler/f18@572a57d3d0
Reviewed-on: https://github.com/flang-compiler/f18/pull/962
2020-02-05 10:13:43 -08:00