Commit graph

2721 commits

Author SHA1 Message Date
Peter Klausler a318aee272 [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@8d2b296fe1
Reviewed-on: https://github.com/flang-compiler/f18/pull/862
2019-12-16 15:05:42 -08:00
peter klausler 828eed971b [flang] Improve commentary
Original-commit: flang-compiler/f18@364ac83bfc
Reviewed-on: https://github.com/flang-compiler/f18/pull/862
2019-12-16 14:28:57 -08:00
peter klausler 40f0e01d2d [flang] Outline per-type parsers to reduce f18 build-time
CPU & memory requirements

Original-commit: flang-compiler/f18@f48fe07dfa
Reviewed-on: https://github.com/flang-compiler/f18/pull/862
Tree-same-pre-rewrite: false
2019-12-16 12:55:41 -08:00
Tim Keith b738d4ad38 [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@9862c94061
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
2019-12-16 14:50:19 -08:00
Tim Keith ea00274e6d [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@9ad12e7c13
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
2019-12-16 14:48:27 -08:00
Tim Keith 6e2e78a09e [flang] C774: Defined operator/assignment may not have NOPASS
Original-commit: flang-compiler/f18@6bfa3d3568
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
Tree-same-pre-rewrite: false
2019-12-16 14:48:27 -08:00
Tim Keith e567bf9f5e [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@1f7ff22145
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
Tree-same-pre-rewrite: false
2019-12-16 14:48:22 -08:00
Peter Klausler 968eabbd9d [flang] Merge pull request flang-compiler/f18#871 from flang-compiler/pmk-fixes
Fix remaining failures in expression semantics

Original-commit: flang-compiler/f18@7473f0bcd7
Reviewed-on: https://github.com/flang-compiler/f18/pull/871
2019-12-16 12:54:55 -08:00
peter klausler d08b010408 [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@52ff319de2
Reviewed-on: https://github.com/flang-compiler/f18/pull/871
2019-12-16 12:34:44 -08:00
Eric Schweitz f061d34509 [flang] Merge pull request flang-compiler/f18#869 from schweitzpgi/master
remove stale optimizer files

Original-commit: flang-compiler/f18@6a8dec4991
Reviewed-on: https://github.com/flang-compiler/f18/pull/869
2019-12-16 08:39:17 -08:00
Eric Schweitz f90350021a [flang] remove stale optimizer files
Original-commit: flang-compiler/f18@c497c135f6
Reviewed-on: https://github.com/flang-compiler/f18/pull/869
2019-12-13 14:46:20 -08:00
Eric Schweitz 5c5880db2f [flang] Merge pull request flang-compiler/f18#868 from schweitzpgi/remove-flatten
remove some old files

Original-commit: flang-compiler/f18@3d05d39e36
Reviewed-on: https://github.com/flang-compiler/f18/pull/868
2019-12-11 16:47:06 -08:00
Eric Schweitz abf50fc3a7 [flang] remove some old files
Original-commit: flang-compiler/f18@d7554c7605
Reviewed-on: https://github.com/flang-compiler/f18/pull/868
2019-12-11 13:33:02 -08:00
Gary Klimowicz 3e65606837 [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@61bb9db531
Reviewed-on: https://github.com/flang-compiler/f18/pull/867
2019-12-11 11:13:48 -08:00
Kiran Kumar T P b96a26c1fc [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@ae4868e572
Reviewed-on: https://github.com/flang-compiler/f18/pull/857
2019-12-11 09:11:59 -08:00
jeanPerier a66086749b [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@53545d7436
Reviewed-on: https://github.com/flang-compiler/f18/pull/865
2019-12-10 23:52:48 -08:00
Jean Perier cdf4ef4962 [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@9a84bcb9ac
Reviewed-on: https://github.com/flang-compiler/f18/pull/865
2019-12-10 01:21:50 -08:00
arjunsuresh1987 562b067439 [flang] Fix file path in cmake (flang-compiler/f18#844)
Original-commit: flang-compiler/f18@4771f8cb78
Reviewed-on: https://github.com/flang-compiler/f18/pull/844
2019-12-10 14:07:56 -08:00
Peter Klausler 84c0faa5b6 [flang] Merge pull request flang-compiler/f18#864 from flang-compiler/pmk-fix
Revert recent addition of ActualArgument::PassedObject

Original-commit: flang-compiler/f18@d1b6e3cd2c
Reviewed-on: https://github.com/flang-compiler/f18/pull/864
2019-12-10 12:39:52 -08:00
peter klausler e693198c5c [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@e58c4e53c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/864
2019-12-10 11:56:40 -08:00
Tim Keith a27ed74672 [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@b3bb698086
Reviewed-on: https://github.com/flang-compiler/f18/pull/863
2019-12-09 14:26:59 -08:00
Tim Keith ef68ed381d [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@be83590183
Reviewed-on: https://github.com/flang-compiler/f18/pull/863
2019-12-09 13:36:19 -08:00
jeanPerier ed37b52fef [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@722caa61f2
Reviewed-on: https://github.com/flang-compiler/f18/pull/858
2019-12-09 02:53:53 -08:00
Jean Perier ce1bd44198 [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@0d6b9c33aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/858
2019-12-09 02:32:28 -08:00
Peter Klausler f8ae66dd11 [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@2ebb75529c
Reviewed-on: https://github.com/flang-compiler/f18/pull/859
2019-12-06 13:56:08 -08:00
peter klausler 6c390a780b [flang] Accept source files with no program units (flang-compiler/f18#658)
update documentation

Original-commit: flang-compiler/f18@3dfb831499
Reviewed-on: https://github.com/flang-compiler/f18/pull/859
2019-12-06 13:55:45 -08:00
Peter Klausler 47575727f7 [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@169f380eaf
Reviewed-on: https://github.com/flang-compiler/f18/pull/856
2019-12-06 09:52:37 -08:00
peter klausler 00c3c274de [flang] Allow assignment between INTEGER and LOGICAL as extension
Extend documentation

Original-commit: flang-compiler/f18@7a719198fc
Reviewed-on: https://github.com/flang-compiler/f18/pull/856
2019-12-06 09:38:54 -08:00
Peter Klausler 371399b8e1 [flang] Merge pull request flang-compiler/f18#855 from flang-compiler/pmk-fix
Fix problems with passed-object arguments...

Original-commit: flang-compiler/f18@882d20d4fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/855
2019-12-05 12:50:21 -08:00
peter klausler f439356f61 [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@5eb60ec419
Reviewed-on: https://github.com/flang-compiler/f18/pull/855
2019-12-05 11:56:29 -08:00
jeanPerier 0aa8f5f643 [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@84c57b8e01
Reviewed-on: https://github.com/flang-compiler/f18/pull/851
2019-12-04 02:07:31 -08:00
Jean Perier b0371c2fd5 [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@4550a23d0b
Reviewed-on: https://github.com/flang-compiler/f18/pull/851
2019-12-03 09:28:33 -08:00
Peter Klausler c559c42c14 [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@7471db2be0
Reviewed-on: https://github.com/flang-compiler/f18/pull/852
2019-12-03 10:59:46 -08:00
peter klausler 9cf3c638ec [flang] Fix forward ref to derived type when symbol exists
Fix some comments

Original-commit: flang-compiler/f18@3274ed9545
Reviewed-on: https://github.com/flang-compiler/f18/pull/852
2019-12-03 10:51:19 -08:00
Peter Klausler 31624ae53f [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@db7214e2e6
Reviewed-on: https://github.com/flang-compiler/f18/pull/850
2019-12-03 10:48:19 -08:00
peter klausler 64ea224ace [flang] Fix bug flang-compiler/f18#843, bad recovery from failed opens of source files
Original-commit: flang-compiler/f18@27d9db610f
Reviewed-on: https://github.com/flang-compiler/f18/pull/850
2019-12-03 10:47:46 -08:00
Tim Keith 1564d2735c [flang] Merge pull request flang-compiler/f18#849 from flang-compiler/tsk-pure
Fix PURE check on procedure binding

Original-commit: flang-compiler/f18@58f036ec01
Reviewed-on: https://github.com/flang-compiler/f18/pull/849
2019-12-03 10:28:39 -08:00
Tim Keith 203627d3a5 [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@c95f2eb4fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/849
2019-12-03 08:43:05 -08:00
Peter Klausler 293c7c28a8 [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@567a1642f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/848
2019-12-03 09:19:26 -08:00
peter klausler b1e7ec6620 [flang] Dodge GCC 7.2 bug
Original-commit: flang-compiler/f18@bde158343a
Reviewed-on: https://github.com/flang-compiler/f18/pull/848
2019-12-02 15:56:00 -08:00
Peter Klausler 29a890e631 [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@5928825790
Reviewed-on: https://github.com/flang-compiler/f18/pull/847
2019-12-02 14:17:35 -08:00
peter klausler 780c2aea65 [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@b66ba55a73
Reviewed-on: https://github.com/flang-compiler/f18/pull/847
2019-12-02 13:53:57 -08:00
psteinfeld e373ddf6cd [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@a5a55d5f3f
Reviewed-on: https://github.com/flang-compiler/f18/pull/834
2019-12-02 13:31:26 -08:00
Pete Steinfeld 7139a04e31 [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@8c4fadfe00
Reviewed-on: https://github.com/flang-compiler/f18/pull/834
2019-12-02 13:26:31 -08:00
Tim Keith b0823c7b69 [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@b900762eed
Reviewed-on: https://github.com/flang-compiler/f18/pull/846
2019-12-02 08:55:44 -08:00
kiranchandramohan 201119217f [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@6b8284f4f2
Reviewed-on: https://github.com/flang-compiler/f18/pull/842
2019-11-26 15:34:03 -06:00
Tim Keith 477bd3c67e [flang] Merge pull request flang-compiler/f18#841 from flang-compiler/tsk-assignment3
Analyze defined assignments

Original-commit: flang-compiler/f18@706a166476
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
2019-11-26 13:30:42 -08:00
Tim Keith 18f3a2beef [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@5c87071210
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
2019-11-26 13:22:17 -08:00
Tim Keith ddb4f259f6 [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@675b0b9bb7
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
2019-11-26 11:19:04 -08:00
Tim Keith e67f6a775e [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@6180d1fb9b
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
2019-11-26 11:19:04 -08:00