Commit Graph

2326 Commits

Author SHA1 Message Date
peter klausler e6ab4a7869 [flang] Address complaints in bug flang-compiler/f18#912
Original-commit: flang-compiler/f18@829f5647d6
Reviewed-on: https://github.com/flang-compiler/f18/pull/917
2020-01-09 09:39:09 -08:00
peter klausler d267f20a07 [flang] Fold TRIM
Accept IS_CONTIGUOUS and fold it

test folding is_contiguous

Original-commit: flang-compiler/f18@c75a0791b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/911
2020-01-08 08:44:30 -08:00
peter klausler 91a2f0c75c [flang] Implement folding of INDEX, SCAN, & VERIFY
Fold LEN_TRIM

Fold REPEAT

Fix gcc build warning

Fix two tests that had illegal pointers to coarrays

Original-commit: flang-compiler/f18@36769996fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/910
2020-01-07 13:06:08 -08:00
peter klausler 01c3e4c9f0 [flang] enable semantic analysis by default
back out -Mnolargearray default temporarily

Fix C_F_POINTER(SHAPE=) argument check, it can be any kind of integer

Revert default result kind of SIZE() & al. to standard by default

Remove needless usage of -fdebug-semantics

Original-commit: flang-compiler/f18@57058a5b16
Reviewed-on: https://github.com/flang-compiler/f18/pull/907
2020-01-07 10:24:33 -08:00
Kiran Chandramohan 582b932542 [flang] Semantic checks for critical construct
The commit includes the following,
-> The name field in DoConcurrent*Enforce classes are not used anymore.
Removing the field and its collection and retrieval from
DoConcurrentBodyEnforce and its usage in DoConcurrentLabelEnforce.
-> DoConcurrentLabelEnforce is useful for checking that there
are no branches escaping from other constructs also. For enabling
use in other constructs (like critical) moving this to tools.h
and renaming it as LabelEnforce.
-> Checks for the constraints.
-> Tests for the constaints.

Original-commit: flang-compiler/f18@4b7a007ff3
Reviewed-on: https://github.com/flang-compiler/f18/pull/897
2020-01-04 15:13:28 +00:00
peter klausler cc179ba749 [flang] Fold FLOOR, CEILING, NINT, and ANINT
Add GetUltimate() to ResolveAssociations(), fixing a UBOUND test case with use association

Fix folding of array-valued subscripts while I am in here

Original-commit: flang-compiler/f18@f663d4fef4
Reviewed-on: https://github.com/flang-compiler/f18/pull/905
2020-01-03 16:12:06 -08:00
peter klausler 39114d503a [flang] Another attempt to fix bug flang-compiler/f18#877
Original-commit: flang-compiler/f18@2ad2330cda
Reviewed-on: https://github.com/flang-compiler/f18/pull/906
2020-01-03 15:08:37 -08:00
Tim Keith d42aaa81f2 [flang] Add analyzed form of pointer assignment
Add `typedAssignment` to `PointerAssignmentStmt` parse tree node and
extend `evaluate::Assignment` to include pointer assignment, including
analyzed bounds. Analyze pointer assignments and fill those in.
Emit them in unparsed output and parse tree dump when present.

Change assignment checking to use analyzed expressions and assignments
rather than calling AnalyzeExpr. Check bounds in pointer assignments
for impure function calls in FORALL context.

Add `Fold` convenience function to `ExpressionAnalyzer`.

Original-commit: flang-compiler/f18@140c983423
Reviewed-on: https://github.com/flang-compiler/f18/pull/904
2020-01-03 14:10:26 -08:00
Tim Keith b58617b940 [flang] Use common SymbolSet type
Replace `std::set<const Symbol *>` with `SymbolSet` from `symbol.h`.

Original-commit: flang-compiler/f18@78e3ff33cc
Reviewed-on: https://github.com/flang-compiler/f18/pull/904
Tree-same-pre-rewrite: false
2020-01-03 14:09:47 -08:00
Tim Keith ec88d6780f [flang] Fix type resolution in ConcurrentHeader
As it was implemented we weren't detecting non-constant kind parameters
in the integer-type-spec. The fix is just to walk the integer-type-spec
like was do any other one.

Also, there is not need for ResolveControlExpressions -- all it does is
walk that part of the parse tree.

Original-commit: flang-compiler/f18@8c0d890eb8
Reviewed-on: https://github.com/flang-compiler/f18/pull/904
Tree-same-pre-rewrite: false
2020-01-03 14:09:47 -08:00
Tim Keith 83d574bf07 [flang] Move forall01 to ERROR_TESTS
That seems to be what was intended and it provides for better checking
of errors.

Original-commit: flang-compiler/f18@99376d77a0
Reviewed-on: https://github.com/flang-compiler/f18/pull/904
Tree-same-pre-rewrite: false
2020-01-03 14:09:42 -08:00
peter klausler 2e32cadddd [flang] Remove needless std::move() that breaks clang build
Add the std::move() to where it should have been

Original-commit: flang-compiler/f18@54fe9b39a1
Reviewed-on: https://github.com/flang-compiler/f18/pull/903
2020-01-03 11:32:44 -08:00
Pete Steinfeld d32d669651 [flang] Check for passing DO variables to OUT arguments in a CALL statement
I added code to save the INTENT of a dummy argument in the checked expression
of the actual argument.  When processing a CallStmt, I then retrieve the
ProcedureRef, which contains a list of the checked ActualArguments.  I then
traverse this list looking for actual arguments that are active DO variable
that are being passed to dummy arguments whose INTENT is either OUT or INOUT.
For OUT dummies, I put out an error message and warn for INOUT dummies.

Original-commit: flang-compiler/f18@0ff1d26428
Reviewed-on: https://github.com/flang-compiler/f18/pull/902
2020-01-03 08:53:42 -08:00
peter klausler 9948f910a5 [flang] Handle type-bound user-defined operators
Pre-review clean-up

Original-commit: flang-compiler/f18@1d4e85563a
Reviewed-on: https://github.com/flang-compiler/f18/pull/901
2020-01-02 11:49:55 -08:00
Tim Keith 96ce00bba2 [flang] Add .mod file dependencies
Make compilation of other predefined module files depend on
__fortran_builtins.mod. Currently only iso_c_binding.f90 and
iso_fortran_env.f90 depend on it but others could in the future.

Create the .f18.mod files by copying from the .mod files so that
we don't have to worry about dependencies for those.

Original-commit: flang-compiler/f18@8209ad3d32
Reviewed-on: https://github.com/flang-compiler/f18/pull/899
2019-12-31 14:08:12 -08:00
peter klausler c587f89a3c [flang] Prep for review
Original-commit: flang-compiler/f18@25cb92e990
Reviewed-on: https://github.com/flang-compiler/f18/pull/900
2019-12-31 14:10:28 -08:00
peter klausler ceb8196023 [flang] Put templates back into implementation header
Original-commit: flang-compiler/f18@8949924351
Reviewed-on: https://github.com/flang-compiler/f18/pull/900
Tree-same-pre-rewrite: false
2019-12-31 13:58:26 -08:00
peter klausler 8deb4bbeb7 [flang] More restructuring
Original-commit: flang-compiler/f18@6e4aca113a
Reviewed-on: https://github.com/flang-compiler/f18/pull/900
Tree-same-pre-rewrite: false
2019-12-31 13:43:15 -08:00
peter klausler d64886d01b [flang] Break up fold.cc along per-type fault lines
Original-commit: flang-compiler/f18@8022c143d9
Reviewed-on: https://github.com/flang-compiler/f18/pull/900
Tree-same-pre-rewrite: false
2019-12-31 12:20:42 -08:00
peter klausler add998bec1 [flang] Make SHAPE= argument to C_F_POINTER() sensitive to -Mlargearray
Original-commit: flang-compiler/f18@daaa74bbc8
Reviewed-on: https://github.com/flang-compiler/f18/pull/900
Tree-same-pre-rewrite: false
2019-12-31 11:06:07 -08:00
peter klausler ec833a6bb7 [flang] Patch build problem
Original-commit: flang-compiler/f18@a668512100
Reviewed-on: https://github.com/flang-compiler/f18/pull/898
2019-12-31 09:19:08 -08:00
peter klausler 663db2741d [flang] C_F_POINTER
Emit INTRINSIC statements in module files

Argument checking utility

Complete error checking

Original-commit: flang-compiler/f18@9c6a88f048
Reviewed-on: https://github.com/flang-compiler/f18/pull/896
2019-12-31 08:34:53 -08:00
peter klausler b8a7bad3e0 [flang] Fix test for assignment to host-associated object in PURE
Original-commit: flang-compiler/f18@019e61aa85
Reviewed-on: https://github.com/flang-compiler/f18/pull/893
2019-12-24 17:53:01 -08:00
Steve Scalpone 71f6a80c2b [flang] The #! sequence must be at the start of the script file. (flang-compiler/f18#894)
Original-commit: flang-compiler/f18@b1ff232730
Reviewed-on: https://github.com/flang-compiler/f18/pull/894
2019-12-24 16:58:28 -08:00
Pete Steinfeld 611db270f6 [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@1bbfcca61b
Reviewed-on: https://github.com/flang-compiler/f18/pull/860
2019-12-24 15:16:36 -08:00
peter klausler 16c5b86368 [flang] Fix off-by-one error in preprocessing expressions
Original-commit: flang-compiler/f18@4c08a4a1be
Reviewed-on: https://github.com/flang-compiler/f18/pull/891
2019-12-23 16:18:21 -08:00
Gary Klimowicz a0caa6af36 [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@b308f9e35a
Reviewed-on: https://github.com/flang-compiler/f18/pull/890
2019-12-23 11:16:00 -08:00
Gary Klimowicz 9e7548ab31 [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@add6cde724
Reviewed-on: https://github.com/flang-compiler/f18/pull/887
2019-12-23 10:26:16 -08:00
Kiran Chandramohan 69d01593b4 [flang] Mark ieee_get_flag and ieee_get_halting_mode as elemental
Original-commit: flang-compiler/f18@d6237fa311
Reviewed-on: https://github.com/flang-compiler/f18/pull/886
2019-12-20 20:28:45 +00:00
peter klausler d67fbce92b [flang] Fix kind of REAL(complex) to be the same as the argument by default
Fixes for expression formatting

Original-commit: flang-compiler/f18@13e8909587
Reviewed-on: https://github.com/flang-compiler/f18/pull/885
2019-12-20 12:06:03 -08:00
peter klausler 3a725ca8d0 [flang] Auto conversion of integer scalar actual argument exprs
Add documentation

Original-commit: flang-compiler/f18@c1b200d238
Reviewed-on: https://github.com/flang-compiler/f18/pull/884
2019-12-20 10:01:49 -08:00
peter klausler 617a4cce50 [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@34b64db7da
Reviewed-on: https://github.com/flang-compiler/f18/pull/883
2019-12-19 18:05:58 -08:00
Tim Keith 2e9633125e [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@2cc226f66e
Reviewed-on: https://github.com/flang-compiler/f18/pull/879
2019-12-19 09:52:15 -08:00
Tim Keith c6aaa9875d [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@e8e7ffcae8
Reviewed-on: https://github.com/flang-compiler/f18/pull/878
2019-12-18 16:29:50 -08:00
Tim Keith 37de6803e3 [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@823b044d2a
Reviewed-on: https://github.com/flang-compiler/f18/pull/878
Tree-same-pre-rewrite: false
2019-12-18 16:29:08 -08:00
peter klausler e668139fdc [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@49d68700e0
Reviewed-on: https://github.com/flang-compiler/f18/pull/874
2019-12-18 16:10:16 -08:00
peter klausler cfe146bfde [flang] Back some changes out
Original-commit: flang-compiler/f18@7f6345ac62
Reviewed-on: https://github.com/flang-compiler/f18/pull/873
2019-12-17 12:32:16 -08:00
peter klausler cd1d3881f1 [flang] Save analyzed CALL statements in the parse tree
Original-commit: flang-compiler/f18@bd618f179c
Reviewed-on: https://github.com/flang-compiler/f18/pull/873
Tree-same-pre-rewrite: false
2019-12-17 10:53:20 -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 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 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 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 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
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 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 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
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 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 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 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
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 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 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 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 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 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
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 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
Tim Keith b51673cab9 [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@9e0d79f173
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
2019-11-26 11:18:59 -08:00
Tim Keith 67c548376d [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@cd0d6930bb
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
2019-11-26 11:18:53 -08:00
Tim Keith abc99c63ff [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@5f1c2ff663
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
2019-11-26 11:18:53 -08:00
Tim Keith e2b939e5f3 [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@f65a9edca2
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
2019-11-26 11:18:53 -08:00
Tim Keith 701a9bd0e5 [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@c74327c393
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
2019-11-26 11:18:47 -08:00
peter klausler e46cd9ee18 [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@79018f7126
Reviewed-on: https://github.com/flang-compiler/f18/pull/836
2019-11-22 14:16:48 -08:00
Isuru Fernando fe7e36d46c [flang] Need algorithm for std::min (flang-compiler/f18#837)
Original-commit: flang-compiler/f18@d20a79cdd9
Reviewed-on: https://github.com/flang-compiler/f18/pull/837
2019-11-22 14:54:36 -07:00
peter klausler 223499ec99 [flang] Address review comments
Original-commit: flang-compiler/f18@0ce592c7c5
Reviewed-on: https://github.com/flang-compiler/f18/pull/835
2019-11-21 13:55:17 -08:00
peter klausler 4d372b6dc1 [flang] Reformat all C++ in lib/*
Original-commit: flang-compiler/f18@232bcedb66
Reviewed-on: https://github.com/flang-compiler/f18/pull/835
Tree-same-pre-rewrite: false
2019-11-21 13:35:20 -08:00
peter klausler 11ce9b0823 [flang] Revert Symbol::operator=() changes
Rearrange "if" nest for clarity

Pass call12.f90 test.

Original-commit: flang-compiler/f18@69a1a2b796
Reviewed-on: https://github.com/flang-compiler/f18/pull/835
Tree-same-pre-rewrite: false
2019-11-21 11:41:27 -08:00
Pete Steinfeld fd76cc47c5 [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@7d1932d344
Reviewed-on: https://github.com/flang-compiler/f18/pull/814
2019-11-21 11:14:51 -08:00
peter klausler ff765f8500 [flang] For call11.f90: more checks on PURE subprograms and TBP bindings
Original-commit: flang-compiler/f18@7aa47f0b9e
Reviewed-on: https://github.com/flang-compiler/f18/pull/833
2019-11-19 14:52:03 -08:00
peter klausler fc94aa6d32 [flang] Define runtime I/O library interface to be used by generated code.
Original-commit: flang-compiler/f18@82cb9b0c87
Reviewed-on: https://github.com/flang-compiler/f18/pull/802
2019-11-19 10:11:23 -08:00
David Truby f3cab5281d [flang] Another atempt to lower core count
Original-commit: flang-compiler/f18@60eeb446b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/832
2019-11-18 14:27:34 +00:00
David Truby e5b754e810 [flang] Change images used for CI to solve build issues
Original-commit: flang-compiler/f18@325b26b3a4
Reviewed-on: https://github.com/flang-compiler/f18/pull/832
Tree-same-pre-rewrite: false
2019-11-18 10:19:02 +00:00
Steve Scalpone 33dad73187 [flang] Rename flang-features to Fortran-features; update the guard macro.
Original-commit: flang-compiler/f18@1a7f5596ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/826
2019-11-14 20:34:50 -08:00
Steve Scalpone ccee728e5a [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@fc34d0ddf3
Reviewed-on: https://github.com/flang-compiler/f18/pull/826
Tree-same-pre-rewrite: false
2019-11-14 15:16:38 -08:00
peter klausler ed1ed24ec2 [flang] Semantic checks for PURE subprograms (test call10.f90)
Fix bug found in testing

Original-commit: flang-compiler/f18@ccdd7326ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/825
2019-11-15 10:30:14 -08:00
David Truby 608ea6414d [flang] Disable arm64 gcc builds in CI until they can be fixed
Currently the arm64 gcc builds in CI are getting stuck,
so disable these to get CI working again until they're fixed.

Original-commit: flang-compiler/f18@49803e62ee
Reviewed-on: https://github.com/flang-compiler/f18/pull/829
2019-11-15 16:30:28 +00:00
Tim Keith 158f9e09fc [flang] Fix bad deference in ProgramTree
We weren't handling MainProgram with no ProgramStmt correctly in
ProgramTree. When building it we were dereferencing an empty optional.
And in ResolveSpecificationParts we were dereferencing a null pointer.

Original-commit: flang-compiler/f18@1bda90d005
Reviewed-on: https://github.com/flang-compiler/f18/pull/827
2019-11-14 19:22:24 -08:00
David Truby 056f5f73b7 [flang] Reduce number of threads used for building.
This is to avoid running out of memory on some builds.

Original-commit: flang-compiler/f18@f8abe443cf
Reviewed-on: https://github.com/flang-compiler/f18/pull/823
2019-11-14 15:16:15 +00:00
David Truby 877b26598d [flang] Add CI file for cloud.drone.io
Original-commit: flang-compiler/f18@32252639ab
Reviewed-on: https://github.com/flang-compiler/f18/pull/823
Tree-same-pre-rewrite: false
2019-11-13 11:31:44 +00:00
kiranktp 17332e283e [flang] Fix for flang-compiler/f18#694 - Unexpected error when compiling submodule
Incorporated all review comments and updated the test case.

Change-Id: I03939bfc705cc5319a0b7da3305026b8403b8edc

Original-commit: flang-compiler/f18@5c602bfbc7
Reviewed-on: https://github.com/flang-compiler/f18/pull/817
2019-11-14 17:14:57 +05:30
kiranktp e572117f8b [flang] Fix for flang-compiler/f18#694 - Unexpected error when compiling submodule
Incorporated all review comments and updated the test case.

Change-Id: I03939bfc705cc5319a0b7da3305026b8403b8edc

Original-commit: flang-compiler/f18@a52b0367ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/817
Tree-same-pre-rewrite: false
2019-11-14 11:12:39 +05:30
kiranktp deffc7a55c [flang] Fix for flang-compiler/f18#694 - Unexpected error when compiling submodule
Incorporated all review comments and updated the test case.

Change-Id: I03939bfc705cc5319a0b7da3305026b8403b8edc

Original-commit: flang-compiler/f18@010da4228e
Reviewed-on: https://github.com/flang-compiler/f18/pull/817
Tree-same-pre-rewrite: false
2019-11-14 10:54:52 +05:30
kiranktp c1ca1b2b7f [flang] Fix for flang-compiler/f18#694 - Unexpected error when compiling submodule
Change-Id: I03939bfc705cc5319a0b7da3305026b8403b8edc

Original-commit: flang-compiler/f18@e1237939aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/817
Tree-same-pre-rewrite: false
2019-11-07 15:17:57 +05:30
Tim Keith b5c7193769 [flang] Fix crashes in ResolveOmpObject and RewriteOpenMPLoopConstruct
Using debug build of f18, `omp-resolve01.f90` sometimes crashed in
`OmpVisitor::ResolveOmpObject`. This was because when the designator was
analyzed it could be rewritten from an `ArrayElement` to a `Substring`.
That made the reference to the `Name` inside the designator no longer
valid so the crash happened when it was referenced later. The fix is to
return when the substring is detected so the name is not referenced.

Also, the name returned from `ResolveDesignator` can but null so it must
be checked.

The crash in `RewriteOpenMPLoopConstruct` happened intermittently on
`omp-loop-association.f90`. It happened when the DO construct was the
last element of the block. In that case `block.erase()` returns an
iterator pointing to `block.end()` which must not be dereferenced.

Original-commit: flang-compiler/f18@3299972d04
Reviewed-on: https://github.com/flang-compiler/f18/pull/824
2019-11-14 15:01:20 -08:00
peter klausler 18f5ce5964 [flang] Remove most comparisons to nullptr
Remove needless usage of has_value()

Original-commit: flang-compiler/f18@1da7fcf7a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/822
2019-11-11 14:40:59 -08:00
peter klausler 6c9b8845e9 [flang] checkpoint, all tests pass
Fix name resolution for undeclared intrinsic actual arguments

Original-commit: flang-compiler/f18@12470f06bc
Reviewed-on: https://github.com/flang-compiler/f18/pull/818
2019-11-09 08:37:39 -08:00
sameeranjoshi17 8d216b40c8 [flang] Added passing test case
Original-commit: flang-compiler/f18@752142055b
Reviewed-on: https://github.com/flang-compiler/f18/pull/808
2019-11-06 17:13:22 +05:30
sameeranjoshi17 4aac676c54 [flang] Added test case for semantic check of OpenMP Master construct
Original-commit: flang-compiler/f18@22f3088c76
Reviewed-on: https://github.com/flang-compiler/f18/pull/808
Tree-same-pre-rewrite: false
2019-11-06 14:18:12 +05:30
sameeranjoshi17 e2166e1ca0 [flang] semantic checks for Master construct
Original-commit: flang-compiler/f18@b052a71062
Reviewed-on: https://github.com/flang-compiler/f18/pull/808
Tree-same-pre-rewrite: false
2019-11-03 23:08:26 +05:30
Tim Keith 9b31cbe7db [flang] Add support for logical abbreviations and .XOR.
Update the grammar to handle logical abbreviations (e.g. `.A.` for `.AND.`)
when the feature is enabled. Only support `.X.` when both XOR and
logical abbreviations are enabled.

Fix the driver to enable logical abbreviations with the
`-flogical-abbreviations` option. This was already documented in
`documentation/Extensions.md`.

Remove `parser::Expr::XOR` from the parse tree and immediately map
`.XOR.` to `.NEQV.` if that feature is enabled. This was already being
done during expression analysis anyway.

Add `LanguageFeatureControl::GetNames` to return all of the names of
a logical or relational operator, depending on which features are
enabled. Use these in both name resolution and expression analysis.
Add `Not` to `LogicalOperator` to help in those cases.

Fix handling of BOZ literals: A numeric operation with one real or
integer operand and the other a BOZ literal is intrinsic.
Also, unary plus with a BOZ literal operand is also intrinsic.

Original-commit: flang-compiler/f18@956bd50bc7
Reviewed-on: https://github.com/flang-compiler/f18/pull/815
2019-11-07 14:45:58 -08:00
Tim Keith cae50f01ff [flang] Move features.h from parser to common
Which features are enabled and disabled applies to more than just the
parser, so move that functionality to `common`.

Original-commit: flang-compiler/f18@98b3240efc
Reviewed-on: https://github.com/flang-compiler/f18/pull/815
Tree-same-pre-rewrite: false
2019-11-06 11:15:03 -08:00
peter klausler a717d170cc [flang] Change more pointers into references
Remove unused interface

Respond to review comments

Original-commit: flang-compiler/f18@7fdfe7b4ac
Reviewed-on: https://github.com/flang-compiler/f18/pull/809
2019-11-05 10:28:17 -08:00
vdonaldson 65791b2d0b [flang] Relax the implementation of constraint C1302. (flang-compiler/f18#805)
* Relax the implementation of constraint C1302.

When a list of format items can be unambiguously partitioned into individual items even though one or more otherwise required comma separators are omitted, generate a warning rather than an error.

Fixes flang-compiler/f18#703

Original-commit: flang-compiler/f18@79c0731137
Reviewed-on: https://github.com/flang-compiler/f18/pull/805
2019-11-05 10:11:36 -08:00
Jean Perier 572de7c7b0 [flang] Implement MIN and MAX folding
* Use Extremum<T> FoldOperation to fold MIN and MAX
* Fix Extremum<T> FolOperation
    * For character, the length is the one of the longest argument.
      Define and use `CharacterUtils<Kind>::Resize` helper to do this.
    * For array of all types, Extremum<T> with Ordering::Less was
      behaving like Ordering::Greater. This is because the default
      `ApplyElementwise` for `Operation` was selected and it then
       called the Extremum<T> constructor without the ordering
       argument (which was an optional defaulted to Greater).
      Define a specific handler for Extremum<T> and make the ordering
      argument mandatory to prevent this kind of bug to pass
      f18 compilation in the futur.
* Fix intrinsic.cc for MIN and MAX
    * When provided with two arguments, `Match` was adding an empty
      3rd optional actual argument. Later code working on min and
      max was not expecting this and failing. The fix prevent this
      empty argument to be created by changing the initial size of
      `actualForDummy` to actually be the number of dummies that do
      not have `Optionality::Repeats`

This commit fixes issue flang-compiler/f18#677.

Original-commit: flang-compiler/f18@acb62f240b
Reviewed-on: https://github.com/flang-compiler/f18/pull/803
2019-11-05 02:54:12 -08:00
peter klausler 2c89c31a59 [flang] Enable and pass call08.f90
Refine a check

Original-commit: flang-compiler/f18@bb96c195d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/812
2019-11-04 14:35:36 -08:00
Tim Keith cf9059ae98 [flang] Fix build error using clang
Change `AllFortranNames()` to return a `std::vector` rather than a
`std::initialization_list`. The latter doesn't own its underlying
storage and so can't be returned as a value. clang detects this and
issues a warning.

Two tests in `resolve63.f90` behave differently with clang and require
further investigation.

Original-commit: flang-compiler/f18@1ed3a3cfee
Reviewed-on: https://github.com/flang-compiler/f18/pull/810
2019-11-04 12:05:51 -08:00
Tim Keith dce7f0aca0 [flang] Resolve extended intrinsic operators
Enhance `ArgumentAnalyzer` to do most of the work for this.
For each kind of operator that might have a user-defined form we follow
this process:
- analyze the arguments
- if the types and shapes match the intrinsic operator do the usual
  processing
- otherwise attempt to interpret it as a user-defined operator with
  `TryDefinedOp`

When we fail to resolve an operator, produce different errors depending
on whether there is a user-defined operator available or not.
If there is, report that neither user-defined nor intrinsic operator
worked. If there is not, describe the rules for the intrinsic operator.
In either case, include the type(s) of the operand(s).

Most of the uses of `ArgumentAnalyzer` are in helper functions that
apply to classes of operators.
For consistency, rename `BinaryOperationHelper` to `NumericBinaryOperator`
and `LogicalHelper` to `LogicalBinaryHelper` and introduce `NumericUnaryHelper`
for unary `+` and `-`.  `.NOT.` and `//` are not implemented in helpers.

Replace `success_` with `fatalErrors_` in `ArgumentAnalyzer` for
consistency with `ExpressionAnalyzer`.

Add `NumericOperator` and `LogicalOperator` enums to `Fortran.h` to go
with `RelationalOperator`. Add `AddFortran` functions to each to convert
to a Fortran source string. `RelationalOperator` also has `AllFortranNames`
because there are multiple names for each operator. This replaces
`LogicalOperator` in `expression.h` and the string representation of
the operators in `formatting.cc`.

Original-commit: flang-compiler/f18@3bb9d664e8
Reviewed-on: https://github.com/flang-compiler/f18/pull/807
2019-11-04 10:47:43 -08:00
peter klausler c14c2b9573 [flang] Enable and pass test call07.f90
Remove a std::move()

Final tweaks after testing and review

Original-commit: flang-compiler/f18@b3fe97b1a0
Reviewed-on: https://github.com/flang-compiler/f18/pull/806
2019-11-02 10:20:39 -07:00
peter klausler 7a681f46f8 [flang] Use c_str() rather than data() where NUL termination is assumed
Original-commit: flang-compiler/f18@5baed3c856
Reviewed-on: https://github.com/flang-compiler/f18/pull/804
2019-10-31 13:25:28 -07:00
peter klausler 926da903f2 [flang] enable call06.f90 test
Relax checking when irrelevant due to INTENT(IN)

Add and pass call14.f90 test on VALUE

Allow ASYNCHRONOUS/VOLATILE to apply to host/USE associated entities, add tests

Pass call06

Check C827 & C828, fix tests

Original-commit: flang-compiler/f18@df6cb83794
Reviewed-on: https://github.com/flang-compiler/f18/pull/801
2019-10-30 15:50:28 -07:00
peter klausler afd39cd49c [flang] Use reference_wrapper in vectors and sets
Convert some CharBlock references to values

Replace more pointers with reference wrappers

Restore object references that were converted to value semantics in an earlier commit

Use Reference<> in Scope

Fix new component iterator

Document pitfall that bit me

final tweaks before rebasing and merging

Rebasing

Original-commit: flang-compiler/f18@87874af934
Reviewed-on: https://github.com/flang-compiler/f18/pull/788
2019-10-29 12:32:28 -07:00
Jinxin Yang 2839cb3835 [flang] Throw error in case of missing listed test
Original-commit: flang-compiler/f18@dabc0ba0e0
2019-10-28 12:58:52 -07:00
Jinxin Yang 004a4c577b [flang] [OpenMP] Test Infra update to support OpenMP symbol tests
During the symbol tests, OpenMP directives (start with "!$omp")
line needs to be saved for 1.f90 and 2.f90. Also moved "OPTIONS:"
detection to common.sh as "$USER_OPTIONS"

Original-commit: flang-compiler/f18@7d4e8e8ad5
2019-10-28 12:58:15 -07:00
Jinxin Yang eeda304160 [flang] [OpenMP] address more comments
The major changes are:
  1) changed the non-nullptr type to reference
  2) changed ResolveOmpObject to use std::visit
  3) the rest of the changes are about positions and naming

Original-commit: flang-compiler/f18@93debe59f3
2019-10-25 15:16:20 -07:00
Jinxin Yang 8143b8980d [flang] [OpenMP] adjust for PR#753 `OmpObject` parse tree change
PR#753 changed the `OmpObject` to be:

```
struct OmpObject {
  UNION_CLASS_BOILERPLATE(OmpObject);
  std::variant<Designator, /*common block*/ Name> u;
};
```

This commit adjust the logic flow for `ResolveOmpObject` based on
the above parse tree change.

For an `OmpObject`,
```
if (Designator) {
  if (DataRef.Name) {
    // Resolve Names
  } else {
    // ResolveDesignator
    // AnalyzeExpr
    if (Designator.Substring) {
      // Error
    }
    // other checks like StructureComponent, ArrayElement, etc.
  }
} else if (Name) {
  // Resolve COMMON block
}
```

Original-commit: flang-compiler/f18@e5c1b92c15
2019-10-25 15:16:20 -07:00
Jinxin Yang 0554d39d74 [flang] [OpenMP] Implement no-multiple-appearance rule for DSA Clauses
DSA stands for Data-Sharing Attribute. This work is part of the
Name Resolution for OpenMP framework (data-refs on clauses part)

Based on 2.15.3: A list item that specifies a given variable may
not appear in more than one clause on the same directive, except that
a variable may be specified in both firstprivate and lastprivate clauses.

Through a temporary `std::set` of `const Symbol *` to keep track of
all the symbols on a certain OpenMP directive, we can determine whether
a variable `Name` (or `Symbol`, more accurately) has already appeared on
another DSA clause already, with the exception of FIRSTPRIVATE clause
and LASTPRIVATE clause. This rule applies to `/COMMON block/` also and
the source provenance shows on error message points to the `Name` between
slashes.

Added two more tests and changed some existing tests to accommodate
this commit. I intend to keep the `omp-clause-validity01.f90` test to
do the validity checks only.

Original-commit: flang-compiler/f18@0d7828c21e
2019-10-25 15:16:20 -07:00
Jinxin Yang df51352d72 [flang] [OpenMP] avoid creating new symbol for common block
Original-commit: flang-compiler/f18@ba2cceb4a2
2019-10-25 15:16:20 -07:00
Jinxin Yang f3961579ac [flang] [OpenMP] add common block example
Original-commit: flang-compiler/f18@a4c923e848
2019-10-25 15:16:20 -07:00
Jinxin Yang 4ca8c5dc5c [flang] [OpenMP] OmpVisitor framework for Name Resolution
This is a preliminary framework to do the name resolution for
data references on the OpenMP clauses. Unlike data references
in the OpenMP region, clauses determining the data-sharing or
data-mapping attributes are straightforward and the resolution
process could be extended to do the name resolution in the OpenMP
region. It is hard to determine what kind of checks can be done
in this visitor and what checks should be done later after name
resolution. But the guide line is that `After the completion of
this phase, every Name corresponds to a Symbol with proper OpenMP
attribute(s) determined unless an error occurred.`

1. Take data-sharing clauses as example, create new symbol for
variable that require private access within the OpenMP region.
Declare the entity implicitly if necessary. The new symbol has
`HostAssocDetails`, which is mentioned in the `OpenMP-semantics.md`.

2. For `Shared` or `ThreadPrivate`, no symbol needs to be created.
OpenMP attribute Flag `OmpThreadprivate` needs to be marked for
`Threadprivate` because the `threadprivate` attribute remains the
same whenever these variables are referenced in the program.
`Names` in `Shared` clause need to be resolved to associate the
symbols in the clause enclosing scope (contains the OpenMP directive)
but `OmpShared` does not need to be marked. Declare the entity
implicitly if necessary.

3. For `COMMON block`, when a named common block appears in a list,
it has the same meaning as if every explicit member of the common
block appeared in the list. Also, a common block name specified in
a data-sharing attribute clause must be declared to be a common
block in the same scoping unit in which the data-sharing attribute
clause appears. So, if a named common block appears on a `PRIVATE`
clause, all its members should have new symbols created within the
OpenMP region (scope). For later Semantic checks and CG, a new
symbol is also created for common block name with `HostAssocDetails`.

There are many things are still on the TODO list:
- Better error/warning messages with directive/clause source provenance

- Resolve variables referenced in the OpenMP region, for example,
  `private(tt%a)` is not allowed but `tt%a = 1` is allowed in the
  OpenMP region and a private version of `tt` maybe created for
  the region. The functions created in the `OmpVisitor` should be
  able to handle the name resolution on the statement too (more
  data structures may be introduced). This is a big portion and may
  require some interface changes to distinguish a reference is on
  `OpenMP directive/clause` or `statements within OpenMP region`.

- Same data reference appears on multiple data-sharing clauses.

- Take association into consideration for example Pointer association,
  `ASSOCIATE` construct, and etc.

- Handle `Array Sections` and `Array or Structure Element`.

- Handle all the name resolution for directives/clauses that have
  `parser::Name`.

- More tests

Original-commit: flang-compiler/f18@b2ea520885
2019-10-25 15:16:20 -07:00
Pete Steinfeld 31cc851629 [flang] Changes to check for calls to PURE procedure components
This addresses issue flang-compiler/f18#781.  I changed my test to create a PURE procedure
component by using an interface as suggested by Peter and Jean.  I then
enhanced the function IsPureProcedure() in tools.cc to cover this case
and updated the code in check-do.cc to perform the test.

Original-commit: flang-compiler/f18@5df56a217d
Reviewed-on: https://github.com/flang-compiler/f18/pull/789
2019-10-25 09:48:20 -07:00
peter klausler 7c44a2011b [flang] Restore a review comment response
Original-commit: flang-compiler/f18@d9673df31c
Reviewed-on: https://github.com/flang-compiler/f18/pull/792
2019-10-25 09:01:27 -07:00
peter klausler 715f2c0d86 [flang] Fix duplicate messages
Original-commit: flang-compiler/f18@6528c5f31b
Reviewed-on: https://github.com/flang-compiler/f18/pull/792
Tree-same-pre-rewrite: false
2019-10-24 16:38:09 -07:00
peter klausler 5f270940ff [flang] Restored changes from pmk-call05
Original-commit: flang-compiler/f18@bb9c12eec3
Reviewed-on: https://github.com/flang-compiler/f18/pull/792
Tree-same-pre-rewrite: false
2019-10-24 16:08:06 -07:00
peter klausler b5eec67fc4 [flang] Add contextualizing interfaces to ExpressionAnalyzer and ContextualMessages
Original-commit: flang-compiler/f18@30a004d7b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/790
2019-10-24 14:55:25 -07:00
Pete Steinfeld 196fec7d85 [flang] # This is a combination of 2 commits.
# This is the 1st commit message:

Changes to disallow image control statements in DO CONCURRENT

Most of these changes were already implemented.  The last remaining part was to check for calls to move_alloc with coarray arguments.  This set of changes implements that.  I also bundled other changes.  Specifically:

All of the code to detect image control statements was moved from check-do.cc to tools.cc so that it could be used by other semantic checking functions.

I added location information to the error messages for all DO semantics checks to highlight either the DO loop associated with the error or other relevant source locations.

I cleaned up the error messages associated with DO semantics so that they have more consistent grammar and punctuation.

I eliminated redundant checks for IEEE_GET_FLAG and IEEE_HALTING_MODE.

I removed the redundant test doconcurrent08.f90.

Responses to pull request comments

I changed the interface to determine whether a statement is an image control
statement to use an ExecutableConstruct as its input.  Since
ExecutableConstruct contains types that do not have source location information
(ChangeTeamConstruct and CriticalConstruct), I also created a function to get
the source location of an ExecutableConstruct.  Also, some ExecutableConstructs
are image control statements because they reference coarrays.  I wanted to tell
users that the reason that an ALLOCATE statement (for example) is an image
control statement because it references a coarray.  To make this happen, I
added another function to return a message for image control statements that
reference coarrays.

I also cleaned up the references to the standard in comments in check-do.cc to
briefly describe the contents of those constraints.

I also added messages that refer to the enclosing DO CONCURRENT statement for
error messages where appropriate.

Responses to pull request comments

The biggest change was to redo the implementation of "IsImageControlStmt()" to
use a custom visitor that strips off the "common::Indirection<...>" prefix of
most of the image control statement types and also takes advantage of
"common::HasMember<...>" to determine if a variant contains a specific type.

Spelling error.

# This is the commit message flang-compiler/f18#2:

More refactoring in response to comments on the pull request.

Original-commit: flang-compiler/f18@3f0a0155b3
Reviewed-on: https://github.com/flang-compiler/f18/pull/780
2019-10-23 14:06:16 -07:00
Tim Keith 373f7489ef [flang] Resolve defined operators to specifics
Most of these changes involve moving code around so that it case be
used for `DefinedUnary` and `DefinedBinary`. The functional changes are
in the `Analyze` member functions for those cases where the arguments
are now analyzed, the generic is resolved, and a `FunctionRef` is
created.

Add `ArgumentAnalyzer` to handling building of the `ActualArguments`
of a call. This allows the code to be shared with the defined unary
and defined binary cases. Move `AnalyzeActualArgument` and
`AnalyzeActualArgument` into that class (renaming both to `Analyze`).

Create an overload of `GetCalleeAndArguments` for the `Name` case so it
can be used for defined ops where we don't have a `ProcedureDesignator`.

Move `IsGenericDefinedOp` to `tools.h` to make it available to the
new code.

We were using `semantics::CheckExplicitInterface` to resolve a generic
interface to a specific procedure based on actual arguments. The problem
with that is that it performs too many checks. We just want to get the
right specific; there may be errors reported later during call analysis.

To fix this, add a new function, `CheckInterfaceForGeneric`, to perform
this check. It shares code with `CheckExplicitInterface`, but it passes
in a null scope to indicate that the full set of checks aren't
necessary in `CheckExplicitInterfaceArg`. Instead we lift the call to
`TypeAndShape::IsCompatibleWith` out of `CheckExplicitDataArg`, and skip
the latter when there is no scope.

Original-commit: flang-compiler/f18@fff2d1580f
Reviewed-on: https://github.com/flang-compiler/f18/pull/786
2019-10-23 06:25:51 -07:00
peter klausler 7aea2f6cb9 [flang] Fix bad new test, and fix detection of test failures in that test too
Original-commit: flang-compiler/f18@38ec2a879b
Reviewed-on: https://github.com/flang-compiler/f18/pull/787
2019-10-22 15:28:26 -07:00
peter klausler f3ae44f645 [flang] Work around a gcc-7.2 specific build bug by recoding with a better approach
Original-commit: flang-compiler/f18@bc2b4015b0
Reviewed-on: https://github.com/flang-compiler/f18/pull/785
2019-10-22 10:34:05 -07:00
peter klausler 4f761d601e [flang] Fix clang performance problem with new code
Original-commit: flang-compiler/f18@b70cac3ba8
Reviewed-on: https://github.com/flang-compiler/f18/pull/785
Tree-same-pre-rewrite: false
2019-10-21 14:58:26 -07:00
peter klausler dc4fac5634 [flang] Testing and debugging
Original-commit: flang-compiler/f18@3fa2e55bef
Reviewed-on: https://github.com/flang-compiler/f18/pull/785
Tree-same-pre-rewrite: false
2019-10-21 14:58:25 -07:00
peter klausler 2348d593ae [flang] Add software uint128_t (debugging incomplete)
Original-commit: flang-compiler/f18@5be270e604
Reviewed-on: https://github.com/flang-compiler/f18/pull/785
Tree-same-pre-rewrite: false
2019-10-21 14:58:25 -07:00
peter klausler 9cf827d297 [flang] Pass call04
Original-commit: flang-compiler/f18@5a44837804
Reviewed-on: https://github.com/flang-compiler/f18/pull/783
2019-10-21 12:44:17 -07:00
peter klausler e6bf9526e1 [flang] most call04 checks
Original-commit: flang-compiler/f18@65289a66d1
Reviewed-on: https://github.com/flang-compiler/f18/pull/783
Tree-same-pre-rewrite: false
2019-10-21 12:44:17 -07:00
peter klausler 15f38e2d67 [flang] Use component iterators in check-call.cc
Original-commit: flang-compiler/f18@e78db8907f
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
2019-10-17 15:29:26 -07:00
peter klausler 5f8817bdac [flang] Address remaining initial comments
Original-commit: flang-compiler/f18@acd307c91f
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-17 12:10:33 -07:00
peter klausler db4ae5cd98 [flang] Address most review comments
Original-commit: flang-compiler/f18@43720b5057
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-17 10:57:01 -07:00
peter klausler ca9d6be0e4 [flang] Pad short CHARACTER actual arguments
Original-commit: flang-compiler/f18@b9c890ca9c
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-16 15:36:54 -07:00
peter klausler 4abdc30b63 [flang] Revert to returning default INTEGER for LEN() and offset-in-CHARACTER intrinsics; further shape analysis of intrinsic results
Original-commit: flang-compiler/f18@561f5965b2
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-16 11:53:03 -07:00
peter klausler f090eb878e [flang] Better shape analysis for CSHIFT, EOSHIFT, SPREAD
Original-commit: flang-compiler/f18@eb43df85a6
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-16 10:35:34 -07:00
peter klausler 3a4091b5e3 [flang] Fix some bugs exposed by testing new checks
Original-commit: flang-compiler/f18@9cc70dcad6
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-16 09:39:37 -07:00
peter klausler 4c37c06597 [flang] rebase
Original-commit: flang-compiler/f18@2691da3836
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-11 15:41:11 -07:00
peter klausler b8d4f79d59 [flang] pass call03
Original-commit: flang-compiler/f18@8c076bd89b
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-10 16:36:47 -07:00
peter klausler d022fc1cca [flang] definability tests
Original-commit: flang-compiler/f18@4b71f003a9
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-10 16:33:25 -07:00
peter klausler f29394589e [flang] Move call semantic checking into lib/semantics
Original-commit: flang-compiler/f18@7996c85cf3
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-10 16:23:07 -07:00
peter klausler b71355ca1e [flang] checkpoint
checkpoint

checkpoint

Original-commit: flang-compiler/f18@99d12a7215
Reviewed-on: https://github.com/flang-compiler/f18/pull/782
Tree-same-pre-rewrite: false
2019-10-10 16:09:57 -07:00
Tim Keith 6acae749c8 [flang] Generic name resolution in expression analysis
Implement the basics of resolving generic names in expressions.

`ExpressionAnalyzer::ResolveGeneric` maps the symbol for a generic
name to the specific procedure appropriate for the actual arguments.
Extract `CheckExplicitInterface` out of `CheckArguments` so that it
can be tried for each specific procedure of the generic as part of
the test to see which is compatible.

Note that it may be there is an elemental and non-elemental specific
procedure that is compatible with the actual arguments. In that case
the generic is resolved to the non-elemental one.

Test this by using generic functions in specification expressions
that must be written to module files. Verify how the generics were
resolved by looking at the generated `.mod` files.

There is more work to be done in this area: the passed-object dummy
argument is not considered and in some cases generated module files
are not correct.

Original-commit: flang-compiler/f18@50e458045a
Reviewed-on: https://github.com/flang-compiler/f18/pull/778
2019-10-10 11:46:26 -07:00
peter klausler b32a435b0b [flang] Update preprocessing document, commentary
Extend documentation on preprocessing

IsSimplyContiguous

basic skeleton

Apply suggested improvements to mod-file.cc

Checks for new call13.f90 (15.4.2.2 explicit interfaces)

Implement checking for procedures that can be called via an implicit interface

Argument checking, test fixing

Better argument checking

Better derived type compatibility checking

Treat externals as if implicitly interfaced

Extend IEEE_EXCEPTIONS module so tests still pass with argument checking

SAME_TYPE_AS and EXTENDS_TYPE_OF intrinsic inquiry functions

Define interfaces for most intrinsic subroutines

Better PASS arguments

More with PASS() argument

Prep for review

address comments

fix comment

Remove formatted expression from specification expression error message per review

more review comments

Original-commit: flang-compiler/f18@3cca775da9
Reviewed-on: https://github.com/flang-compiler/f18/pull/776
2019-10-07 11:01:46 -07:00
peter klausler d6c8bd805f [flang] Import preprocessing tests
Original-commit: flang-compiler/f18@7ef7029604
Reviewed-on: https://github.com/flang-compiler/f18/pull/777
2019-10-04 15:21:31 -07:00
peter klausler 78d33b600e [flang] Fix flang-compiler/f18#773
Original-commit: flang-compiler/f18@d12d1129b7
Reviewed-on: https://github.com/flang-compiler/f18/pull/775
2019-10-02 15:42:07 -07:00
peter klausler 9b37989e05 [flang] Final tweaks
Original-commit: flang-compiler/f18@6e269b4e29
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
2019-10-02 16:52:27 -07:00
peter klausler 07d48c0a23 [flang] Extend documentation
Original-commit: flang-compiler/f18@7e11f8165f
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 16:30:36 -07:00
peter klausler e88bf15d2a [flang] Dodge weird clang-format behavior
Original-commit: flang-compiler/f18@48b81a2dd9
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 16:14:01 -07:00
peter klausler 4ee37ac356 [flang] Address review comments
Original-commit: flang-compiler/f18@b2a0503614
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 15:48:20 -07:00
peter klausler 5c35f3288a [flang] Retain no-op default: cases when compiling with gcc
Original-commit: flang-compiler/f18@8ebfd8d2e9
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 14:24:44 -07:00
peter klausler 637b933202 [flang] Enable more warnings, clean them up
Original-commit: flang-compiler/f18@c6b3420e5f
Reviewed-on: https://github.com/flang-compiler/f18/pull/774
Tree-same-pre-rewrite: false
2019-10-02 12:40:52 -07:00
David Truby e401082289 [flang] Removed stray comma in unparse for dist_schedule clause
Original-commit: flang-compiler/f18@0b61bc22c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/772
2019-10-03 10:59:17 +01:00
David Truby 9aa80d3353 [flang] Make the second argument to dist_schedule optional.
Original-commit: flang-compiler/f18@7ed2d0e3ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/772
Tree-same-pre-rewrite: false
2019-10-02 16:58:11 +01:00
David Truby 56efc1eca2 [flang] Added basic sema checks for distribute construct
Original-commit: flang-compiler/f18@f23059bf30
Reviewed-on: https://github.com/flang-compiler/f18/pull/771
2019-10-02 16:13:32 +01:00
David Truby 98223835c0 [flang] Added comment about gcc function cast workaround.
Original-commit: flang-compiler/f18@28bc021323
Reviewed-on: https://github.com/flang-compiler/f18/pull/767
2019-10-01 11:15:43 +01:00
David Truby c579118ce6 [flang] Replace access through union with reinterpret_cast.
This avoids undefined behaviour.

Original-commit: flang-compiler/f18@e289bbfa83
Reviewed-on: https://github.com/flang-compiler/f18/pull/767
Tree-same-pre-rewrite: false
2019-09-30 12:41:34 +01:00
Eric Schweitz 7d1696b3ad [flang] add initial Burnside bridge code
Original-commit: flang-compiler/f18@0d387d1468
Reviewed-on: https://github.com/flang-compiler/f18/pull/720
2019-10-02 10:54:12 -07:00
Pete Steinfeld 855f817d9d [flang] More semantic checking for DO constructs
This time I'm adding to the checks for constraint C1137, which states
that image control statements cannot appear in a DO CONCURRENT.  The
checks I added test to see if the DO CONCURRENT contains an ALLOCATE or
DEALLOCATE that references a coarray.

Original-commit: flang-compiler/f18@c16b883db3
Reviewed-on: https://github.com/flang-compiler/f18/pull/769
2019-10-01 13:03:40 -07:00
David Truby e0c15c4952 [flang] Added grammar comments for enter data and exit data directives
Original-commit: flang-compiler/f18@a1e6cded2f
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
2019-09-27 13:57:51 +01:00
David Truby 5776003259 [flang] Corrected check for required OpenMP clauses
Original-commit: flang-compiler/f18@ce3ec50c3f
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
Tree-same-pre-rewrite: false
2019-09-27 13:57:51 +01:00
David Truby 7c09d48218 [flang] Corrections for map semantics to match coding style
Original-commit: flang-compiler/f18@f2d97c3a1e
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
Tree-same-pre-rewrite: false
2019-09-27 13:57:51 +01:00
David Truby d3e8c76f67 [flang] Added semantic checks for map clauses
Original-commit: flang-compiler/f18@75b6228388
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
Tree-same-pre-rewrite: false
2019-09-27 13:57:51 +01:00
Eric Schweitz 5c8c0716b4 [flang] sync latest changes to these files
Original-commit: flang-compiler/f18@97becf30fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
2019-09-26 13:08:27 -07:00
Eric Schweitz cca3c31176 [flang] latest changes
Original-commit: flang-compiler/f18@c4278fe1aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-17 14:23:20 -07:00
Eric Schweitz 6bff59ec6b [flang] add FIROps.h
Original-commit: flang-compiler/f18@e53fefb66c
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-10 08:25:34 -07:00
Eric Schweitz d6bfd9135c [flang] fix name of argument
Original-commit: flang-compiler/f18@ad50545941
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-09 16:05:02 -07:00
Eric Schweitz 27e80ffd73 [flang] add attributes
Original-commit: flang-compiler/f18@d35f55b0d5
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-06 16:15:37 -07:00
Eric Schweitz 717cdbd4ac [flang] more cleanup
Original-commit: flang-compiler/f18@23fdcf77d0
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-06 13:37:14 -07:00
Eric Schweitz 38301e7fa0 [flang] changes per review comments
Original-commit: flang-compiler/f18@eb34e2d47b
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-09-06 13:25:42 -07:00
Eric Schweitz deef31dc7c [flang] add fir types header
Original-commit: flang-compiler/f18@4dc278b271
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
Tree-same-pre-rewrite: false
2019-08-28 13:53:50 -07:00
peter klausler 6e7ed4fb4d [flang] Fix flang-compiler/f18#765
Original-commit: flang-compiler/f18@bb2ffac717
Reviewed-on: https://github.com/flang-compiler/f18/pull/766
2019-09-27 14:08:09 -07:00
Pete Steinfeld c3f05ac421 [flang] Added tests for image control statements in DO CONCURRENT
There was already code in check-do.cc to test for the presence of a
variety of different image control statements, but several of them did
not have associated tests.  This change adds tests for most of them.

Also, I removed the check for the END PROGRAM statement, since its
presence causes a syntax error which prevents the semantic check from
ever being reached.

Original-commit: flang-compiler/f18@9cc6f5bd40
Reviewed-on: https://github.com/flang-compiler/f18/pull/764
2019-09-26 13:33:48 -07:00
Tim Keith a3d2966637 [flang] Fix clang build on MacOS
clang doesn't consider `std::strlen` of a constant to be a constexpr,
so just replace with the actual length.

Original-commit: flang-compiler/f18@738deab465
Reviewed-on: https://github.com/flang-compiler/f18/pull/761
2019-09-25 15:39:44 -07:00
David Truby 5efbea87cf [flang] Added grammar for teams directive to semantic checks
Original-commit: flang-compiler/f18@1cee26516b
Reviewed-on: https://github.com/flang-compiler/f18/pull/750
2019-09-19 10:02:35 +01:00
David Truby cad44d2e91 [flang] Semantic checks for teams directive
Original-commit: flang-compiler/f18@ec22e9c4c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/750
Tree-same-pre-rewrite: false
2019-09-17 12:08:04 +01:00
Steve Scalpone fdb58597e8 [flang] Update C++style.md
Original-commit: flang-compiler/f18@d453fdda31
Reviewed-on: https://github.com/flang-compiler/f18/pull/751
2019-09-17 17:07:06 -07:00
Steve Scalpone 3a25e25bd7 [flang] Update C++style.md
Add guidelines for error messages and commas.  Add a version number for clang-format. Add spaces before ### sections to restart numbering.

Original-commit: flang-compiler/f18@3e8db49f34
Reviewed-on: https://github.com/flang-compiler/f18/pull/751
Tree-same-pre-rewrite: false
2019-09-17 12:31:37 -07:00
Tim Keith 3ef61ec226 [flang] Fix tests that use the same .mod file
The tests run by `test_any.sh` don't redirect their .mod files to
a different directory so they occasionally fail when the same file
is accessed by different tests at the same time. With locking of
module files implemented, this problem reproduces much more reliably

Work around it by changing the module names to be distinct. Also remove
some comments left over when copied from `test_symbols.sh` tests.

Original-commit: flang-compiler/f18@f7b5c5f0fc
Reviewed-on: https://github.com/flang-compiler/f18/pull/758
2019-09-25 14:55:40 -07:00
Tim Keith 73c630a4ea [flang] Improve module file reading and writing
Fix problems with writing a mod file while another compilation is
reading or writing. Write to a temp and then rename it:
- compute the new contents of the .mod file
- if it already exists, check if it is already correct
- if not, write new contents to a temp file
- rename the temp to the final destination

`mkstemps()` seems to be the best way to create the temp file.
It returns a file descriptor, so change the rest of the mod file
writing to use POSIX open/read/write/close. This seems to set
errno more reliably too.

There is some extra work around creating the temp to make it have
the same directory and suffix as the final file (so that if one gets
left behind by a crash, "rm *.mod" still cleans it up).
`mkstemps()` creates file with 0600 permissions so try to change it
to what it would have been if we just wrote the file.

Change module file reading to only read the file once; we used to
read it to verify the checksum and then again to parse it.
Instead, change `Parsing` so that we can get the file contents
after `Prescan()` and use that to verify the checksum. Also, it has
a mechanism for searching directories for files, so make use of that
instead of duplicating that functionality in `ModFileReader`.
This requires some changes to how errors are returned so they can
be reported in the right place.

Original-commit: flang-compiler/f18@d0d54971a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/758
Tree-same-pre-rewrite: false
2019-09-25 14:55:40 -07:00
peter klausler 55e241a722 [flang] Fix build on OSX
Original-commit: flang-compiler/f18@453b03af1c
Reviewed-on: https://github.com/flang-compiler/f18/pull/760
2019-09-25 10:40:01 -07:00
peter klausler ccb91afba7 [flang] Address review comments
Original-commit: flang-compiler/f18@2393157d3f
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
2019-09-25 09:04:38 -07:00
peter klausler 9fd72e9393 [flang] Clean up test results
Original-commit: flang-compiler/f18@7d3180160c
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:37 -07:00
peter klausler d8c9b50fd6 [flang] Prep for review
Original-commit: flang-compiler/f18@8be02a41c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:35 -07:00
peter klausler 686baf0b0e [flang] Remove dead code
Original-commit: flang-compiler/f18@4d90aad361
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:33 -07:00
peter klausler 32f2ea0753 [flang] Build with all compilers * versions
Original-commit: flang-compiler/f18@7332caa613
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:31 -07:00
peter klausler fc5d127c1c [flang] Complete conversions, delete old visitor
Original-commit: flang-compiler/f18@6ce1da55c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:30 -07:00
peter klausler f07d6bc6ba [flang] more conversions to Traverse
Original-commit: flang-compiler/f18@e8668e2368
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:29 -07:00
peter klausler 48fd773a19 [flang] Refinements; replace several clients of old Visitor with new Traverse
Original-commit: flang-compiler/f18@0b44a86e31
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:28 -07:00
peter klausler e6e66c022b [flang] Redo IsInitialDataTarget
Original-commit: flang-compiler/f18@988c38e1f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:27 -07:00
peter klausler 0bc6d134a6 [flang] Repackaging; tests pass
Original-commit: flang-compiler/f18@1fa7bb7717
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:26 -07:00
peter klausler c36f7d916a [flang] progress
Original-commit: flang-compiler/f18@b5e3e709cb
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:24 -07:00
peter klausler 8d8e1c4604 [flang] add test
Original-commit: flang-compiler/f18@ad2fa9dfdf
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:23 -07:00
peter klausler 9016b1d6a8 [flang] checkpoint
Original-commit: flang-compiler/f18@96ade8e6e9
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:22 -07:00
peter klausler e9dda4f0f5 [flang] checkpoint
Original-commit: flang-compiler/f18@782f44fe7d
Reviewed-on: https://github.com/flang-compiler/f18/pull/755
Tree-same-pre-rewrite: false
2019-09-25 09:04:20 -07:00
Pete Steinfeld ea1cf9ee0b [flang] More responses to pull request comments.
Original-commit: flang-compiler/f18@0fb4cf1c9b
Reviewed-on: https://github.com/flang-compiler/f18/pull/756
2019-09-24 15:33:51 -07:00