Pete Steinfeld [Sat, 7 Dec 2019 03:59:54 +0000 (19:59 -0800)]
[flang] Semantic checks to see if a DO variable is modified
I added infrastructure to SemanticsContext to track active DO variables
and the source locations where they appear in DO statements. I also
added code to semantics.[h,cc] to check to see if a DO variable is
already defined, and, if so, to emit an error message along with a
reference to the relevant DO construct. I also added calls to several
places where variables are defined to determine if the definitions are
happening in the context of an active DO construct.
I have not yet added the checks for DO variables being redefined when passing
them as actual arguments to dummy arguments with INTENT(OUT) or INTENT(INOUT).
I wanted to get these changes merged first and catch up with the other changes
in master.
Original-commit: flang-compiler/f18@
1bbfcca61b94dccfbbe943b511f846acc1c33997
Reviewed-on: https://github.com/flang-compiler/f18/pull/860
Peter Klausler [Tue, 24 Dec 2019 00:35:54 +0000 (16:35 -0800)]
[flang] Merge pull request flang-compiler/f18#891 from flang-compiler/pmk-spec
Some fixes
Original-commit: flang-compiler/f18@
e3ee4a658ad4236a6683e8cbec8c24345dab9805
Reviewed-on: https://github.com/flang-compiler/f18/pull/891
peter klausler [Fri, 20 Dec 2019 21:03:30 +0000 (13:03 -0800)]
[flang] Fix off-by-one error in preprocessing expressions
Original-commit: flang-compiler/f18@
4c08a4a1be9fb398a8fc7561da114dc9d2a3accc
Reviewed-on: https://github.com/flang-compiler/f18/pull/891
Gary Klimowicz [Mon, 23 Dec 2019 19:47:55 +0000 (11:47 -0800)]
[flang] Merge pull request flang-compiler/f18#890 from flang-compiler/gak-format-fixes
Fix clang-format issues identified during relicensing
Original-commit: flang-compiler/f18@
a04295dc36f8685447bd83dffdd037dc2e819f2e
Reviewed-on: https://github.com/flang-compiler/f18/pull/890
Gary Klimowicz [Mon, 23 Dec 2019 19:16:00 +0000 (11:16 -0800)]
[flang] Fix clang-format issues identified during relicensing
While running clang-format during the relicensing, there were
a few files that showed minor format issues that could be cleaned
up. These changes address them.
Original-commit: flang-compiler/f18@
b308f9e35a6d386b53ded90e84bbfac600f38867
Reviewed-on: https://github.com/flang-compiler/f18/pull/890
Gary Klimowicz [Mon, 23 Dec 2019 19:07:30 +0000 (11:07 -0800)]
[flang] Merge pull request flang-compiler/f18#887 from flang-compiler/gak-relicense
Flang relicensing changes for LLVM Apache 2.0 license
Original-commit: flang-compiler/f18@
e06be2faa64a52471b3cfb2829dc05888236aa68
Reviewed-on: https://github.com/flang-compiler/f18/pull/887
Gary Klimowicz [Fri, 20 Dec 2019 20:52:07 +0000 (12:52 -0800)]
[flang] Flang relicensing changes for LLVM Apache 2.0 license
This changes the license information in many of the flang source files.
- Renamed LICENSE to LICENSE.txt.
- NVIDIA Copyright lines have been removed.
- Initial lines for files follow the LLVM coding convention (file name on the first line; Emacs mode information on the first line).
- License references have been replaced with the abridged LLVM text.
- License information was removed from the test files.
- No file header was placed on test files (these weren't in most LLVM test files).
- License information was added to documentation files where it was missing.
We did not add brief file summaries to the initial line.
See http://llvm.org/docs/DeveloperPolicy.html#new-llvm-project-license-framework
for a description of the new license.
See http://llvm.org/docs/CodingStandards.html#file-headers
for a description of the new LLVM standard file header.
Original-commit: flang-compiler/f18@
add6cde7244b926ca457a1c74c21fea071b85329
Reviewed-on: https://github.com/flang-compiler/f18/pull/887
Peter Klausler [Fri, 20 Dec 2019 20:53:06 +0000 (12:53 -0800)]
[flang] Merge pull request flang-compiler/f18#886 from kiranchandramohan/elemental
Mark ieee_get_flag and ieee_get_halting_mode as elemental
Original-commit: flang-compiler/f18@
a694b62c6d464ef2fc17046497a0aa0a0b14a756
Reviewed-on: https://github.com/flang-compiler/f18/pull/886
Kiran Chandramohan [Fri, 20 Dec 2019 20:28:18 +0000 (20:28 +0000)]
[flang] Mark ieee_get_flag and ieee_get_halting_mode as elemental
Original-commit: flang-compiler/f18@
d6237fa31112acc7bd864b9f732cb288014e6cf7
Reviewed-on: https://github.com/flang-compiler/f18/pull/886
Peter Klausler [Fri, 20 Dec 2019 20:24:30 +0000 (12:24 -0800)]
[flang] Merge pull request flang-compiler/f18#885 from flang-compiler/pmk-fixes
Two small fixes
Original-commit: flang-compiler/f18@
2d8a4815a338b3c21cc9882ebbb165fe1204ed93
Reviewed-on: https://github.com/flang-compiler/f18/pull/885
peter klausler [Fri, 20 Dec 2019 18:44:43 +0000 (10:44 -0800)]
[flang] Fix kind of REAL(complex) to be the same as the argument by default
Fixes for expression formatting
Original-commit: flang-compiler/f18@
13e8909587f2284e0093cdfaab5ac8335b060ec9
Reviewed-on: https://github.com/flang-compiler/f18/pull/885
Peter Klausler [Fri, 20 Dec 2019 18:09:49 +0000 (10:09 -0800)]
[flang] Merge pull request flang-compiler/f18#884 from flang-compiler/pmk-warn-size
Convert INTEGER scalar actual argument expressions to the kinds of dummies
Original-commit: flang-compiler/f18@
c88694b36eeb0ac0010127d8751627f000800000
Reviewed-on: https://github.com/flang-compiler/f18/pull/884
peter klausler [Fri, 20 Dec 2019 03:13:16 +0000 (19:13 -0800)]
[flang] Auto conversion of integer scalar actual argument exprs
Add documentation
Original-commit: flang-compiler/f18@
c1b200d23891cff4eca1991deec58c1adf65842e
Reviewed-on: https://github.com/flang-compiler/f18/pull/884
Peter Klausler [Fri, 20 Dec 2019 02:35:17 +0000 (18:35 -0800)]
[flang] Merge pull request flang-compiler/f18#883 from flang-compiler/pmk-spec-fixes
Misc fixes from SPEC
Original-commit: flang-compiler/f18@
9e91c635d7c706b78ed8f3776e7bfac1e20b559f
Reviewed-on: https://github.com/flang-compiler/f18/pull/883
peter klausler [Thu, 19 Dec 2019 01:06:13 +0000 (17:06 -0800)]
[flang] Roll up fixes for semantic analysis of SPEC CPU codes
- Add cases to IsDescriptor
- Fix NULLIFY in PURE checking
- Fix fotonik3d mutually-referencing derived type bug
- Fix spurious I/O error message on ALLOCATE
Original-commit: flang-compiler/f18@
34b64db7da9e90109b1dfec5347b344eae7dd8ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/883
Tim Keith [Thu, 19 Dec 2019 17:52:15 +0000 (09:52 -0800)]
[flang] Save CallStmt::typedCall (flang-compiler/f18#879)
When `ExpressionAnalyzer::AnalyzeCall` processed a subroutine it was
always returning std::nullopt. Change it to return a `ProcedureRef`
wrapped in an `Expr` so that it can be saved in `CallStmt::typedCall`.
Original-commit: flang-compiler/f18@
2cc226f66ec51b38056c779494a7b6104557f9a8
Reviewed-on: https://github.com/flang-compiler/f18/pull/879
Tim Keith [Thu, 19 Dec 2019 01:26:49 +0000 (17:26 -0800)]
[flang] Merge pull request flang-compiler/f18#878 from flang-compiler/tsk-dump-parse-expr
Include analyzed exprs in parse tree dump
Original-commit: flang-compiler/f18@
0855ba8baa5c6e9afc62f96fd4cba5d9a32d56d5
Reviewed-on: https://github.com/flang-compiler/f18/pull/878
Tim Keith [Wed, 18 Dec 2019 23:49:42 +0000 (15:49 -0800)]
[flang] Remove extraneous occurences of parser::
This file is in `Fortran::parser` so we don't need to qualify names
with `parser::`.
Original-commit: flang-compiler/f18@
e8e7ffcae88c3be8fecf4188896736790217578c
Reviewed-on: https://github.com/flang-compiler/f18/pull/878
Tim Keith [Wed, 18 Dec 2019 23:36:14 +0000 (15:36 -0800)]
[flang] Include analyzed exprs in parse tree dump
When dumping the parse tree, if there are analyzed expressions,
assignments, or call statements, include the Fortran form of those
in the dump.
This uses the same `AnalyzedObjectsAsFortran` object that unparsing
does so it applies to the same nodes.
We already do something like this for `Name` nodes as well as some
predefined types, so abstract it into an `AsFortran` function which
returns the Fortran source for a node that is to be included in the
dump.
Original-commit: flang-compiler/f18@
823b044d2a009f43fe5ce15755a8ae23f70dfed8
Reviewed-on: https://github.com/flang-compiler/f18/pull/878
Tree-same-pre-rewrite: false
Peter Klausler [Thu, 19 Dec 2019 00:11:31 +0000 (16:11 -0800)]
[flang] Merge pull request flang-compiler/f18#874 from flang-compiler/pmk-fixes
Fix unparsing of assignment representation and excess parentheses
Original-commit: flang-compiler/f18@
3e7e95fff203bb33834f9b91e2a3ec5a3885b73b
Reviewed-on: https://github.com/flang-compiler/f18/pull/874
peter klausler [Tue, 17 Dec 2019 23:59:25 +0000 (15:59 -0800)]
[flang] Fix unparsing of assignment representation and excess parentheses
More fixes, and move prefix/infix/suffix strings into formatting.cc
Original-commit: flang-compiler/f18@
49d68700e0ab105459fb1e05bf60f8ec352a8aac
Reviewed-on: https://github.com/flang-compiler/f18/pull/874
Peter Klausler [Tue, 17 Dec 2019 21:44:51 +0000 (13:44 -0800)]
[flang] Merge pull request flang-compiler/f18#873 from flang-compiler/pmk-call
Save analyzed ProcedureRef in parse tree node for CALL statement
Original-commit: flang-compiler/f18@
80c27052055fccd20b18130b510169549ff38fea
Reviewed-on: https://github.com/flang-compiler/f18/pull/873
peter klausler [Tue, 17 Dec 2019 20:32:16 +0000 (12:32 -0800)]
[flang] Back some changes out
Original-commit: flang-compiler/f18@
7f6345ac627e5f5b8ed8daeb7290b2a7712b0e5d
Reviewed-on: https://github.com/flang-compiler/f18/pull/873
peter klausler [Tue, 17 Dec 2019 18:53:20 +0000 (10:53 -0800)]
[flang] Save analyzed CALL statements in the parse tree
Original-commit: flang-compiler/f18@
bd618f179c82ca613efd8db71548ceb5b1143e70
Reviewed-on: https://github.com/flang-compiler/f18/pull/873
Tree-same-pre-rewrite: false
Peter Klausler [Mon, 16 Dec 2019 23:05:42 +0000 (15:05 -0800)]
[flang] Merge pull request flang-compiler/f18#862 from flang-compiler/pmk-grammar
Outline parsers for types (reduce f18 build memory requirements)
Original-commit: flang-compiler/f18@
8d2b296fe1ecc6e4b92789b8dffaf22b3930a89e
Reviewed-on: https://github.com/flang-compiler/f18/pull/862
peter klausler [Mon, 16 Dec 2019 22:28:57 +0000 (14:28 -0800)]
[flang] Improve commentary
Original-commit: flang-compiler/f18@
364ac83bfc39e7f866536f4d1fd1c19c271469c1
Reviewed-on: https://github.com/flang-compiler/f18/pull/862
peter klausler [Mon, 9 Dec 2019 19:09:44 +0000 (11:09 -0800)]
[flang] Outline per-type parsers to reduce f18 build-time
CPU & memory requirements
Original-commit: flang-compiler/f18@
f48fe07dfac52b4c2f031e34d27404f37a0a7cd7
Reviewed-on: https://github.com/flang-compiler/f18/pull/862
Tree-same-pre-rewrite: false
Tim Keith [Mon, 16 Dec 2019 22:50:19 +0000 (14:50 -0800)]
[flang] Merge pull request flang-compiler/f18#872 from flang-compiler/tsk-defined-op2
Support for type-bound operators and assignment
Original-commit: flang-compiler/f18@
9862c9406144ccb39f97453909fc476d8c380f4b
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
Tim Keith [Mon, 16 Dec 2019 22:28:23 +0000 (14:28 -0800)]
[flang] Add evaluate::GetDerivedTypeSpec(DynamicType)
It gets the semantics::DerivedTypeSpec of a DynamicType if it has one.
Make use of it where it simplifies the code.
Original-commit: flang-compiler/f18@
9ad12e7c131459a8beab2b9ffa204966a85f405a
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
Tim Keith [Sat, 14 Dec 2019 00:22:48 +0000 (16:22 -0800)]
[flang] C774: Defined operator/assignment may not have NOPASS
Original-commit: flang-compiler/f18@
6bfa3d3568b6dc373d62d691db2fd5e8859fff47
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
Tree-same-pre-rewrite: false
Tim Keith [Mon, 16 Dec 2019 19:33:55 +0000 (11:33 -0800)]
[flang] Support for type-bound operators and assignment
Add `ArgumentAnalyzer::FindBoundOp` to look for an operator or
assignment definition in the type of each operand. Then `TryBoundOp`
checks if it is actually applicable.
Change ResolveGeneric to handle type-bound operators: the `adjustActuals`
function passed in handles the difference between these and normal
type-bound procedures. For operators, either operand may be the passed-
object argument. For procedures we know which one it is.
Extract `GetDerivedTypeSpec`, `GetBindingResolution`, and
`OkLogicalIntegerAssignment` into separate functions to simplify the
logic of the calling functions.
Original-commit: flang-compiler/f18@
1f7ff22145ef61c4c168c466f4de4fab11e0f611
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
Tree-same-pre-rewrite: false
Peter Klausler [Mon, 16 Dec 2019 20:54:55 +0000 (12:54 -0800)]
[flang] Merge pull request flang-compiler/f18#871 from flang-compiler/pmk-fixes
Fix remaining failures in expression semantics
Original-commit: flang-compiler/f18@
7473f0bcd76a055fffea9d3f47567a64fceb5ccf
Reviewed-on: https://github.com/flang-compiler/f18/pull/871
peter klausler [Wed, 11 Dec 2019 23:06:24 +0000 (15:06 -0800)]
[flang] Apply implicit typing to names in COMMON that appear in specification expressions
Extend semantic analysis of expressions to catch missing cases
Fix statement function semantics, add degree trig intrinsics
Add GetUltimate to rewrite of bare namelist
Address review comments
Original-commit: flang-compiler/f18@
52ff319de2e750733660d8e7e938e09159a3c11c
Reviewed-on: https://github.com/flang-compiler/f18/pull/871
Eric Schweitz [Mon, 16 Dec 2019 16:39:17 +0000 (08:39 -0800)]
[flang] Merge pull request flang-compiler/f18#869 from schweitzpgi/master
remove stale optimizer files
Original-commit: flang-compiler/f18@
6a8dec4991ecb219f0d42a865d799c93e675612f
Reviewed-on: https://github.com/flang-compiler/f18/pull/869
Eric Schweitz [Fri, 13 Dec 2019 22:46:20 +0000 (14:46 -0800)]
[flang] remove stale optimizer files
Original-commit: flang-compiler/f18@
c497c135f6f277f2dee0c1c3c82319577448438c
Reviewed-on: https://github.com/flang-compiler/f18/pull/869
Eric Schweitz [Thu, 12 Dec 2019 00:47:06 +0000 (16:47 -0800)]
[flang] Merge pull request flang-compiler/f18#868 from schweitzpgi/remove-flatten
remove some old files
Original-commit: flang-compiler/f18@
3d05d39e3636fecab2bc1b7540cec9d672f72944
Reviewed-on: https://github.com/flang-compiler/f18/pull/868
Eric Schweitz [Wed, 11 Dec 2019 21:33:02 +0000 (13:33 -0800)]
[flang] remove some old files
Original-commit: flang-compiler/f18@
d7554c7605079c8a2f8d3d2d6d584241d3112ecd
Reviewed-on: https://github.com/flang-compiler/f18/pull/868
Gary Klimowicz [Wed, 11 Dec 2019 19:13:48 +0000 (11:13 -0800)]
[flang] Flang relicense: LICENSE file and one change (flang-compiler/f18#867)
Add new license text to runtime/magic-numbers.h, which is unusual
in that it is the only .h file in flang that is intended to be
included in either C or Fortran files. This requires special
handling of the license text.
Original-commit: flang-compiler/f18@
61bb9db531ad4fbe8fda9978a6b7754cb86323c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/867
Kiran Kumar T P [Wed, 11 Dec 2019 17:11:59 +0000 (22:41 +0530)]
[flang] Updated call10.f90 with more test for flang-compiler/f18#794-Check for PURE procedures containing image control statements (flang-compiler/f18#857)
Original-commit: flang-compiler/f18@
ae4868e572c90e0ec2c618f4235c9de1ea8cade5
Reviewed-on: https://github.com/flang-compiler/f18/pull/857
jeanPerier [Wed, 11 Dec 2019 07:52:48 +0000 (23:52 -0800)]
[flang] Merge pull request flang-compiler/f18#865 from flang-compiler/jpr-fix-cplx-power
Fix INTGER**COMPLEX regression introduced by PR 858
Original-commit: flang-compiler/f18@
53545d7436c452e2329615326ab95799083dbcd3
Reviewed-on: https://github.com/flang-compiler/f18/pull/865
Jean Perier [Tue, 10 Dec 2019 09:21:50 +0000 (01:21 -0800)]
[flang] Fix INTGER**COMPLEX regression introduced by PR 858
Fix bad copy past that had introduced an unitialized value use.
Original-commit: flang-compiler/f18@
9a84bcb9ac3a06800e9c0f0941a6a82d8416a9fe
Reviewed-on: https://github.com/flang-compiler/f18/pull/865
arjunsuresh1987 [Tue, 10 Dec 2019 22:07:56 +0000 (03:37 +0530)]
[flang] Fix file path in cmake (flang-compiler/f18#844)
Original-commit: flang-compiler/f18@
4771f8cb7895ebc1fa836e8cf3ceddfa7a705eba
Reviewed-on: https://github.com/flang-compiler/f18/pull/844
Peter Klausler [Tue, 10 Dec 2019 20:39:52 +0000 (12:39 -0800)]
[flang] Merge pull request flang-compiler/f18#864 from flang-compiler/pmk-fix
Revert recent addition of ActualArgument::PassedObject
Original-commit: flang-compiler/f18@
d1b6e3cd2c4ef79df6804edd85d7b1e1d398e255
Reviewed-on: https://github.com/flang-compiler/f18/pull/864
peter klausler [Mon, 9 Dec 2019 21:52:12 +0000 (13:52 -0800)]
[flang] Revert recent addition of ActualArgument::PassedObject
reformatting
Complete merging with current master
implement extension of inherited type-bound generics
Original-commit: flang-compiler/f18@
e58c4e53c2fcf6559e7254ce0fd1e4b96d158c73
Reviewed-on: https://github.com/flang-compiler/f18/pull/864
Tim Keith [Mon, 9 Dec 2019 22:26:59 +0000 (14:26 -0800)]
[flang] Merge pull request flang-compiler/f18#863 from flang-compiler/tsk-defined-op2
Resolve calls to type-bound generic names
Original-commit: flang-compiler/f18@
b3bb698086ab9a79c285f90b956036d8411f4520
Reviewed-on: https://github.com/flang-compiler/f18/pull/863
Tim Keith [Mon, 9 Dec 2019 21:36:19 +0000 (13:36 -0800)]
[flang] Resolve calls to type-bound generic names
Extend `ResolveGeneric` to handle calls to procedure components by
passing in the data-ref that is used as the passed-object argument.
`AddPassArg` takes care of adding a placeholder for the passed object.
This is shared by the generic and non-generic cases of calls to
procedure components.
Original-commit: flang-compiler/f18@
be83590183f7abf32c0cc111c812fd484af36f2b
Reviewed-on: https://github.com/flang-compiler/f18/pull/863
jeanPerier [Mon, 9 Dec 2019 10:53:53 +0000 (02:53 -0800)]
[flang] Merge pull request flang-compiler/f18#858 from flang-compiler/jpr-complex-power-promote-fix
Fix COMPLEX-REAL `/` and `**` operand promotion
Original-commit: flang-compiler/f18@
722caa61f217625aed4d4654e5f03627777d2323
Reviewed-on: https://github.com/flang-compiler/f18/pull/858
Jean Perier [Fri, 6 Dec 2019 09:18:20 +0000 (01:18 -0800)]
[flang] Fix COMPLEX/REAL `/` and `**` operand promotion
The real operand was always converted to the complex operand type.
The highest precison should be used instead. This fix converts the
real to a complex of the same kind before applying the promotion
rules for complex operands.
Reference to Fortran 2018 standard 10.9.1.3 that rules this added
in comments.
Original-commit: flang-compiler/f18@
0d6b9c33aae59d80ff1b77f3561a6acb1db98645
Reviewed-on: https://github.com/flang-compiler/f18/pull/858
Peter Klausler [Fri, 6 Dec 2019 21:56:08 +0000 (13:56 -0800)]
[flang] Merge pull request flang-compiler/f18#859 from flang-compiler/pmk-empty
Accept source files with no program units (flang-compiler/f18#658)
Original-commit: flang-compiler/f18@
2ebb75529c80a21658250dafffbf49ebdc27847e
Reviewed-on: https://github.com/flang-compiler/f18/pull/859
peter klausler [Fri, 6 Dec 2019 17:37:07 +0000 (09:37 -0800)]
[flang] Accept source files with no program units (flang-compiler/f18#658)
update documentation
Original-commit: flang-compiler/f18@
3dfb8314991035a428c514cf0ad46af446d64a4e
Reviewed-on: https://github.com/flang-compiler/f18/pull/859
Peter Klausler [Fri, 6 Dec 2019 17:52:37 +0000 (09:52 -0800)]
[flang] Merge pull request flang-compiler/f18#856 from flang-compiler/pmk-legacy-assignments
Allow assignment between INTEGER and LOGICAL as extension
Original-commit: flang-compiler/f18@
169f380eafa87f2164e4529a314701feaee55ad6
Reviewed-on: https://github.com/flang-compiler/f18/pull/856
peter klausler [Fri, 6 Dec 2019 00:18:39 +0000 (16:18 -0800)]
[flang] Allow assignment between INTEGER and LOGICAL as extension
Extend documentation
Original-commit: flang-compiler/f18@
7a719198fc7dc09f50cd1e4129d87f2ace711c4b
Reviewed-on: https://github.com/flang-compiler/f18/pull/856
Peter Klausler [Thu, 5 Dec 2019 20:50:21 +0000 (12:50 -0800)]
[flang] Merge pull request flang-compiler/f18#855 from flang-compiler/pmk-fix
Fix problems with passed-object arguments...
Original-commit: flang-compiler/f18@
882d20d4fb676535d0b96e2960d3874ce1a2a09a
Reviewed-on: https://github.com/flang-compiler/f18/pull/855
peter klausler [Thu, 5 Dec 2019 18:24:18 +0000 (10:24 -0800)]
[flang] Fix problems with passed-object arguments by deferring the
identification of their index in the dummy argument list,
simplifying their representation, completing the representation
of their actual arguments, and (while I'm here) resolving
calls to type-bound procedures whose bindings are known at
compilation time.
Button up class ActualArgument by making remaining data
members private and adding accessors & mutators.
Original-commit: flang-compiler/f18@
5eb60ec41912b0963e41bbc1a3141164efcb7fbf
Reviewed-on: https://github.com/flang-compiler/f18/pull/855
jeanPerier [Wed, 4 Dec 2019 10:07:31 +0000 (02:07 -0800)]
[flang] Merge pull request flang-compiler/f18#851 from flang-compiler/jpr-complex-literal-dump-2
Complex expression dump fixes
Original-commit: flang-compiler/f18@
84c57b8e011e0701cb582522faaacbf06479d88a
Reviewed-on: https://github.com/flang-compiler/f18/pull/851
Jean Perier [Tue, 3 Dec 2019 15:52:18 +0000 (07:52 -0800)]
[flang] Complex expression dump fixes
1. Dump negative parts in complex constants without parentheses
(-1., 0.) was dumped as ((-1.), 0.) from f18 expression format.
The latter format is only valid with the complex constructor extension
that is not supported by all compilers.
This commit ensure the former fromat is used in dumps so that dumps can
be used by all fortran compilers. It turns out the parenthesis added
by REAL::AsFortran are not required because operation lowering is
already taking care of this.
2. Dump evaluate::ComplexComponent with REAL/IMAG instead of %RE/%IM
f18 was failing to reparse its own dump in some cases involving
complex expressions like `-z**i`.
The reason was %RE and %IM were used to dump ComplexComponents.
%RE and %IM can only be used on designators but ComplexComponent can
contain arbitrary complex expressions.
Hence, %RE and %IM cannot be used to dump ComplexComponent.
This commit replace them with call to intrinsic function
REAL/IMAG.
Note that this may unfortunatly be unsafe if the user
shadowed REAL or IMAG but I do not see an easy way to solve
this... The current dump is not correct.
Original-commit: flang-compiler/f18@
4550a23d0bdce4ffa8d8765a1da4b35151eebe50
Reviewed-on: https://github.com/flang-compiler/f18/pull/851
Peter Klausler [Tue, 3 Dec 2019 18:59:46 +0000 (10:59 -0800)]
[flang] Merge pull request flang-compiler/f18#852 from flang-compiler/pmk-forward-private
Fix forward ref to derived type when symbol exists
Original-commit: flang-compiler/f18@
7471db2be0fc1b3e66de48acb8d573e9f31cf815
Reviewed-on: https://github.com/flang-compiler/f18/pull/852
peter klausler [Tue, 3 Dec 2019 18:21:37 +0000 (10:21 -0800)]
[flang] Fix forward ref to derived type when symbol exists
Fix some comments
Original-commit: flang-compiler/f18@
3274ed95459865057a2e77966863e6b01b5f6d35
Reviewed-on: https://github.com/flang-compiler/f18/pull/852
Peter Klausler [Tue, 3 Dec 2019 18:48:19 +0000 (10:48 -0800)]
[flang] Merge pull request flang-compiler/f18#850 from flang-compiler/pmk-853
Fix bug flang-compiler/f18#843, bad recovery from failed opens of source files
Original-commit: flang-compiler/f18@
db7214e2e6fd8f2ae5f9224748a61c749e35a1c0
Reviewed-on: https://github.com/flang-compiler/f18/pull/850
peter klausler [Tue, 3 Dec 2019 17:49:44 +0000 (09:49 -0800)]
[flang] Fix bug flang-compiler/f18#843, bad recovery from failed opens of source files
Original-commit: flang-compiler/f18@
27d9db610fc7302b8da33e19a70c441a0ead6c7c
Reviewed-on: https://github.com/flang-compiler/f18/pull/850
Tim Keith [Tue, 3 Dec 2019 18:28:39 +0000 (10:28 -0800)]
[flang] Merge pull request flang-compiler/f18#849 from flang-compiler/tsk-pure
Fix PURE check on procedure binding
Original-commit: flang-compiler/f18@
58f036ec01c0abd8c186914711f565388e67ae52
Reviewed-on: https://github.com/flang-compiler/f18/pull/849
Tim Keith [Tue, 3 Dec 2019 16:43:05 +0000 (08:43 -0800)]
[flang] Fix PURE check on procedure binding
A symbol that represents a procedure binding is PURE if the procedure
it is bound to is PURE. Fix `IsPureProcedure` to check that.
Make use of `IsPureProcedure` in `CheckSpecificationExprHelper`.
Original-commit: flang-compiler/f18@
c95f2eb4fb25d464977690ba03260be2451911d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/849
Peter Klausler [Tue, 3 Dec 2019 17:19:26 +0000 (09:19 -0800)]
[flang] Merge pull request flang-compiler/f18#848 from flang-compiler/pmk-fix-gcc-7.2-build
Dodge GCC 7.2 bug
Original-commit: flang-compiler/f18@
567a1642f45d9831dea16bcab7e66ed9f2729e9f
Reviewed-on: https://github.com/flang-compiler/f18/pull/848
peter klausler [Mon, 2 Dec 2019 23:56:00 +0000 (15:56 -0800)]
[flang] Dodge GCC 7.2 bug
Original-commit: flang-compiler/f18@
bde158343aa254d529cac85657c4102194999b6f
Reviewed-on: https://github.com/flang-compiler/f18/pull/848
Peter Klausler [Mon, 2 Dec 2019 22:17:35 +0000 (14:17 -0800)]
[flang] Merge pull request flang-compiler/f18#847 from flang-compiler/pmk-forward-type-ref
Forward references to derived types
Original-commit: flang-compiler/f18@
5928825790958a89d5b29f7def7b1d31596a5a06
Reviewed-on: https://github.com/flang-compiler/f18/pull/847
peter klausler [Fri, 22 Nov 2019 16:15:02 +0000 (08:15 -0800)]
[flang] Implement forward references to derived types (fix flang-compiler/f18#573)
Restructuring PDT instantiation in preparation for forward references
Complete tests, pass them
Address review comments
Original-commit: flang-compiler/f18@
b66ba55a73c8e4b94ffd4164b8428a848e593b3f
Reviewed-on: https://github.com/flang-compiler/f18/pull/847
psteinfeld [Mon, 2 Dec 2019 21:31:26 +0000 (13:31 -0800)]
[flang] Merge pull request flang-compiler/f18#834 from flang-compiler/ps-zerodo
Add a check for DO step expressions being zero
Original-commit: flang-compiler/f18@
a5a55d5f3fb71109afd5d94ba3fdd0051778a19c
Reviewed-on: https://github.com/flang-compiler/f18/pull/834
Pete Steinfeld [Wed, 20 Nov 2019 21:33:04 +0000 (13:33 -0800)]
[flang] Add a check for DO step expressions being zero
This is prohibited by Section 11.1.7.4.1, paragraph 1.
Note also that we allow for REAL step expressions. But the check I
added only works for INTEGER step expressions.
I added a function to tools.cc to test to see if an expression is zero,
and I added calls to check-do.cc for regular and CONCURRENT DO
statements to this function. I made the regular DO a warning and the DO
CONCURRENT message an error. I added tests for the DO CONCURRENT case,
including a test that uses an integer constant.
Original-commit: flang-compiler/f18@
8c4fadfe00fec25f9c814a14aa1e4d31c21df3be
Reviewed-on: https://github.com/flang-compiler/f18/pull/834
Tim Keith [Mon, 2 Dec 2019 16:55:44 +0000 (08:55 -0800)]
[flang] Check functions that implement defined operators (flang-compiler/f18#846)
Section 15.4.3.4.2 specifies restrictions on functions that may be used
to implement an "extended-intrinsic-op". These checkw are implemented in
`CheckHelper::CheckDefinedOperator`.
Move `IsIntrinsicRelational` et al. to `semantics/tools.h` so that
the same logic is used to check both dummy and actual arguments.
Fix up tests that had errors that are now detected.
Original-commit: flang-compiler/f18@
b900762eed5883bfbc31349847381098de1e7b6a
Reviewed-on: https://github.com/flang-compiler/f18/pull/846
kiranchandramohan [Tue, 26 Nov 2019 21:34:03 +0000 (21:34 +0000)]
[flang] Minor fix in folding of reshape intrinsic (flang-compiler/f18#842)
The standard permits source to have more elements than the
result (as specified by the SHAPE arg). While copying, ensure
that we do not copy more than the number of elements of the
result.
Original-commit: flang-compiler/f18@
6b8284f4f2cff32fcf5483ea93d1d239ecdacd33
Reviewed-on: https://github.com/flang-compiler/f18/pull/842
Tim Keith [Tue, 26 Nov 2019 21:30:42 +0000 (13:30 -0800)]
[flang] Merge pull request flang-compiler/f18#841 from flang-compiler/tsk-assignment3
Analyze defined assignments
Original-commit: flang-compiler/f18@
706a166476f4c275e67adde14669f2b844f0ea39
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tim Keith [Sat, 23 Nov 2019 00:46:11 +0000 (16:46 -0800)]
[flang] Analyze intrinsic and user-defined assignments
Change expression analysis to do assignment statements as it currently
does call statements. Check there for defined assignment and set
`typedAssignment` in the `AssignmentStmt` node to contain the analyzed
assignment, either intrinsic or user-defined.
When `var = expr` is implemented by subroutine `sub`, the analyzed
assignment contains a procedure reference to `sub(var, (expr))`.
Add `IsDefinedAssignment` to decide based on types and ranks of lhs
and rhs whether is can be a defined assignment. The result is
tri-state because when they are both the same derived type it can
be either intrinsic or defined. Use this where a similar decision
is made in `check-declarations.cc`.
Change "Procedure referenced in PURE subprogram" error message to
contain the name of the procedure. If the reference is from a defined
assignment that name won't appear on the highlighted source line.
Original-commit: flang-compiler/f18@
5c87071210ec74e9395805dd547c107e7d3bf7b6
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tim Keith [Sat, 23 Nov 2019 00:04:56 +0000 (16:04 -0800)]
[flang] Add analyzed assignment to parse tree
Add `typedAssignment` to the `AssignmentStmt` node, analagous to
`typedExpr` in `Expr`. This represents the analyzed form of an assignment.
It may be a subroutine call in the case of a user-defined assignment.
Add `GetAssignment` function to get it from the parse tree node if present.
Original-commit: flang-compiler/f18@
675b0b9bb7617231e8e4bfa0c7a63423c74d79a4
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Tim Keith [Fri, 22 Nov 2019 22:58:26 +0000 (14:58 -0800)]
[flang] Extract Parenthesize function
Move the code to parenthesize an expression from `ExpressionAnalyzer`
into `evaluate/tools.h` so that it can be used to parenthesize an
`ActualArgument`. This will be needed for defined assignment calls.
Original-commit: flang-compiler/f18@
6180d1fb9bd8dbbf26697353b271deb59aa466fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Tim Keith [Fri, 22 Nov 2019 22:40:53 +0000 (14:40 -0800)]
[flang] Add checks for valid defined assignment procedures
Perform the checks from 15.4.3.4.3 to determine what procedures are
valid to implement defined assignment. This requires characterizing
procedures, so share the result of that with
`CheckSpecificsAreDistinguishable`.
Original-commit: flang-compiler/f18@
9e0d79f1735cf99b43f9ff7f6d712d7aa862dead
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Tim Keith [Fri, 22 Nov 2019 22:05:54 +0000 (14:05 -0800)]
[flang] Move distinguishability check to check-declarations.cc
The check that specific procedures of a generic are distinguishable
doesn't need to be done in `resolve-names.cc`. It can be deferred until
`check-declarations.cc` because it only depends on the symbol table.
Make use of `AttachDeclaration` when reporting errors
Refactor checks for different symbol details into separate functions
as they are getting more numerous.
Original-commit: flang-compiler/f18@
cd0d6930bba3ae92f2526d7ce1fbf5e39afe2f38
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Tim Keith [Fri, 22 Nov 2019 21:20:58 +0000 (13:20 -0800)]
[flang] Change AttachDeclaration to take reference instead of pointer
AttachDeclaration (and so also SayWithDeclaration) don't do anything
when passed a null pointer for the symbol and in all but one place they
are called the symbol can't be null. So change both function to take
`const Symbol &` rather than `const Symbol *`. Change it to handle
procedure bindings as well.
Add `SayWithDeclaration` to `CheckHelper` to simplify calling the one in
`evaluate` and prevent attaching the declaration when it would point at
the same line.
Original-commit: flang-compiler/f18@
5f1c2ff6638da837616fa7ae6e3e121544c89bb7
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Tim Keith [Fri, 22 Nov 2019 20:52:23 +0000 (12:52 -0800)]
[flang] Combine GenericDetails and GenericBindingDetails
`GenericDetails` and `GenericBindingDetails` were almost identical:
the former has optional data members to handle the case when a specific
procedure or derived type has the same name as the generic symbol.
Most places they are handled the same way so it simplifies things to
have only one type. In the case where we want to know if it is a generic
binding (e.g. in `mod-file.cc`) we can check the kind of scope that owns
the symbol.
Save name from the generic binding for better location of error messages.
Original-commit: flang-compiler/f18@
f65a9edca232098be1412607e59b6ed1d5803ad7
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Tim Keith [Fri, 22 Nov 2019 20:40:37 +0000 (12:40 -0800)]
[flang] Refactor GenericKind
Change GenericKind from an enum class to a variant that includes the
`NumericOperator`, `LogicalOperator`, and `RelationalOperator` from `common`.
This allows for better tests like `IsIntrinsicOperator` (which used to
check for being in a range of the `GenericKind` enumeration) and
simplifies mapping the kind to a string representation.
Original-commit: flang-compiler/f18@
c74327c393649ff95355f00333ffd2352b148f72
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Peter Klausler [Fri, 22 Nov 2019 22:47:17 +0000 (14:47 -0800)]
[flang] Merge pull request flang-compiler/f18#836 from flang-compiler/pmk-kinds
Fold MERGE, use it in ISO_FORTRAN_ENV
Original-commit: flang-compiler/f18@
34e04649fe6515a84cc5288b8ecfb133bd618e5a
Reviewed-on: https://github.com/flang-compiler/f18/pull/836
peter klausler [Thu, 21 Nov 2019 21:31:52 +0000 (13:31 -0800)]
[flang] Fold MERGE, use it in ISO_FORTRAN_ENV
Reduce use of intrinsic type KIND codes in ISO_FORTRAN_ENV
Use COUNT([x]) rather than MERGE(1,0,x)
Fix problems in array constructor expression analysis
Original-commit: flang-compiler/f18@
79018f7126a55a4b8a907f121cc099d5f4f9666a
Reviewed-on: https://github.com/flang-compiler/f18/pull/836
Isuru Fernando [Fri, 22 Nov 2019 21:54:36 +0000 (15:54 -0600)]
[flang] Need algorithm for std::min (flang-compiler/f18#837)
Original-commit: flang-compiler/f18@
d20a79cdd952e5013c741f052157e50ecb391d34
Reviewed-on: https://github.com/flang-compiler/f18/pull/837
Peter Klausler [Thu, 21 Nov 2019 23:17:03 +0000 (15:17 -0800)]
[flang] Merge pull request flang-compiler/f18#835 from flang-compiler/pmk-call12
Enable, extend, and pass call12.f90 test; revert some recent changes
Original-commit: flang-compiler/f18@
3feacd8a637f150b8433bbc46d10c53cc054957a
Reviewed-on: https://github.com/flang-compiler/f18/pull/835
peter klausler [Thu, 21 Nov 2019 21:55:17 +0000 (13:55 -0800)]
[flang] Address review comments
Original-commit: flang-compiler/f18@
0ce592c7c550027b8d4516af2cda8330b2ddc08a
Reviewed-on: https://github.com/flang-compiler/f18/pull/835
peter klausler [Thu, 21 Nov 2019 21:35:20 +0000 (13:35 -0800)]
[flang] Reformat all C++ in lib/*
Original-commit: flang-compiler/f18@
232bcedb6647592e63dc0dec6c6bd83fd41082b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/835
Tree-same-pre-rewrite: false
peter klausler [Wed, 20 Nov 2019 03:10:02 +0000 (19:10 -0800)]
[flang] Revert Symbol::operator=() changes
Rearrange "if" nest for clarity
Pass call12.f90 test.
Original-commit: flang-compiler/f18@
69a1a2b796f64c13b37f417dc03ff6a416384b94
Reviewed-on: https://github.com/flang-compiler/f18/pull/835
Tree-same-pre-rewrite: false
psteinfeld [Thu, 21 Nov 2019 19:33:42 +0000 (11:33 -0800)]
[flang] Merge pull request flang-compiler/f18#814 from flang-compiler/ps-c1140
Changes to check for constraint C1140 -- deallocation of polymorphic entities
Original-commit: flang-compiler/f18@
794b75155abfca6a938b5baa9bff0bc2cf2c4b67
Reviewed-on: https://github.com/flang-compiler/f18/pull/814
Pete Steinfeld [Tue, 5 Nov 2019 18:18:33 +0000 (10:18 -0800)]
[flang] Changes to check for constraint C1140
This constraint prohibits deallocation of polymorphic entities in a DO
CONCURRENT.
Section 9.7.3.2 specifies the situations that might cause deallocation
of a polymorphic entity. The ones that are applicable to a DO CONCURRENT
are exiting from a block that declares such variables, intrinsic
assignment, and an actual DEALLOCATE statement. This section also
specifies (paragraph 8) that deallocation of a derived type causes
deallocation of all of its allocatable subobjects.
Section 10.2.1.3 specifies what happens during intrinsic assignment.
Paragraph 3 states If the variable is an allocated allocatable variable,
it is deallocated if expr is an array of different shape, any
corresponding length type parameter values of the variable and expr
differ, or the variable is polymorphic and the dynamic type or any
corresponding kind type parameter values of the variable and expr
differ." Thus, an allocatable polymorphic variable on the left hand side
of an assignment statement gets deallocated. Paragraph 13 states that
"For a noncoarray allocatable component the following sequence of
operations is applied.
(1) If the component of the variable is allocated, it is deallocated."
Thus, a variable on the left-hand side of an assignment statement might have noncorray allocatable components. Such components will be deallocated.
Deallocation can be caused by exiting from a block where the entity is
declared, from an assignment, and from direct deallocation.
Original-commit: flang-compiler/f18@
7d1932d344308d8266503268a7534532cebe6087
Reviewed-on: https://github.com/flang-compiler/f18/pull/814
Peter Klausler [Tue, 19 Nov 2019 22:53:26 +0000 (14:53 -0800)]
[flang] Merge pull request flang-compiler/f18#833 from flang-compiler/pmk-call11
For call11.f90: more checks on PURE subprograms and TBP bindings
Original-commit: flang-compiler/f18@
1122b381d65add5d33ee5b39ac39b6d07e110955
Reviewed-on: https://github.com/flang-compiler/f18/pull/833
peter klausler [Fri, 15 Nov 2019 22:26:10 +0000 (14:26 -0800)]
[flang] For call11.f90: more checks on PURE subprograms and TBP bindings
Original-commit: flang-compiler/f18@
7aa47f0b9e4ad5a7496d3142953092a404f621a2
Reviewed-on: https://github.com/flang-compiler/f18/pull/833
Peter Klausler [Tue, 19 Nov 2019 18:32:13 +0000 (10:32 -0800)]
[flang] Merge pull request flang-compiler/f18#802 from flang-compiler/pmk-io-header
API for generated code to use to implement I/O data transfer statements
Original-commit: flang-compiler/f18@
696bce96856a00b5912afb71bb21269698660eed
Reviewed-on: https://github.com/flang-compiler/f18/pull/802
peter klausler [Fri, 11 Oct 2019 20:46:58 +0000 (13:46 -0700)]
[flang] Define runtime I/O library interface to be used by generated code.
Original-commit: flang-compiler/f18@
82cb9b0c8794e253d6bec4fd01be1b6b5428fc56
Reviewed-on: https://github.com/flang-compiler/f18/pull/802
Steve Scalpone [Mon, 18 Nov 2019 16:34:52 +0000 (09:34 -0700)]
[flang] Merge pull request flang-compiler/f18#832 from DavidTruby/drone_ci
Change images used for CI to solve build issues
Original-commit: flang-compiler/f18@
369327a6d0c512973359f57a90b5482f45b2b6f2
Reviewed-on: https://github.com/flang-compiler/f18/pull/832
David Truby [Mon, 18 Nov 2019 14:27:34 +0000 (14:27 +0000)]
[flang] Another atempt to lower core count
Original-commit: flang-compiler/f18@
60eeb446b160826d587adeea939cc99416c03df5
Reviewed-on: https://github.com/flang-compiler/f18/pull/832
David Truby [Mon, 18 Nov 2019 10:04:54 +0000 (10:04 +0000)]
[flang] Change images used for CI to solve build issues
Original-commit: flang-compiler/f18@
325b26b3a4025d4c54725db6b557276025f706fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/832
Tree-same-pre-rewrite: false
Steve Scalpone [Sat, 16 Nov 2019 22:03:47 +0000 (14:03 -0800)]
[flang] Merge pull request flang-compiler/f18#826 from flang-compiler/sjs-feature-rename
Rename features.h
Original-commit: flang-compiler/f18@
6cf3196dbf3b857c5f308101709b473a5578743a
Reviewed-on: https://github.com/flang-compiler/f18/pull/826
Steve Scalpone [Fri, 15 Nov 2019 04:34:50 +0000 (20:34 -0800)]
[flang] Rename flang-features to Fortran-features; update the guard macro.
Original-commit: flang-compiler/f18@
1a7f5596ecab5eb954130713c5b9e4f6a16c5ab7
Reviewed-on: https://github.com/flang-compiler/f18/pull/826
Steve Scalpone [Thu, 14 Nov 2019 23:16:38 +0000 (15:16 -0800)]
[flang] Rename features.h because many linux systems have an include file called features.h which can complicate makefiles that use a search path.
Original-commit: flang-compiler/f18@
fc34d0ddf355e4f978e2cb984486191041c24ea9
Reviewed-on: https://github.com/flang-compiler/f18/pull/826
Tree-same-pre-rewrite: false
Peter Klausler [Fri, 15 Nov 2019 18:36:18 +0000 (10:36 -0800)]
[flang] Merge pull request flang-compiler/f18#825 from flang-compiler/pmk-call10
Extend, enable, and pass test call10.f90 (restrictions on PURE subprograms)
Original-commit: flang-compiler/f18@
bf1cc4a9bb821aa1cc12c189c2c3a05b7bf11619
Reviewed-on: https://github.com/flang-compiler/f18/pull/825
peter klausler [Tue, 12 Nov 2019 23:43:09 +0000 (15:43 -0800)]
[flang] Semantic checks for PURE subprograms (test call10.f90)
Fix bug found in testing
Original-commit: flang-compiler/f18@
ccdd7326ba56c5a3cf8bc944516e3d1b93b25848
Reviewed-on: https://github.com/flang-compiler/f18/pull/825