platform/upstream/llvm.git
4 years ago[flang] A rework of the cmake build components for in and out of tree builds.
Patrick McCormick [Tue, 25 Feb 2020 23:22:14 +0000 (16:22 -0700)]
[flang] A rework of the cmake build components for in and out of tree builds.

In general all the basic functionality seems to work and removes some redundancy
and more complicated features in favor of borrowing infrastructure from LLVM
build configurations. Here's a quick summary of details and remaining issues:

  * Testing has spanned Ubuntu 18.04 & 19.10, CentOS 7, RHEL 8, and
    MacOS/darwin.  Architectures include x86_64 and Arm.  Without
    access to Window nothing has been tested there yet.

  * As we change file and directory naming schemes (i.e.,
    capitalization) some odd things can occur on MacOS systems with
    case preserving but not case senstive file system configurations.
    Can be painful and certainly something to watch out for as any
    any such changes continue.

  * Testing infrastructure still needs to be tuned up and worked on.
    Note that there do appear to be cases of some tests hanging (on
    MacOS in particular).  They appear unrelated to the build
    process.

  * Shared library configurations need testing (and probably fixing).

  * Tested both standalone and 'in-mono repo' builds.  Changes for
    supporting the mono repo builds will require LLVM-level changes that
    are straightforward when the time comes.

  * The configuration contains a work-around for LLVM's C++ standard mode
    passing down into Flang/F18 builds (i.e., LLVM CMake configuration would
    force a -std=c++11 flag to show up in command line arguments.  The
    current configuration removes that automatically and is more strict in
    following new CMake guidelines for enforcing C++17 mode across all the
    CMake files.

  * Cleaned up a lot of repetition in the command line arguments.  It
    is likely that more work is still needed to both allow for
    customization and working around CMake defailts (or those
    inherited from LLVM's configuration files). On some platforms agressive
    optimization flags (e.g. -O3) can actually break builds due to the inlining
    of templates in .cpp source files that then no longer are available for use
    cases outside those source files (shows up as link errors).   Sticking at -O2
    appears to fix this.  Currently this CMake configuration forces this in
    release mode but at the cost of stomping on any CMake, or user customized,
    settings for the release flags.

  * Made the lit tests non-source directory dependent where appropriate. This is
    done by configuring certain test shell files to refer to the correct paths
    whether an in or out of tree build is being performed. These configured
    files are output in the build directory. A %B substitution is introduced in
    lit to refer to the build directory, mirroring the %S substitution for the
    source directory, so that the tests can refer to the configured shell scripts.

Co-authored-by: David Truby <david.truby@arm.com>
Original-commit: flang-compiler/f18@d1c7184159b2d3c542a8f36c58a0c817e7506845
Reviewed-on: https://github.com/flang-compiler/f18/pull/1045

4 years ago[flang] Merge pull request flang-compiler/f18#1083 from DavidTruby/static_cast
Steve Scalpone [Wed, 25 Mar 2020 19:38:50 +0000 (12:38 -0700)]
[flang] Merge pull request flang-compiler/f18#1083 from DavidTruby/static_cast

Add explicit nullptr check in initialisation of inDoConstruct.

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

4 years ago[flang] Add explicit nullptr check in initialisation of inDoConstruct.
David Truby [Thu, 19 Mar 2020 11:04:28 +0000 (11:04 +0000)]
[flang] Add explicit nullptr check in initialisation of inDoConstruct.

This explicit check is needed as we are using braced initialisation here so
implicit narrowing conversions (such as pointer to bool) are not allowed.

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

4 years ago[flang] Merge pull request flang-compiler/f18#1086 from flang-compiler/pmk-entry
Peter Klausler [Tue, 24 Mar 2020 21:48:07 +0000 (14:48 -0700)]
[flang] Merge pull request flang-compiler/f18#1086 from flang-compiler/pmk-entry

Semantics and test for ENTRY statements

Original-commit: flang-compiler/f18@0fafe398b41c3694ca8c7961cdfd1e13970db5e6
Reviewed-on: https://github.com/flang-compiler/f18/pull/1086

4 years ago[flang] Semantics for ENTRY
peter klausler [Thu, 19 Mar 2020 23:31:10 +0000 (16:31 -0700)]
[flang] Semantics for ENTRY

initial test passes

Move some checks to check-declarations

Fix bugs found in testing

Get tests all passing

Allow declaration statements for function result to follow ENTRY

Fix another bug

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

4 years ago[flang] Merge pull request flang-compiler/f18#1084 from flang-compiler/ps-typechecks
Pete Steinfeld [Tue, 24 Mar 2020 17:13:31 +0000 (10:13 -0700)]
[flang] Merge pull request flang-compiler/f18#1084 from flang-compiler/ps-typechecks

Constraint checks C727 to C730 and most constraints related to attributes

Original-commit: flang-compiler/f18@6dbfb80915bcebb9143f87b9d69b0a2667647b90
Reviewed-on: https://github.com/flang-compiler/f18/pull/1084

4 years ago[flang] Changes to enforce constraints C727 to C730 and most constraints related...
Pete Steinfeld [Fri, 20 Mar 2020 03:07:01 +0000 (20:07 -0700)]
[flang] Changes to enforce constraints C727 to C730 and most constraints related to attributes

The full list of constraints is C727, C728, C729, C730, C743, C755, C759, C778,
and C1543.

I added a function to tools.cpp to check to see if a symbol name is the name
of an intrinsic type.

The biggest change was to resolve-names.cpp to check to see if attributes were
either duplicated or in conflict with each other.  I changed all locations
where attributes were set to check for duplicates or conflicts.

I also added tests for all checks and annotated the tests and code with the
numbers of the constraints being tested/checked.

Original-commit: flang-compiler/f18@3f30e8a61e605b9ca6a67791469053286ae563b2
Reviewed-on: https://github.com/flang-compiler/f18/pull/1084

4 years ago[flang] Merge pull request flang-compiler/f18#945 from DavidTruby/clang-format
Steve Scalpone [Tue, 24 Mar 2020 15:12:42 +0000 (08:12 -0700)]
[flang] Merge pull request flang-compiler/f18#945 from DavidTruby/clang-format

Bump clang-format version and remove some differences from LLVM

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

4 years ago[flang] Remove non-alignment based divergences from LLVM formatting.
David Truby [Wed, 18 Mar 2020 16:02:53 +0000 (16:02 +0000)]
[flang] Remove non-alignment based divergences from LLVM formatting.

This only changs the clang-format file and adds documentation
referring to the new process for formatting code. A future commit
will perform a reformatting according to these new formatting
settings.

Original-commit: flang-compiler/f18@02531d788e7550a2455633f87d22e3f30de7a3a7
Reviewed-on: https://github.com/flang-compiler/f18/pull/945

4 years ago[flang] Merge pull request flang-compiler/f18#1032 from DavidTruby/memorybuffer
Steve Scalpone [Tue, 24 Mar 2020 14:55:58 +0000 (07:55 -0700)]
[flang] Merge pull request flang-compiler/f18#1032 from DavidTruby/memorybuffer

Replace manual mmap with llvm::MemoryBuffer

Original-commit: flang-compiler/f18@35f7defccf98823a930ce5d736c3bcba4f143e2e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1032

4 years ago[flang] Replace manual mmap with llvm::MemoryBuffer
David Truby [Thu, 27 Feb 2020 13:42:56 +0000 (13:42 +0000)]
[flang] Replace manual mmap with llvm::MemoryBuffer

The previous code had handling for cases when too many file descriptors may be
opened; this is not necessary with MemoryBuffer as the file descriptors are
closed after the mapping occurs. MemoryBuffer also internally handles the case
where a file is small and therefore an mmap is bad for performance; such files
are simply copied to memory after being opened.

Many places elsewhere in the code assume that the buffer is not empty, and the
old file opening code handles this by replacing an empty file with a buffer
containing a single newline. That behavior is now kept in the new MemoryBuffer
based code.

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

4 years ago[flang] Merge pull request flang-compiler/f18#1047 from CarolineConcatto/llvm_ostream
Steve Scalpone [Thu, 19 Mar 2020 16:31:27 +0000 (09:31 -0700)]
[flang] Merge pull request flang-compiler/f18#1047 from CarolineConcatto/llvm_ostream

[LLVMify F18] Replace the use std::ostream with LLVM streams llvm::ostream

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

4 years ago[flang] [LLVMify F18] Replace the use std::ostream with LLVM streams llvm::ostream
Caroline Concatto [Fri, 28 Feb 2020 15:11:03 +0000 (15:11 +0000)]
[flang] [LLVMify F18] Replace the use std::ostream with LLVM streams llvm::ostream

This patch replaces the occurrence of std::ostream by llvm::raw_ostream.
In  LLVM Coding Standards[1] "All new code should use raw_ostream
instead of ostream".[1]

As a consequence, this patch also replaces the use of:
   std::stringstream by llvm::raw_string_ostream or llvm::raw_ostream*
   std::ofstream by llvm::raw_fd_ostream
   std::endl by '\n' and flush()[2]
   std::cout by llvm::outs()   and
   std::cerr by llvm::errs()

It also replaces  std::strerro by llvm::sys::StrError** , but NOT in  Fortran
runtime libraries

*std::stringstream were replaced by llvm::raw_ostream in all methods that
used std::stringstream as a parameter. Moreover, it removes the pointers to
these streams.

[1]https://llvm.org/docs/CodingStandards.html
[2]https://releases.llvm.org/2.5/docs/CodingStandards.html#ll_avoidendl

Signed-off-by: Caroline Concatto <caroline.concatto@arm.com>
Running clang-format-7

Signed-off-by: Caroline Concatto <caroline.concatto@arm.com>
Removing residue of ostream library

Signed-off-by: Caroline Concatto <caroline.concatto@arm.com>
Original-commit: flang-compiler/f18@a3507d44b8911e6024033aa583c1dc54e0eb89fd
Reviewed-on: https://github.com/flang-compiler/f18/pull/1047

4 years ago[flang] Merge pull request flang-compiler/f18#1076 from flang-compiler/pmk-fix-forward
Peter Klausler [Wed, 18 Mar 2020 21:05:21 +0000 (14:05 -0700)]
[flang] Merge pull request flang-compiler/f18#1076 from flang-compiler/pmk-fix-forward

Support forward references to sibling module procedures

Original-commit: flang-compiler/f18@8c8cdd60914e1438c6861749218893cf655bdbb8
Reviewed-on: https://github.com/flang-compiler/f18/pull/1076

4 years ago[flang] Improve error message for procedure passed as invalid argument to an intrinsic
peter klausler [Fri, 13 Mar 2020 19:19:44 +0000 (12:19 -0700)]
[flang] Improve error message for procedure passed as invalid argument to an intrinsic

Support forward references to sibling module procedures

Add tests, handle corner cases

Rename new test

Original-commit: flang-compiler/f18@234bb519cd38d0b9234fc0b4a8d11cfcb9935e6a
Reviewed-on: https://github.com/flang-compiler/f18/pull/1076

4 years ago[flang] Merge pull request flang-compiler/f18#1080 from flang-compiler/tsk-issue1054
Tim Keith [Wed, 18 Mar 2020 01:54:51 +0000 (18:54 -0700)]
[flang] Merge pull request flang-compiler/f18#1080 from flang-compiler/tsk-issue1054

Fixes for separate module procedures

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

4 years ago[flang] Check module subprogram against separate module procedure
Tim Keith [Tue, 17 Mar 2020 21:48:36 +0000 (14:48 -0700)]
[flang] Check module subprogram against separate module procedure

When a module subprogram has the MODULE prefix the following must match
with the corresponding separate module procedure interface body:
- C1549: characteristics and dummy argument names
- C1550: binding label
- C1551: NON_RECURSIVE prefix

SubprogramMatchHelper performs all of these checks.

Rename separate-module-procs.f90 to separate-mp01.f90 so we can have
separate-mp02.f90 (etc).

Make ShapesAreCompatible public in characteristics.h.

Add Scope::IsSubmodule.

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

4 years ago[flang] Create symbols for args of separate-module-subprogram
Tim Keith [Tue, 17 Mar 2020 21:28:08 +0000 (14:28 -0700)]
[flang] Create symbols for args of separate-module-subprogram

A separate-module-subprogram is declared as `module procedure ...`
and gets its characteristics from the declaration of that name as
a separate module procedure. When we encounter one, we need to create
symbols in the new subprogram scope for the dummy arguments and
function return (if any).

The failure to create these symbols led to the bug in issue flang-compiler/f18#1054:
when a dummy argument was referenced, the compiler interpreted it as
an implicit declaration because there was no symbol for the argument.

Fixes flang-compiler/f18#1054.

Original-commit: flang-compiler/f18@4d3c4bac843dcc6351fbe7538c6ce23bb9c1a215
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
Tree-same-pre-rewrite: false

4 years ago[flang] Fix location of name of Symbol for ProcEntity
Tim Keith [Tue, 17 Mar 2020 20:02:17 +0000 (13:02 -0700)]
[flang] Fix location of name of Symbol for ProcEntity

When we encounter a ProcDecl and a symbol for it has already been
created, replace the CharBlock for the name with the one in the ProcDecl
as it is the "main" declaration of that name. This matches what is done
for an EntityDecl.

This moves the location of some error messages to a better source
location so update the affected tests.

Original-commit: flang-compiler/f18@514c0f2c9477040f830fbf0495e4d38129648615
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
Tree-same-pre-rewrite: false

4 years ago[flang] Merge pull request flang-compiler/f18#1078 from flang-compiler/pmk-no-prefix...
Peter Klausler [Tue, 17 Mar 2020 22:09:55 +0000 (15:09 -0700)]
[flang] Merge pull request flang-compiler/f18#1078 from flang-compiler/pmk-no-prefix-dft-char

Do not emit a prefix for a default-kind character constant in AsFortran

Original-commit: flang-compiler/f18@0011011a04ec13df7bcccd81b2f931f4e420eef9
Reviewed-on: https://github.com/flang-compiler/f18/pull/1078

4 years ago[flang] Do not emit a prefix for a default-kind character constant in AsFortran
peter klausler [Tue, 17 Mar 2020 19:35:31 +0000 (12:35 -0700)]
[flang] Do not emit a prefix for a default-kind character constant in AsFortran

Original-commit: flang-compiler/f18@4a3db55727a93805d3f047713e5d253543ee51fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/1078

4 years ago[flang] Merge pull request flang-compiler/f18#1075 from flang-compiler/tsk-tests
Tim Keith [Mon, 16 Mar 2020 18:10:41 +0000 (11:10 -0700)]
[flang] Merge pull request flang-compiler/f18#1075 from flang-compiler/tsk-tests

Test cleanup

Original-commit: flang-compiler/f18@809f4116f2086a8941bf786a5ac091885283494a
Reviewed-on: https://github.com/flang-compiler/f18/pull/1075

4 years ago[flang] Test cleanup
Tim Keith [Mon, 16 Mar 2020 17:46:17 +0000 (10:46 -0700)]
[flang] Test cleanup

Fix omp-nested01.f90 so that it is not an expected failure. The test was
never enabled but I'm guessing this is what it's supposed to do.

Fix the instructions to include "make test" as part of running tests.

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

4 years ago[flang] Merge pull request flang-compiler/f18#1070 from flang-compiler/pmk-io
Peter Klausler [Mon, 16 Mar 2020 18:02:26 +0000 (11:02 -0700)]
[flang] Merge pull request flang-compiler/f18#1070 from flang-compiler/pmk-io

First cut at runtime API for allocatable management

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

4 years ago[flang] more edits
peter klausler [Fri, 13 Mar 2020 00:07:16 +0000 (17:07 -0700)]
[flang] more edits

Remove AllocateDefaultCharacter

Refinements in code review

Original-commit: flang-compiler/f18@688512ddc671fa1ed54224b7cfef49a1c2284c99
Reviewed-on: https://github.com/flang-compiler/f18/pull/1070

4 years ago[flang] Merge pull request flang-compiler/f18#1073 from flang-compiler/pmk-ptr-asst...
Peter Klausler [Mon, 16 Mar 2020 15:48:02 +0000 (08:48 -0700)]
[flang] Merge pull request flang-compiler/f18#1073 from flang-compiler/pmk-ptr-asst-asfortran

Complete formatting of pointer assignments

Original-commit: flang-compiler/f18@07b8ab1907102ef4d2f6248c0786d3738ae5d871
Reviewed-on: https://github.com/flang-compiler/f18/pull/1073

4 years ago[flang] Complete formatting of pointer assignments, move to formatting.cpp with rest...
peter klausler [Fri, 13 Mar 2020 16:52:15 +0000 (09:52 -0700)]
[flang] Complete formatting of pointer assignments, move to formatting.cpp with rest of AsFortran

Original-commit: flang-compiler/f18@9625317ee8aed40a3827fe551cecf08aa34ee7a2
Reviewed-on: https://github.com/flang-compiler/f18/pull/1073

4 years ago[flang] Merge pull request flang-compiler/f18#1027 from LukeIreland1/master
Steve Scalpone [Fri, 13 Mar 2020 20:07:34 +0000 (13:07 -0700)]
[flang] Merge pull request flang-compiler/f18#1027 from LukeIreland1/master

Porting F18 tests to use LLVM lit without FileCheck

Original-commit: flang-compiler/f18@89bc84fe562ca2a2622438ac14908bce39fa7cfc
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027

4 years ago[flang] Added CMakeLists changes, moved config and made test scripts compatible.
Luke Ireland [Fri, 6 Mar 2020 11:21:36 +0000 (11:21 +0000)]
[flang] Added CMakeLists changes, moved config and made test scripts compatible.

All Fortran tests are now run in lit, except Preprocessing tests flang-compiler/f18#1052
Preprocessing tests are a separate kind of test, so will be sorted out
later.

Original-commit: flang-compiler/f18@3f99d35f3d4f57f704fd91a0d6ba8af308e900b3
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027

4 years ago[flang] Port all remaining regression tests to lit
Luke Ireland [Fri, 14 Feb 2020 14:02:29 +0000 (14:02 +0000)]
[flang] Port all remaining regression tests to lit

We have re-classified a subset of the regression tests as unit tests and
now we are porting the remaining ones.

Test discovery and running is now performed by lit rather than ctest.
The tests continue to use their original scripts with minor
modifications. Most of the changes were mechanical and so scripted.
A few changes were made by hand. Details

Manual:
  * modfile09-*.f90 tests depend on being run together as some tests have
    dependencies on modules created by other tests. This will need
     separating out when porting away from test_modfile.sh, but for now,
     added modfile09-*.f90 to the Inputs directory and added a single
     tests modfile09.f90 to hold the run line.
  * getdefinition03-a.f90 includes a non-test file getdefinition03-b.f90.
    Manually edited the former to find the latter in Inputs so as to add
    only one test.
  * Same pattern for getsymbols03-{a,b}.f90

Auto:
  * Remaining tests have a lit RUN line added to them based on the type
    of test they are.
  * Failing tests also have an XFAIL line added to them.
  * Generic tests have their pre-existing RUN lines replaced with the
    word "EXEC" to avoid conflict with the added lit RUN line.

Original-commit: flang-compiler/f18@63ec0af9f4c8e736a626d1cd1410f71f4e578aa9
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false

4 years ago[flang] Create a separate directory for unittests
Luke Ireland [Wed, 19 Feb 2020 15:49:33 +0000 (15:49 +0000)]
[flang] Create a separate directory for unittests

Some of the regression tests are C programs that act as test harnesses
for the compiler internals as opposed to being Fortran inputs to test
the compiler in action. The former style of tests are analog to LLVM's
unittests and will not use the lit framework.

Change-Id: I0ff10e23f66ff843e8fff4c35cfb6559b9dab762

Original-commit: flang-compiler/f18@2bfddbe8f8898551a28c3ea07b7ae508018f8634
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false

4 years ago[flang] Re-enable semantics/altreturn{02,03} tests
Luke Ireland [Fri, 21 Feb 2020 12:28:58 +0000 (12:28 +0000)]
[flang] Re-enable semantics/altreturn{02,03} tests

These tests were disabled due to https://github.com/flang-compiler/f18/issues/407.
Previously these tests caused F18 to crash as the feature was not fully
implemented.

The altreturn feature is now implemented, so these tests can be
re-enabled. altreturn03 tested some negative cases which F18 correctly
diagnoses. Modified that test to expect these new error messages. Also
make the later cases in the test reachable.

These tests can now be ported by the script to lit-style tests.

Change-Id: Ib336c10d55068d9a26fc2deb43ad052e74e73456

Original-commit: flang-compiler/f18@4de19d7ba2df892ce4361461841c3997de439532
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false

4 years ago[flang] Merge pull request flang-compiler/f18#1071 from flang-compiler/jpr-fix-no...
jeanPerier [Fri, 13 Mar 2020 18:12:04 +0000 (11:12 -0700)]
[flang] Merge pull request flang-compiler/f18#1071 from flang-compiler/jpr-fix-no-side-effects

Support latest LLVM head with FIR - MLIR SideEffects interface change

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

4 years ago[flang] Support latest LLVM head with FIR - MLIR SideEffects interface change
Jean Perier [Fri, 13 Mar 2020 11:06:31 +0000 (04:06 -0700)]
[flang] Support latest LLVM head with FIR - MLIR SideEffects interface change

Include new .td after LLVM changes:
https://github.com/llvm/llvm-project/commit/0ddba0bd59c337f16b51a00cb205ecfda46f97fa

Tested to work with LLVM head ecd3e678bbb11cf899603037ec2c5949b8d7fa6c
from 2020-03-13 01:45 am PCT

Backwards compatible with previous known compatible heads at least back to
fde9d33f7101bac631b26990d17822474d3a34e9 from 2020-03-10, so need to
update LLVM builds if they previously work with FIR.

Original-commit: flang-compiler/f18@45454587c932c23430f0f1eb81df816dd75de86b
Reviewed-on: https://github.com/flang-compiler/f18/pull/1071

4 years ago[flang] Need <algorithm> for std::min and std::max (flang-compiler/f18#1063)
Isuru Fernando [Thu, 12 Mar 2020 17:52:29 +0000 (12:52 -0500)]
[flang] Need <algorithm> for std::min and std::max (flang-compiler/f18#1063)

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

4 years ago[flang] fix typo (flang-compiler/f18#1067)
Eric Schweitz [Thu, 12 Mar 2020 17:25:22 +0000 (10:25 -0700)]
[flang] fix typo (flang-compiler/f18#1067)

Original-commit: flang-compiler/f18@4cdc9f75e2bd81889ccc4e30da8c40b2335f10c0
Reviewed-on: https://github.com/flang-compiler/f18/pull/1067

4 years ago[flang] Added documentation explaining the use of std::list (flang-compiler/f18#988)
David Truby [Thu, 12 Mar 2020 16:38:59 +0000 (16:38 +0000)]
[flang] Added documentation explaining the use of std::list (flang-compiler/f18#988)

Original-commit: flang-compiler/f18@094f55890775362f093bb62c57c13b8d3436c82e
Reviewed-on: https://github.com/flang-compiler/f18/pull/988

4 years ago[flang] Add initial CODE_OWNERS file (flang-compiler/f18#1066)
RichBarton-Arm [Thu, 12 Mar 2020 15:15:20 +0000 (15:15 +0000)]
[flang] Add initial CODE_OWNERS file (flang-compiler/f18#1066)

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

4 years ago[flang] Add Fortran IR (FIR) MLIR dialect implementation (flang-compiler/f18#1035)
jeanPerier [Thu, 12 Mar 2020 04:47:22 +0000 (21:47 -0700)]
[flang] Add Fortran IR (FIR) MLIR dialect implementation (flang-compiler/f18#1035)

Adds FIR library that implements an MLIR dialect to which Fortran
parse-tree will be lowered to.

FIR is defined and documented inside FIROps.td added in this commit.
It is possible to generate a more readable description FIRLangRef.md
from FIROps.td following the related instructions added to the README.md
by this commit.

This patch adds FIR definition and implementation that allow parsing,
printing, and verifying FIR. FIR transformations and lowering to Standard
and LLVM dialects are not part of this patch. The FIR verifiers are verifying
the basic properties of FIR operations in order to provide a sufficient
frame for lowering. Verifiers for more advanced FIR properties can be added
as needed.

Coarrays are not covered by FIR defined in this patch.

This patch also adds tco tool that is meant to process FIR input files and
drives transformations on it. The tco tool is used for testing.
In this patch, it is only used to demonstrate parsing/verifying/
and dumping FIR with round-trip tests.

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:

https://github.com/schweitzpgi/f18/commit/742edde572bd74d77cf7d447132ccf0949187fce
and
https://github.com/schweitzpgi/f18/commit/2ff55242126d86061f4fed9ef7b59d3636b5fd0b

Changes on top of these original commits were made during this patch review.

Original-commit: flang-compiler/f18@30b428a51e140e5fb12bd53a0619f10ff510f408
Reviewed-on: https://github.com/flang-compiler/f18/pull/1035

4 years ago[flang] Merge pull request flang-compiler/f18#1053 from flang-compiler/pmk-io
Peter Klausler [Wed, 11 Mar 2020 21:06:04 +0000 (14:06 -0700)]
[flang] Merge pull request flang-compiler/f18#1053 from flang-compiler/pmk-io

Roll up runtime I/O work

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

4 years ago[flang] Use hash table for UnitMap, avoid C++ STL binary dependence
peter klausler [Thu, 13 Feb 2020 22:41:56 +0000 (14:41 -0800)]
[flang] Use hash table for UnitMap, avoid C++ STL binary dependence

Scan FORMAT strings locally to avoid C++ binary runtime dependence when computing deepest parenthesis nesting

Remove a dependency on ostream from runtime

Remove remaining direct external references from runtime to C++ library binaries

Remove runtime dependences on lib/common

SetPos() and SetRec()

Instantiate templates for input

Begin input; rearrange locking, deal with CLOSE races

View()

Update error message in test to agree with compiler change

First cut at real input

More robust I/O runtime error handling

Debugging of REAL input

Add iostat.{h,cpp}

Rename runtime/numeric-* to runtime/edit-*

Move templates around, templatize integer output editing

Move LOGICAL and CHARACTER output from io-api.cpp to edit-output.cpp

Change pointer argument to reference

More list-directed input

Complex list-directed input

Use enum class Direction rather than bool for templates

Catch up with changes to master

Undo reformatting of Lower code

Use record number instead of subscripts for internal unit

Unformatted sequential backspace

Testing and debugging

Dodge bogus GCC warning

Add <cstddef> for std::size_t to fix CI build

Address review comments

Original-commit: flang-compiler/f18@50406b349609efdde76e48bf2caa039d031dd1c4
Reviewed-on: https://github.com/flang-compiler/f18/pull/1053

4 years ago[flang] Merge pull request flang-compiler/f18#1029 from isuruf/patch-3
Peter Klausler [Wed, 11 Mar 2020 21:04:43 +0000 (14:04 -0700)]
[flang] Merge pull request flang-compiler/f18#1029 from isuruf/patch-3

Fix an ambiguous overload error

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

4 years ago[flang] Fix an ambiguous overload error
Isuru Fernando [Wed, 26 Feb 2020 18:05:28 +0000 (12:05 -0600)]
[flang] Fix an ambiguous overload error

Original-commit: flang-compiler/f18@70fa71ff7be3024a44b8214be663b9701adc5b1f
Reviewed-on: https://github.com/flang-compiler/f18/pull/1029

4 years ago[flang] Merge pull request flang-compiler/f18#1061 from flang-compiler/pmk-shape
Peter Klausler [Wed, 11 Mar 2020 20:21:45 +0000 (13:21 -0700)]
[flang] Merge pull request flang-compiler/f18#1061 from flang-compiler/pmk-shape

Extend shape analysis to cope better with ASSOCIATE construct entities

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

4 years ago[flang] Resolve known problems in shape analysis
peter klausler [Wed, 11 Mar 2020 20:17:03 +0000 (13:17 -0700)]
[flang] Resolve known problems in shape analysis

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

4 years ago[flang] Repair C_LOC
peter klausler [Wed, 11 Mar 2020 18:00:36 +0000 (11:00 -0700)]
[flang] Repair C_LOC

Original-commit: flang-compiler/f18@dc1c95277dd6161ce2d13f971ca91cce3e771e8a
Reviewed-on: https://github.com/flang-compiler/f18/pull/1061
Tree-same-pre-rewrite: false

4 years ago[flang] Extend shape analysis to cope with ASSOCIATE construct entities better
peter klausler [Tue, 10 Mar 2020 23:13:09 +0000 (16:13 -0700)]
[flang] Extend shape analysis to cope with ASSOCIATE construct entities better

Fix incomplete copy&paste

Another review comment addressed

Original-commit: flang-compiler/f18@a2e2593fa5457a7737faab8ee74e5f3b18cd71f7
Reviewed-on: https://github.com/flang-compiler/f18/pull/1061
Tree-same-pre-rewrite: false

4 years ago[flang] Merge pull request flang-compiler/f18#1051 from isuruf/extern
Peter Klausler [Wed, 11 Mar 2020 20:21:15 +0000 (13:21 -0700)]
[flang] Merge pull request flang-compiler/f18#1051 from isuruf/extern

Rename EXTERN_C_END to FORTRAN_EXTERN_C_END

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

4 years ago[flang] Rename EXTERN_C_END to FORTRAN_EXTERN_C_END
Isuru Fernando [Fri, 6 Mar 2020 06:51:41 +0000 (00:51 -0600)]
[flang] Rename EXTERN_C_END to FORTRAN_EXTERN_C_END

Since EXTERN_C_END is a macro defined in Windows system headers

Original-commit: flang-compiler/f18@4c6e5608adddf25a53fbdbfd5f0e1b98278cc5ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/1051

4 years ago[flang] Merge pull request flang-compiler/f18#1062 from flang-compiler/tsk-vector...
Tim Keith [Tue, 10 Mar 2020 23:41:43 +0000 (16:41 -0700)]
[flang] Merge pull request flang-compiler/f18#1062 from flang-compiler/tsk-vector-subscript

Allow for vector subscript on LHS of assignment

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

4 years ago[flang] Allow for vector subscript on LHS of assignment
Tim Keith [Tue, 10 Mar 2020 23:32:58 +0000 (16:32 -0700)]
[flang] Allow for vector subscript on LHS of assignment

Original-commit: flang-compiler/f18@38aefd41f051546024ecf4555a3bb3385b99f3c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/1062

4 years ago[flang] Merge pull request flang-compiler/f18#1060 from flang-compiler/tsk-scope...
Tim Keith [Tue, 10 Mar 2020 22:49:14 +0000 (15:49 -0700)]
[flang] Merge pull request flang-compiler/f18#1060 from flang-compiler/tsk-scope-contains

Fix scope accessibility check

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

4 years ago[flang] Fix scope accessibility check
Tim Keith [Tue, 10 Mar 2020 22:31:02 +0000 (15:31 -0700)]
[flang] Fix scope accessibility check

The check for whether a private component is accessible was depending on
determining whether the source range of the current scope was within the
source range of the module that the component was declared in. This
could fail if the current scope was of kind `ImpliedDos` and had no
source range.

The fix is to add `Scope::Contains` to check the relationship by
traversing the parent links. These are created when the Scope is so are
always reliable. The source range of a scope is built up over time.

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

4 years ago[flang] Merge pull request flang-compiler/f18#1059 from flang-compiler/pmk-clang
Peter Klausler [Tue, 10 Mar 2020 20:43:00 +0000 (13:43 -0700)]
[flang] Merge pull request flang-compiler/f18#1059 from flang-compiler/pmk-clang

Changes that enable f18 build with latest clang

Original-commit: flang-compiler/f18@9e628b633cad8ed07a89f4e270828370c826ab24
Reviewed-on: https://github.com/flang-compiler/f18/pull/1059

4 years ago[flang] Changes to get a clean build of f18 with latest clang
peter klausler [Tue, 10 Mar 2020 17:28:36 +0000 (10:28 -0700)]
[flang] Changes to get a clean build of f18 with latest clang

Prep for review

Original-commit: flang-compiler/f18@111f49061e07604670614250197a1064959fd981
Reviewed-on: https://github.com/flang-compiler/f18/pull/1059

4 years ago[flang] Merge pull request flang-compiler/f18#1050 from flang-compiler/tsk-assign
Tim Keith [Tue, 10 Mar 2020 01:08:19 +0000 (18:08 -0700)]
[flang] Merge pull request flang-compiler/f18#1050 from flang-compiler/tsk-assign

Perform definability checks on LHS of assignment

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

4 years ago[flang] Perform definability checks on LHS of assignment
Tim Keith [Fri, 6 Mar 2020 01:55:51 +0000 (17:55 -0800)]
[flang] Perform definability checks on LHS of assignment

If the pure context check succeeds, call `WhyNotModifiable` to verify
the LHS can be modified.

Detect assignment to whole assumed-size array.

Change `IsVariable` to return false for a parameter or a component or
array reference whose base it a parameter.

When analyzing an assignment statement, report an error if the LHS is
a constant expression. Otherwise it might get folded and when we detect
the problem later the error will be confusing.

Handle Substring on LHS of assignment. Change ExtractDataRef and IsVariable
to work on a Substring.

Fix IsImpliedShape and IsAssumedSize predicates in ArraySpec.

Fix C709 check in check-declarations.cpp.

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

4 years ago[flang] Change CheckDefinabilityInPureScope to return bool
Tim Keith [Thu, 5 Mar 2020 21:05:45 +0000 (13:05 -0800)]
[flang] Change CheckDefinabilityInPureScope to return bool

Have CheckDefinabilityInPureScope and CheckCopyabilityInPureScope return
false when their checks fail and report errors so that we will be able
to avoid reporting extra errors in those cases.

Original-commit: flang-compiler/f18@305a3470e572161483b0f430514b77ba19f932ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
Tree-same-pre-rewrite: false

4 years ago[flang] Change WhyNotModifiable to return optional
Tim Keith [Thu, 5 Mar 2020 20:56:30 +0000 (12:56 -0800)]
[flang] Change WhyNotModifiable to return optional

One overload of WhyNotModifiable returned an optional message while the
other returns a unique_ptr. Change the latter to be consistent with the
former and other message-returning functions in this file.

Also, reorder the if clauses to reduce the level of indentation.

Original-commit: flang-compiler/f18@864e9cfc7ee98e3646052fdc757943011d641691
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
Tree-same-pre-rewrite: false

4 years ago[flang] Fix handling of DataRef when analyzing CoindexedNamedObject
Tim Keith [Sat, 7 Mar 2020 01:05:04 +0000 (17:05 -0800)]
[flang] Fix handling of DataRef when analyzing CoindexedNamedObject

As we loop through the Components, maintain a pointer to the current
DataRef rather than moving it. This is more efficient and the previous
behavior caused illegal memory accesses.

Original-commit: flang-compiler/f18@cede2971ff863b8dd6a2c8727f6566a444ac7a52
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
Tree-same-pre-rewrite: false

4 years ago[flang] Fix for 'wrong constant folding of assumed-rank array' (flang-compiler/f18...
Steve Scalpone [Thu, 5 Mar 2020 16:06:58 +0000 (08:06 -0800)]
[flang] Fix for 'wrong constant folding of assumed-rank array' (flang-compiler/f18#1010)

https://github.com/flang-compiler/f18/issues/990

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

4 years ago[flang] Change README to refer to LLVM_BUILD_DIR. (flang-compiler/f18#1033)
Steve Scalpone [Thu, 5 Mar 2020 15:12:06 +0000 (07:12 -0800)]
[flang] Change README to refer to LLVM_BUILD_DIR. (flang-compiler/f18#1033)

* Change README to refer to LLVM_BUILD_DIR.

LLVM_INSTALL_TOOLS doesn't to install llvm-lit. However pointing to the cmake file in the build directory works fine, and lit and FileCheck will be picked up correctly this way.

Original-commit: flang-compiler/f18@3cbe344f82a0898c9e20b6718d5f80d52670838b
Reviewed-on: https://github.com/flang-compiler/f18/pull/1033

4 years ago[flang] Use a file descriptor in Temp struct (flang-compiler/f18#1036)
Steve Scalpone [Thu, 5 Mar 2020 15:09:29 +0000 (07:09 -0800)]
[flang] Use a file descriptor in Temp struct (flang-compiler/f18#1036)

The struct Temp is used in the function call createUniqueFile
which only takes in a file descriptor instead of a file handler.
In Unix these are the same thing, but in Windows they are different.
Therefore, the type of the member of struct Temp is changed
from file handler to file descriptor and when closing the file
the file descriptor is converted to a file handler.

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

4 years ago[flang] Use std::mutex instead of pthreads (flang-compiler/f18#1006)
Steve Scalpone [Thu, 5 Mar 2020 14:52:35 +0000 (06:52 -0800)]
[flang] Use std::mutex instead of pthreads (flang-compiler/f18#1006)

* Use std::mutex for portability.

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

4 years ago[flang] Add missing include <algorithm> for std::max (flang-compiler/f18#1028)
Steve Scalpone [Thu, 5 Mar 2020 14:31:24 +0000 (06:31 -0800)]
[flang] Add missing include <algorithm> for std::max (flang-compiler/f18#1028)

Original-commit: flang-compiler/f18@0e32eebf7fec8cd07ab3280565799cfbf2ca55e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/1028

4 years ago[flang] Don't link to libm (flang-compiler/f18#1038)
Steve Scalpone [Thu, 5 Mar 2020 13:40:44 +0000 (05:40 -0800)]
[flang] Don't link to libm (flang-compiler/f18#1038)

* Don't link to libm on windows

* Don't link to libm in Unix as well

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

4 years ago[flang] Merge pull request flang-compiler/f18#1043 from DavidTruby/zlib
Eric Schweitz [Wed, 4 Mar 2020 23:57:09 +0000 (15:57 -0800)]
[flang] Merge pull request flang-compiler/f18#1043 from DavidTruby/zlib

Link against zlib when LLVM does.

Original-commit: flang-compiler/f18@8b0a473069cb3691d604f72d7f9a5200aa7f1c01
Reviewed-on: https://github.com/flang-compiler/f18/pull/1043

4 years ago[flang] Link against zlib when LLVM does.
David Truby [Mon, 2 Mar 2020 13:35:24 +0000 (13:35 +0000)]
[flang] Link against zlib when LLVM does.

Original-commit: flang-compiler/f18@2260abe4c27a76e374b286df072e303aa9ea1418
Reviewed-on: https://github.com/flang-compiler/f18/pull/1043

4 years ago[flang] Merge pull request flang-compiler/f18#1046 from flang-compiler/tsk-comps
Tim Keith [Tue, 3 Mar 2020 21:28:04 +0000 (13:28 -0800)]
[flang] Merge pull request flang-compiler/f18#1046 from flang-compiler/tsk-comps

Improve checking of structure constructor keywords

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

4 years ago[flang] Improve checking of structure constructor arguments
Tim Keith [Tue, 3 Mar 2020 00:43:01 +0000 (16:43 -0800)]
[flang] Improve checking of structure constructor arguments

When a misparsed FunctionReference was converted to a StructureConstructor,
the components accessed were not checked for accessibility.

The conversion happens in expression analysis so that where the accessibity
must be checked. So move `CheckAccessibleComponent` to `tools.h` so that it
can be shared by `resolve-names.cpp` and `expression.cpp`.

Add FindModuleContaining to help implement this and use it other places.

Check that an access-spec can only appear in a module.

Remove some unnecessary "semantics::" qualifiers.

Original-commit: flang-compiler/f18@99ce156e49ec0847ce42a6d10f0a62664714092b
Reviewed-on: https://github.com/flang-compiler/f18/pull/1046

4 years ago[flang] Merge pull request flang-compiler/f18#1039 from flang-compiler/tsk-arrays
Tim Keith [Tue, 3 Mar 2020 00:53:22 +0000 (16:53 -0800)]
[flang] Merge pull request flang-compiler/f18#1039 from flang-compiler/tsk-arrays

Improve array element errors

Original-commit: flang-compiler/f18@899ef78d6aac3a1c5e8264100165dcc2521684c6
Reviewed-on: https://github.com/flang-compiler/f18/pull/1039

4 years ago[flang] Improve array element errors
Tim Keith [Fri, 28 Feb 2020 02:00:45 +0000 (18:00 -0800)]
[flang] Improve array element errors

When something is parsed as an array element it was sometimes intended
to be a function call or structure constructor. So if the base name is
not found the errors can be confusing. This is an attempt to improve
them.

When the subscript list is empty, it was probably meant to be a function
call, so report that the name is not a function.

If the base is a scalar but there are subscripts, report that it is not
an array.

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

4 years ago[flang] Merge pull request flang-compiler/f18#1044 from flang-compiler/tsk-data
Tim Keith [Mon, 2 Mar 2020 21:37:33 +0000 (13:37 -0800)]
[flang] Merge pull request flang-compiler/f18#1044 from flang-compiler/tsk-data

Expression analysis on DataStmtConstant

Original-commit: flang-compiler/f18@1611fd8e9e237dc86266b146309931428d228ace
Reviewed-on: https://github.com/flang-compiler/f18/pull/1044

4 years ago[flang] Expression analysis on DataStmtConstant
Tim Keith [Mon, 2 Mar 2020 15:59:29 +0000 (07:59 -0800)]
[flang] Expression analysis on DataStmtConstant

Data statements contains expressions but they are not wrapped in one of
the kinds of parse tree nodes that are analyzed, like `parser::Expr`.
So potential errors were not discovered.

Change `ExprChecker` to handle `DataStmtConstant` and analyze any
expressions that are contained in it. Note that the analyzed form of
the expression is not yet saved in the parse tree.

Original-commit: flang-compiler/f18@8bdaf0a521f6630ec2c369b2c41484eff4803d6e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1044

4 years ago[flang] Merge pull request flang-compiler/f18#1037 from vjayathirtha-nv/master
vjayathirtha-nv [Fri, 28 Feb 2020 00:05:22 +0000 (16:05 -0800)]
[flang] Merge pull request flang-compiler/f18#1037 from vjayathirtha-nv/master

Add semantic checks C8104, C8105. Add tests for C8103, C8104, C8105

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

4 years ago[flang] Add semantic checks C8104, C8105. Add tests for C8103, C8104, C8105
Varun Jayathirtha [Wed, 26 Feb 2020 02:01:23 +0000 (18:01 -0800)]
[flang] Add semantic checks C8104, C8105. Add tests for C8103, C8104, C8105

Original-commit: flang-compiler/f18@8134fc477e843d9bf525eeb552ba1d234140e7a7
Reviewed-on: https://github.com/flang-compiler/f18/pull/1037

4 years ago[flang] Merge pull request flang-compiler/f18#1031 from flang-compiler/ps-types
psteinfeld [Thu, 27 Feb 2020 21:57:27 +0000 (13:57 -0800)]
[flang] Merge pull request flang-compiler/f18#1031 from flang-compiler/ps-types

Semantic checks for C712 through C727

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

4 years ago[flang] Responses to pull request comments
Pete Steinfeld [Thu, 27 Feb 2020 16:49:40 +0000 (08:49 -0800)]
[flang] Responses to pull request comments

I cleaned up some code and reverted a change to semantic checking for
the exponent letter in REAL literals.

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

4 years ago[flang] Semantic checks for C712 through C727
Pete Steinfeld [Thu, 27 Feb 2020 04:19:48 +0000 (20:19 -0800)]
[flang] Semantic checks for C712 through C727

I've updated the compiler and test source with references to the contraints at
the points where they were enforced and tested.  Many of these were already
implemented and required no code change.  A few constraint checks were both
implemented and tested, and I only added references to the constraint
numbers in the compiler source and tests.  Here are the things I had to
implement:

Constraint C716 states that, in a REAL constant, if both a kind-param and an
exponent letter appear, the exponent letter must be 'E'.

Constraints C715 and C719 require that a KIND value be actually implemented.

Constraint C722 requires that functions that return assumed-length character
types are external.

Constraint C726 disallows assumed lenght charater types for dummy arguments and
return types.

Original-commit: flang-compiler/f18@45998741e5f04bba7db6eed6a4d27c1d25209b41
Reviewed-on: https://github.com/flang-compiler/f18/pull/1031
Tree-same-pre-rewrite: false

4 years ago[flang] Merge pull request flang-compiler/f18#1024 from flang-compiler/tsk-rewrite
Tim Keith [Thu, 27 Feb 2020 03:20:57 +0000 (19:20 -0800)]
[flang] Merge pull request flang-compiler/f18#1024 from flang-compiler/tsk-rewrite

Fix misparsed structure constructor in data stmt

Original-commit: flang-compiler/f18@7649e5d705b2c87d710525d522a42288030c3bfa
Reviewed-on: https://github.com/flang-compiler/f18/pull/1024

4 years ago[flang] Fix misparsed structure constructor in data stmt
Tim Keith [Wed, 26 Feb 2020 01:13:56 +0000 (17:13 -0800)]
[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@a2b2a330e7dbb8d719fdab9bb28921cf84f503ca
Reviewed-on: https://github.com/flang-compiler/f18/pull/1024

4 years ago[flang] Merge pull request flang-compiler/f18#1014 from flang-compiler/tsk-where
Tim Keith [Thu, 27 Feb 2020 00:10:49 +0000 (16:10 -0800)]
[flang] Merge pull request flang-compiler/f18#1014 from flang-compiler/tsk-where

Remove use of std::set::merge

Original-commit: flang-compiler/f18@59c14bad32093f5ccfcd0a05e337295c2c1c85ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/1014

4 years ago[flang] Remove use of std::set::merge
Tim Keith [Sat, 22 Feb 2020 19:47:04 +0000 (11:47 -0800)]
[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@886ccc37fbff5df00717ac728e2aba240d0a314c
Reviewed-on: https://github.com/flang-compiler/f18/pull/1014

4 years ago[flang] Add script to flatten git history for llvm monorepo submission (flang-compile...
Peter Waller [Wed, 26 Feb 2020 19:50:43 +0000 (19:50 +0000)]
[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@d9871fa9eb2304c4761a4a818187553396bb8924
Reviewed-on: https://github.com/flang-compiler/f18/pull/854

4 years ago[flang] Merge pull request flang-compiler/f18#1021 from flang-compiler/pmk-ieee-128
Peter Klausler [Wed, 26 Feb 2020 16:54:41 +0000 (08:54 -0800)]
[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@91feed7a3841bb4f865353ebd7790c39ea926390
Reviewed-on: https://github.com/flang-compiler/f18/pull/1021

4 years ago[flang] Fix layout of 128-bit IEEE-754 floating-point values
peter klausler [Tue, 25 Feb 2020 01:04:54 +0000 (17:04 -0800)]
[flang] Fix layout of 128-bit IEEE-754 floating-point values

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

4 years ago[flang] Merge pull request flang-compiler/f18#1026 from flang-compiler/jpr-drone-fix
jeanPerier [Wed, 26 Feb 2020 15:15:42 +0000 (07:15 -0800)]
[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@a5644a4e8e81c47de1352829a562193e7cfaff03
Reviewed-on: https://github.com/flang-compiler/f18/pull/1026

4 years ago[flang] Remove clang from LLVM drone builds until needed to fasten builds
Jean Perier [Wed, 26 Feb 2020 14:16:22 +0000 (06:16 -0800)]
[flang] Remove clang from LLVM drone builds until needed to fasten builds

Original-commit: flang-compiler/f18@5eaebc800caa90b592c5ba8cf1fd6fd3987b3636
Reviewed-on: https://github.com/flang-compiler/f18/pull/1026

4 years ago[flang] Fix drone CI build failure due to lack of FileCheck
Jean Perier [Wed, 26 Feb 2020 10:01:02 +0000 (02:01 -0800)]
[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@7848ab146ad32062daba9f07b032655568381a1b
Reviewed-on: https://github.com/flang-compiler/f18/pull/1026
Tree-same-pre-rewrite: false

4 years ago[flang] Merge pull request flang-compiler/f18#1023 from flang-compiler/tsk-issue1022
Tim Keith [Tue, 25 Feb 2020 23:32:06 +0000 (15:32 -0800)]
[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@618dc08139664c944f57b6763751b264ca2cf579
Reviewed-on: https://github.com/flang-compiler/f18/pull/1023

4 years ago[flang] Allow for access-stmt before namelist-stmt
Tim Keith [Tue, 25 Feb 2020 02:55:53 +0000 (18:55 -0800)]
[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@a759204db583d337dda886acf748e0fe135c6259
Reviewed-on: https://github.com/flang-compiler/f18/pull/1023

4 years ago[flang] Replace module writer posix file handling with llvm file handling. (flang...
David Truby [Tue, 25 Feb 2020 15:59:50 +0000 (15:59 +0000)]
[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@97efc0194d411a17ec47edf5e27157d1a1afa3bc
Reviewed-on: https://github.com/flang-compiler/f18/pull/993

4 years ago[flang] [LLVMify F18] Compiler module folders should have capitalised names (flang...
CarolineConcatto [Tue, 25 Feb 2020 15:11:52 +0000 (15:11 +0000)]
[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@d2eb7a1c443d1539ef12b6f027074a0eb15b1ea0
Reviewed-on: https://github.com/flang-compiler/f18/pull/980

4 years ago[flang] Merge pull request flang-compiler/f18#1013 from flang-compiler/tsk-rewrite
Tim Keith [Sat, 22 Feb 2020 00:25:54 +0000 (16:25 -0800)]
[flang] Merge pull request flang-compiler/f18#1013 from flang-compiler/tsk-rewrite

Temporarily disable part of data01 test

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

4 years ago[flang] Temporarily disable part of data01 test
Tim Keith [Sat, 22 Feb 2020 00:25:10 +0000 (16:25 -0800)]
[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@72aa278f0341f345a12fcd76a6ad1f2045ecc233
Reviewed-on: https://github.com/flang-compiler/f18/pull/1013

4 years ago[flang] Merge pull request flang-compiler/f18#1009 from flang-compiler/tsk-where
Tim Keith [Fri, 21 Feb 2020 23:48:52 +0000 (15:48 -0800)]
[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@c9638d10c6515703e8c095127bd46ae1dae1637e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1009

4 years ago[flang] Add more checks on WHERE and FORALL
Tim Keith [Thu, 20 Feb 2020 22:54:46 +0000 (14:54 -0800)]
[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@8b04dbebcf5621cfd571a8c45878cebcd1a1bfb0
Reviewed-on: https://github.com/flang-compiler/f18/pull/1009

4 years ago[flang] Merge pull request flang-compiler/f18#1012 from flang-compiler/tsk-rewrite
Tim Keith [Fri, 21 Feb 2020 23:46:24 +0000 (15:46 -0800)]
[flang] Merge pull request flang-compiler/f18#1012 from flang-compiler/tsk-rewrite

Fix parsing bug on DATA statement

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

4 years ago[flang] Fix parsing bug on DATA statement
Tim Keith [Fri, 21 Feb 2020 23:31:12 +0000 (15:31 -0800)]
[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@04a76b272675d47ec7752420b15976c69a907dab
Reviewed-on: https://github.com/flang-compiler/f18/pull/1012

4 years ago[flang] Issue flang-compiler/f18#992 : Implementing Semantic checks for DATA Stateme...
Anchu Rajendran S [Fri, 21 Feb 2020 06:19:14 +0000 (11:49 +0530)]
[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@822129736b6b7a96b6ff3ffe810d842ce42e3672
Reviewed-on: https://github.com/flang-compiler/f18/pull/992