Commit graph

2973 commits

Author SHA1 Message Date
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
Tim Keith 49422bb83a [flang] Merge pull request flang-compiler/f18#1060 from flang-compiler/tsk-scope-contains
Fix scope accessibility check

Original-commit: flang-compiler/f18@e671fc0754
Reviewed-on: https://github.com/flang-compiler/f18/pull/1060
2020-03-10 15:49:14 -07:00
Tim Keith 6ab50745c0 [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@d787108637
Reviewed-on: https://github.com/flang-compiler/f18/pull/1060
2020-03-10 15:31:02 -07:00
Peter Klausler 749be7993e [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@9e628b633c
Reviewed-on: https://github.com/flang-compiler/f18/pull/1059
2020-03-10 13:43:00 -07:00
peter klausler e03b20e66e [flang] Changes to get a clean build of f18 with latest clang
Prep for review

Original-commit: flang-compiler/f18@111f49061e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1059
2020-03-10 13:12:52 -07:00
Tim Keith 330ca1ea68 [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@a7b49f99a6
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
2020-03-09 18:08:19 -07:00
Tim Keith a0a1f519c0 [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@f2d2657aab
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
2020-03-09 17:25:12 -07:00
Tim Keith c97e1c0a45 [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@305a3470e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
Tree-same-pre-rewrite: false
2020-03-09 17:25:12 -07:00
Tim Keith 2cc21cecf2 [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@864e9cfc7e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
Tree-same-pre-rewrite: false
2020-03-09 17:25:12 -07:00
Tim Keith 0b130278a0 [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@cede2971ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/1050
Tree-same-pre-rewrite: false
2020-03-09 17:25:12 -07:00
Steve Scalpone e0ca7b447b [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@d971333025
Reviewed-on: https://github.com/flang-compiler/f18/pull/1010
2020-03-05 08:06:58 -08:00
Steve Scalpone a705a4a314 [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@3cbe344f82
Reviewed-on: https://github.com/flang-compiler/f18/pull/1033
2020-03-05 07:12:06 -08:00
Steve Scalpone 61106305b6 [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@a8edb328f7
Reviewed-on: https://github.com/flang-compiler/f18/pull/1036
2020-03-05 07:09:29 -08:00
Steve Scalpone e8f09da68d [flang] Use std::mutex instead of pthreads (flang-compiler/f18#1006)
* Use std::mutex for portability.

Original-commit: flang-compiler/f18@a9a725eb9d
Reviewed-on: https://github.com/flang-compiler/f18/pull/1006
2020-03-05 06:52:35 -08:00
Steve Scalpone 5dfd2b06d4 [flang] Add missing include <algorithm> for std::max (flang-compiler/f18#1028)
Original-commit: flang-compiler/f18@0e32eebf7f
Reviewed-on: https://github.com/flang-compiler/f18/pull/1028
2020-03-05 06:31:24 -08:00
Steve Scalpone e94ee41ec2 [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@a807862ab8
Reviewed-on: https://github.com/flang-compiler/f18/pull/1038
2020-03-05 05:40:44 -08:00
Eric Schweitz 8ad166c3a7 [flang] Merge pull request flang-compiler/f18#1043 from DavidTruby/zlib
Link against zlib when LLVM does.

Original-commit: flang-compiler/f18@8b0a473069
Reviewed-on: https://github.com/flang-compiler/f18/pull/1043
2020-03-04 15:57:09 -08:00
David Truby d545a132bc [flang] Link against zlib when LLVM does.
Original-commit: flang-compiler/f18@2260abe4c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/1043
2020-03-02 14:19:10 +00:00