Commit graph

2950 commits

Author SHA1 Message Date
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
Tim Keith 7547f76928 [flang] Merge pull request flang-compiler/f18#1046 from flang-compiler/tsk-comps
Improve checking of structure constructor keywords

Original-commit: flang-compiler/f18@c80c72d6f9
Reviewed-on: https://github.com/flang-compiler/f18/pull/1046
2020-03-03 13:28:04 -08:00
Tim Keith 47452b9691 [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@99ce156e49
Reviewed-on: https://github.com/flang-compiler/f18/pull/1046
2020-03-03 13:24:09 -08:00
Tim Keith f30c0307c1 [flang] Merge pull request flang-compiler/f18#1039 from flang-compiler/tsk-arrays
Improve array element errors

Original-commit: flang-compiler/f18@899ef78d6a
Reviewed-on: https://github.com/flang-compiler/f18/pull/1039
2020-03-02 16:53:22 -08:00
Tim Keith 3495c78214 [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@e2fd5333ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/1039
2020-03-02 16:45:02 -08:00
Tim Keith 4ffbdb3d35 [flang] Merge pull request flang-compiler/f18#1044 from flang-compiler/tsk-data
Expression analysis on DataStmtConstant

Original-commit: flang-compiler/f18@1611fd8e9e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1044
2020-03-02 13:37:33 -08:00
Tim Keith 2a00c617d6 [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@8bdaf0a521
Reviewed-on: https://github.com/flang-compiler/f18/pull/1044
2020-03-02 07:59:29 -08:00
vjayathirtha-nv 015075840d [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@f2a4e5c685
Reviewed-on: https://github.com/flang-compiler/f18/pull/1037
2020-02-27 16:05:22 -08:00
Varun Jayathirtha 92c1f6bb98 [flang] Add semantic checks C8104, C8105. Add tests for C8103, C8104, C8105
Original-commit: flang-compiler/f18@8134fc477e
Reviewed-on: https://github.com/flang-compiler/f18/pull/1037
2020-02-27 15:55:46 -08:00
psteinfeld a5ff3ac51e [flang] Merge pull request flang-compiler/f18#1031 from flang-compiler/ps-types
Semantic checks for C712 through C727

Original-commit: flang-compiler/f18@d6898ab882
Reviewed-on: https://github.com/flang-compiler/f18/pull/1031
2020-02-27 13:57:27 -08:00
Pete Steinfeld 84b2909ded [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@e81f57fcf5
Reviewed-on: https://github.com/flang-compiler/f18/pull/1031
2020-02-27 08:49:40 -08:00
Pete Steinfeld 657aaf8b8d [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@45998741e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/1031
Tree-same-pre-rewrite: false
2020-02-26 20:19:48 -08:00
Tim Keith c388d26f41 [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@7649e5d705
Reviewed-on: https://github.com/flang-compiler/f18/pull/1024
2020-02-26 19:20:57 -08:00
Tim Keith 914a91c1c3 [flang] Fix misparsed structure constructor in data stmt
In a data statement like `data x / a(1) /`, `a(1)` may be an array
element or a structure constructor. It is parsed as an array element
so if it turns out `a` is a derived type it must be rewritten as a
strucutre constructor.

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

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

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

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

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

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

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

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

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

Fixes flang-compiler/f18#1022.

Original-commit: flang-compiler/f18@a759204db5
Reviewed-on: https://github.com/flang-compiler/f18/pull/1023
2020-02-25 15:22:13 -08:00