Commit graph

2990 commits

Author SHA1 Message Date
Steve Scalpone 53d5d9f631 [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@d14e0aa936
Reviewed-on: https://github.com/flang-compiler/f18/pull/1083
2020-03-25 12:38:50 -07:00
David Truby cc77f818f2 [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@ff8dad10bf
Reviewed-on: https://github.com/flang-compiler/f18/pull/1083
2020-03-25 18:37:31 +00:00
Peter Klausler 63fb36c494 [flang] Merge pull request flang-compiler/f18#1086 from flang-compiler/pmk-entry
Semantics and test for ENTRY statements

Original-commit: flang-compiler/f18@0fafe398b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/1086
2020-03-24 14:48:07 -07:00
peter klausler c42f6314eb [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@e82cfee432
Reviewed-on: https://github.com/flang-compiler/f18/pull/1086
2020-03-24 14:30:34 -07:00
Pete Steinfeld 55a500989a [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@6dbfb80915
Reviewed-on: https://github.com/flang-compiler/f18/pull/1084
2020-03-24 10:13:31 -07:00
Pete Steinfeld e17e71735e [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@3f30e8a61e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1084
2020-03-24 09:24:49 -07:00
Steve Scalpone 23c227a971 [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@a999575211
Reviewed-on: https://github.com/flang-compiler/f18/pull/945
2020-03-24 08:12:42 -07:00
David Truby 3214c18774 [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@02531d788e
Reviewed-on: https://github.com/flang-compiler/f18/pull/945
2020-03-23 17:52:22 +00:00
Steve Scalpone 37524c901a [flang] Merge pull request flang-compiler/f18#1032 from DavidTruby/memorybuffer
Replace manual mmap with llvm::MemoryBuffer

Original-commit: flang-compiler/f18@35f7defccf
Reviewed-on: https://github.com/flang-compiler/f18/pull/1032
2020-03-24 07:55:58 -07:00
David Truby 13ea73e42d [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@d34df84351
Reviewed-on: https://github.com/flang-compiler/f18/pull/1032
2020-03-24 13:35:01 +00:00
Steve Scalpone 901198441f [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@a65b690ef0
Reviewed-on: https://github.com/flang-compiler/f18/pull/1047
2020-03-19 09:31:27 -07:00
Caroline Concatto 8670e49901 [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@a3507d44b8
Reviewed-on: https://github.com/flang-compiler/f18/pull/1047
2020-03-19 07:54:36 +00:00
Peter Klausler fc23a1bb79 [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@8c8cdd6091
Reviewed-on: https://github.com/flang-compiler/f18/pull/1076
2020-03-18 14:05:21 -07:00
peter klausler 9977b24a6d [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@234bb519cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/1076
2020-03-18 14:04:08 -07:00
Tim Keith 206763bfcf [flang] Merge pull request flang-compiler/f18#1080 from flang-compiler/tsk-issue1054
Fixes for separate module procedures

Original-commit: flang-compiler/f18@bb225be9b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
2020-03-17 18:54:51 -07:00
Tim Keith 61b1390e2a [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@d121578af1
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
2020-03-17 16:01:59 -07:00
Tim Keith 824d198e31 [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@4d3c4bac84
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
Tree-same-pre-rewrite: false
2020-03-17 16:01:59 -07:00
Tim Keith d1ce4d275f [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@514c0f2c94
Reviewed-on: https://github.com/flang-compiler/f18/pull/1080
Tree-same-pre-rewrite: false
2020-03-17 16:01:59 -07:00
Peter Klausler 8aa62d81e8 [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@0011011a04
Reviewed-on: https://github.com/flang-compiler/f18/pull/1078
2020-03-17 15:09:55 -07:00
peter klausler f4faeefe3d [flang] Do not emit a prefix for a default-kind character constant in AsFortran
Original-commit: flang-compiler/f18@4a3db55727
Reviewed-on: https://github.com/flang-compiler/f18/pull/1078
2020-03-17 12:35:31 -07:00
Tim Keith d2c87e0b36 [flang] Merge pull request flang-compiler/f18#1075 from flang-compiler/tsk-tests
Test cleanup

Original-commit: flang-compiler/f18@809f4116f2
Reviewed-on: https://github.com/flang-compiler/f18/pull/1075
2020-03-16 11:10:41 -07:00
Tim Keith 6905526a10 [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@c351181cab
Reviewed-on: https://github.com/flang-compiler/f18/pull/1075
2020-03-16 10:46:17 -07:00
Peter Klausler 631513fd39 [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@d9232d6efd
Reviewed-on: https://github.com/flang-compiler/f18/pull/1070
2020-03-16 11:02:26 -07:00
peter klausler 2bd473de82 [flang] more edits
Remove AllocateDefaultCharacter

Refinements in code review

Original-commit: flang-compiler/f18@688512ddc6
Reviewed-on: https://github.com/flang-compiler/f18/pull/1070
2020-03-16 09:57:12 -07:00
Peter Klausler bc0825f96b [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@07b8ab1907
Reviewed-on: https://github.com/flang-compiler/f18/pull/1073
2020-03-16 08:48:02 -07:00
peter klausler 38ebace5b7 [flang] Complete formatting of pointer assignments, move to formatting.cpp with rest of AsFortran
Original-commit: flang-compiler/f18@9625317ee8
Reviewed-on: https://github.com/flang-compiler/f18/pull/1073
2020-03-13 09:52:15 -07:00
Steve Scalpone d91c28e453 [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@89bc84fe56
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
2020-03-13 13:07:34 -07:00
Luke Ireland da9d002b18 [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@3f99d35f3d
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
2020-03-13 13:54:24 +00:00
Luke Ireland f1a8eae3b6 [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@63ec0af9f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false
2020-03-13 11:58:11 +00:00
Luke Ireland ee5fa1f233 [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@2bfddbe8f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false
2020-03-13 11:58:11 +00:00
Luke Ireland a9d9261cf3 [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@4de19d7ba2
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false
2020-03-13 11:58:11 +00:00
jeanPerier 9509a2f676 [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@d9fadfacbc
Reviewed-on: https://github.com/flang-compiler/f18/pull/1071
2020-03-13 11:12:04 -07:00
Jean Perier f856a5526a [flang] Support latest LLVM head with FIR - MLIR SideEffects interface change
Include new .td after LLVM changes:
0ddba0bd59

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

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

Original-commit: flang-compiler/f18@45454587c9
Reviewed-on: https://github.com/flang-compiler/f18/pull/1071
2020-03-13 04:06:31 -07:00
Isuru Fernando 231fae9087 [flang] Need <algorithm> for std::min and std::max (flang-compiler/f18#1063)
Original-commit: flang-compiler/f18@d0f9ef7742
Reviewed-on: https://github.com/flang-compiler/f18/pull/1063
2020-03-12 10:52:29 -07:00
Eric Schweitz 324bab9bf4 [flang] fix typo (flang-compiler/f18#1067)
Original-commit: flang-compiler/f18@4cdc9f75e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/1067
2020-03-12 10:25:22 -07:00
David Truby 232711df35 [flang] Added documentation explaining the use of std::list (flang-compiler/f18#988)
Original-commit: flang-compiler/f18@094f558907
Reviewed-on: https://github.com/flang-compiler/f18/pull/988
2020-03-12 09:38:59 -07:00
RichBarton-Arm 3064bdcce9 [flang] Add initial CODE_OWNERS file (flang-compiler/f18#1066)
Original-commit: flang-compiler/f18@e5f369d086
Reviewed-on: https://github.com/flang-compiler/f18/pull/1066
2020-03-12 08:15:20 -07:00
jeanPerier 57f536a448 [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:

742edde572
and
2ff5524212

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

Original-commit: flang-compiler/f18@30b428a51e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1035
2020-03-11 21:47:22 -07:00
Peter Klausler 989cbfb0c4 [flang] Merge pull request flang-compiler/f18#1053 from flang-compiler/pmk-io
Roll up runtime I/O work

Original-commit: flang-compiler/f18@bcb8565a93
Reviewed-on: https://github.com/flang-compiler/f18/pull/1053
2020-03-11 14:06:04 -07:00
peter klausler 3b63571425 [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@50406b3496
Reviewed-on: https://github.com/flang-compiler/f18/pull/1053
2020-03-11 13:23:39 -07:00
Peter Klausler e1ba511c2c [flang] Merge pull request flang-compiler/f18#1029 from isuruf/patch-3
Fix an ambiguous overload error

Original-commit: flang-compiler/f18@c39a22b6e4
Reviewed-on: https://github.com/flang-compiler/f18/pull/1029
2020-03-11 14:04:43 -07:00
Isuru Fernando 0a8a6cd921 [flang] Fix an ambiguous overload error
Original-commit: flang-compiler/f18@70fa71ff7b
Reviewed-on: https://github.com/flang-compiler/f18/pull/1029
2020-03-05 09:19:11 -06:00
Peter Klausler 83ccf62e86 [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@abee106168
Reviewed-on: https://github.com/flang-compiler/f18/pull/1061
2020-03-11 13:21:45 -07:00
peter klausler f7432ca7a6 [flang] Resolve known problems in shape analysis
Original-commit: flang-compiler/f18@ed2e4842d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/1061
2020-03-11 13:17:03 -07:00
peter klausler 771c21c19f [flang] Repair C_LOC
Original-commit: flang-compiler/f18@dc1c95277d
Reviewed-on: https://github.com/flang-compiler/f18/pull/1061
Tree-same-pre-rewrite: false
2020-03-11 11:00:36 -07:00
peter klausler 886fb42ece [flang] Extend shape analysis to cope with ASSOCIATE construct entities better
Fix incomplete copy&paste

Another review comment addressed

Original-commit: flang-compiler/f18@a2e2593fa5
Reviewed-on: https://github.com/flang-compiler/f18/pull/1061
Tree-same-pre-rewrite: false
2020-03-10 16:46:25 -07:00
Peter Klausler 84319aba7d [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@b04233ea55
Reviewed-on: https://github.com/flang-compiler/f18/pull/1051
2020-03-11 13:21:15 -07:00
Isuru Fernando 59baf8b822 [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@4c6e5608ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/1051
2020-03-06 00:51:41 -06:00
Tim Keith 78f45d4efe [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@ed6e34d33b
Reviewed-on: https://github.com/flang-compiler/f18/pull/1062
2020-03-10 16:41:43 -07:00
Tim Keith a40dbe7c41 [flang] Allow for vector subscript on LHS of assignment
Original-commit: flang-compiler/f18@38aefd41f0
Reviewed-on: https://github.com/flang-compiler/f18/pull/1062
2020-03-10 16:32:58 -07:00