Commit graph

1458 commits

Author SHA1 Message Date
peter klausler d49aa3c57c [flang] Final fixes before review
Original-commit: flang-compiler/f18@efe5c1b8ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-29 16:00:31 -07:00
peter klausler f4b1209f4b [flang] PRECISION, RANGE, RADIX
Original-commit: flang-compiler/f18@de0bf5a18f
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-29 15:38:33 -07:00
peter klausler eff41b8fa7 [flang] Complete folding of intermixed array and component references
Original-commit: flang-compiler/f18@70db03e4ac
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-29 13:22:35 -07:00
peter klausler 4cd29d1002 [flang] Fix intrinsic folding after merging changes
Original-commit: flang-compiler/f18@a982c34b6f
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-28 15:42:28 -07:00
peter klausler d29530e1c4 [flang] Defer conversions to objects; fix some intrinsic table entries
more fixes

Access components of constant structures

Apply implicit typing to dummy args used in automatic array dimensions

SELECTED_INT_KIND and SELECTED_REAL_KIND

Finish SELECTED_{INT,REAL}_KIND and common cases of ALL()/ANY()

Original-commit: flang-compiler/f18@e9f8e53e55
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-28 13:29:29 -07:00
Jean Perier 0dfecfa8c5 [flang] Add semantic error test for integer constant containing division by zero
Original-commit: flang-compiler/f18@650cfac539
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
2019-05-24 08:22:11 -07:00
Jean Perier 33d6fb2332 [flang] Make integer divide by zero in constants a fatal error
Original-commit: flang-compiler/f18@e5acff6b63
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
2019-05-24 07:55:57 -07:00
Jean Perier 3e0e884338 [flang] removed a relicate comment
Original-commit: flang-compiler/f18@f25113b84e
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
2019-05-24 07:55:50 -07:00
Jean Perier 49c8d329b7 [flang] Fix support of parenthesized arguments in function folding
Original-commit: flang-compiler/f18@1ecb07cddf
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
2019-05-24 07:55:44 -07:00
Jean Perier fcf951b4d4 [flang] more folding edge cases tests
Original-commit: flang-compiler/f18@21c0ec4cc4
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
2019-05-24 07:55:42 -07:00
Jean Perier ccd47f072c [flang] Adding tests for folding edge case (overflows...)
Original-commit: flang-compiler/f18@6893775dee
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
2019-05-24 07:55:41 -07:00
Jean Perier f62528535e [flang] Folding improvments:
- Add location to non-fatal error message (context was not given
    a location before folding in semantics).
  - Avoid refolding expression from scratch several times (update GenericExprWrapper
    after folding). So far, warning messages were generated twice per parametere init
    expressions.

Original-commit: flang-compiler/f18@bf7f6cf9cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
2019-05-24 07:55:40 -07:00
Jinxin Yang 67ebc0064a [flang] improvement for atomic construct
Original-commit: flang-compiler/f18@d57ef4a669
Reviewed-on: https://github.com/flang-compiler/f18/pull/470
2019-05-24 13:54:58 -07:00
Jinxin Yang 083bc9c6a1 [flang] improvement for 'Re-write OpenMP 4.5 grammar doc with BNF'
Original-commit: flang-compiler/f18@e17e74104b
Reviewed-on: https://github.com/flang-compiler/f18/pull/470
Tree-same-pre-rewrite: false
2019-05-24 13:45:15 -07:00
Jinxin Yang 80c9995a19 [flang] Re-write OpenMP 4.5 grammar doc with BNF
Original-commit: flang-compiler/f18@fe06ea9f60
Reviewed-on: https://github.com/flang-compiler/f18/pull/470
Tree-same-pre-rewrite: false
2019-05-23 17:13:52 -07:00
Jean Perier 6bcb3cac84 [flang] add test for parameter infinite loop
Original-commit: flang-compiler/f18@552568c397
Reviewed-on: https://github.com/flang-compiler/f18/pull/469
2019-05-23 02:13:01 -07:00
Jean Perier e5f396511d [flang] fix error message typo
Original-commit: flang-compiler/f18@049163e0d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/469
Tree-same-pre-rewrite: false
2019-05-23 02:09:58 -07:00
Jean Perier 15630a4ddd [flang] Prevent possible infinte loop in parameter folding
Original-commit: flang-compiler/f18@38360930ce
Reviewed-on: https://github.com/flang-compiler/f18/pull/469
Tree-same-pre-rewrite: false
2019-05-22 08:26:50 -07:00
Peter Klausler 849597f4f9 [flang] Update FortranForCProgrammers.md
Refine the text describing differences between C and Fortran pointers to correct an erroneous statement (that pointers cannot point to allocatables).  Fixes bug flang-compiler/f18#461.

Original-commit: flang-compiler/f18@eaa3c10aa8
Reviewed-on: https://github.com/flang-compiler/f18/pull/464
2019-05-15 13:37:10 -07:00
Jean Perier d146db54ca [flang] Fix: catch subroutine symbols in ALLOCATE
Original-commit: flang-compiler/f18@99d4b3dcd6
Reviewed-on: https://github.com/flang-compiler/f18/pull/467
2019-05-22 08:00:19 -07:00
peter klausler 7026445c07 [flang] Address review comments from Jean (thanks!)
Original-commit: flang-compiler/f18@5183c6196e
Reviewed-on: https://github.com/flang-compiler/f18/pull/466
2019-05-21 10:24:30 -07:00
peter klausler 59342b0641 [flang] work in progress
checkpoint: changes build, tests all pass

many fixes, ready to test more

Further CLASS(*) support

More fixes for CLASS(*)

Hide data members of DynamicType

implement PRESENT() intrinsic

Original-commit: flang-compiler/f18@044ba12c20
Reviewed-on: https://github.com/flang-compiler/f18/pull/466
Tree-same-pre-rewrite: false
2019-05-20 13:37:28 -07:00
peter klausler d0fcb7681a [flang] Fix crash reported by Tim
Original-commit: flang-compiler/f18@7fe2d197ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/465
2019-05-15 13:23:31 -07:00
peter klausler 9a13ea959c [flang] Fix bug with comment clipping on compiler directives
Original-commit: flang-compiler/f18@3f4375c57c
Reviewed-on: https://github.com/flang-compiler/f18/pull/463
2019-05-15 12:35:36 -07:00
peter klausler 01a3e1b80e [flang] Strip comments from source and directive lines after macro replacement
Original-commit: flang-compiler/f18@ecf22e6698
Reviewed-on: https://github.com/flang-compiler/f18/pull/460
2019-05-10 16:04:10 -07:00
Tim Keith cae5ce3d27 [flang] Update extensions doc for DO loop over REAL
Original-commit: flang-compiler/f18@bc8ea466fc
Reviewed-on: https://github.com/flang-compiler/f18/pull/455
2019-05-09 10:04:46 -07:00
Tim Keith 4c4f4d2807 [flang] Address review comments
Use better names for template parameters of `LoopBounds`, and also
for the constructor arguments.

Use two overloadings of `loopBounds()` instead of `std::is_same_v<>`.

Original-commit: flang-compiler/f18@a2c0c75462
Reviewed-on: https://github.com/flang-compiler/f18/pull/455
Tree-same-pre-rewrite: false
2019-05-09 10:00:13 -07:00
Tim Keith 351dc98948 [flang] Change parse tree to allow DO loop over REAL
It is a common extension to allow DO loops with REAL variable and
bounds. The parse tree currently parses those with the variable
as `scalar-int-variable-name` and the bounds as `scalar-int-expr`.
That causes the INTEGER constraint to be enforced automatically.

Change the grammar and parse tree to treat them as `scalar-variable-name`
and `scalar-expr`. This allows the name and expression to be REAL,
but we will have to verify that they aren't any other type (in a future
change).

To accomplish this, add a template parameter to `LoopBounds` for the type
of the variable name (always `Scalar<Name>` or `Scalar<Integer<Name>>`).
We sometimes need names for the instantiations of `LoopBounds` so add
type aliases like `LoopControl::Bounds` for each one.

Original-commit: flang-compiler/f18@d75aa03970
Reviewed-on: https://github.com/flang-compiler/f18/pull/455
Tree-same-pre-rewrite: false
2019-05-09 08:33:28 -07:00
Peter Steinfeld 3cf2173010 [flang] Added a TODO to include the name of the IMPURE procedure in the error
message for referencing in IMPURE procedure in the scalar-mask-expr of
a DO CONCURRENT.

Also removed a bogus comment from the test.

Both of these changes were in response to review comments.

Original-commit: flang-compiler/f18@4447d59b39
Reviewed-on: https://github.com/flang-compiler/f18/pull/452
2019-05-09 10:58:55 -07:00
Peter Steinfeld c2346d9ee2 [flang] Added a test for C1121 -- in a concurrent DO loop, the
scalar-mask-expr cannot reference an IMPURE procedure.

Original-commit: flang-compiler/f18@0684c6ccc2
Reviewed-on: https://github.com/flang-compiler/f18/pull/452
Tree-same-pre-rewrite: false
2019-05-09 10:58:54 -07:00
Jinxin Yang d25c942594 [flang] OpenMP 4.5 grammar related minor fixes
1. typo and trailing spaces within OpenMP-4.5-grammar.txt

2. parse (openmp-grammar.h) and unparse(unparse.cc) for:

   SCHEDULE ([modifier [, modifier]:]kind[, chunk_size])
   Modifier ->  MONITONIC | NONMONOTONIC | SIMD

where ":" is optional except at least one modifier is present.

Original-commit: flang-compiler/f18@5cebae5039
Reviewed-on: https://github.com/flang-compiler/f18/pull/453
2019-05-08 14:12:28 -07:00
peter klausler 802895b7c6 [flang] Allow use of (x?"a":"b") as a message argument
Original-commit: flang-compiler/f18@c0d4e55455
Reviewed-on: https://github.com/flang-compiler/f18/pull/451
2019-05-08 11:11:11 -07:00
peter klausler 40282fabd2 [flang] Add & use mutators for Substring, Triplet, CoarrayRef
Original-commit: flang-compiler/f18@cc2de361fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
2019-05-08 10:29:04 -07:00
peter klausler b00798b64f [flang] Fix warning
Original-commit: flang-compiler/f18@4fcf88901c
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:29:02 -07:00
peter klausler d92abfa65e [flang] Address review comment
Original-commit: flang-compiler/f18@5d20cd48b6
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:29:02 -07:00
peter klausler 91de1f62fb [flang] dodge clang build problem with constexpr
Original-commit: flang-compiler/f18@83995a5a98
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:29:01 -07:00
peter klausler 04d85f1754 [flang] Remove debugging
Original-commit: flang-compiler/f18@1db626f838
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:28:58 -07:00
peter klausler bb83471e96 [flang] Fix folding of substring
Original-commit: flang-compiler/f18@62dc5e0c93
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:28:57 -07:00
peter klausler 52d46695fc [flang] Handle remaining cases in expression traversal
Original-commit: flang-compiler/f18@5cb0de58d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/449
Tree-same-pre-rewrite: false
2019-05-08 10:28:56 -07:00
Jinxin Yang 80ccd20f3b [flang] Add -mp option for pgf90 in the presence of -fopenmp
Original-commit: flang-compiler/f18@a9d7287420
Reviewed-on: https://github.com/flang-compiler/f18/pull/450
2019-05-08 08:43:20 -07:00
peter klausler 4ffb37e593 [flang] Remove support for Names in messages for now.
Original-commit: flang-compiler/f18@15d38c7059
Reviewed-on: https://github.com/flang-compiler/f18/pull/444
2019-05-07 10:04:21 -07:00
peter klausler f704d38129 [flang] Merge with recent changes
Original-commit: flang-compiler/f18@56a72cbbd6
Reviewed-on: https://github.com/flang-compiler/f18/pull/444
Tree-same-pre-rewrite: false
2019-05-07 09:24:35 -07:00
peter klausler ec6cf76536 [flang] Replace formatting of CharBlock & string
Preserve generated strings until consumed by formatting.

bugfix from premature push

Address review comments

Last fix(?)

Use %s formatting for CharBlocks and strings

Use new formatting and fix usage of std::forward<>()

Use forward_list rather than vector to save strings

Original-commit: flang-compiler/f18@8ea478420f
Reviewed-on: https://github.com/flang-compiler/f18/pull/444
Tree-same-pre-rewrite: false
2019-05-07 09:24:32 -07:00
Jean Perier a11ab23ccb [flang] Change a user error to an internal error in ALLOCATE semantic check
Original-commit: flang-compiler/f18@d9a9b59634
2019-05-07 08:28:24 -07:00
Tim Keith de36472ef7 [flang] Re-enable test resolve51.f90
Original-commit: flang-compiler/f18@595e45fd34
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
2019-05-07 07:35:10 -07:00
Tim Keith 409212cf43 [flang] Move ProgramTree to its own file
Original-commit: flang-compiler/f18@06913c38ca
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
Tree-same-pre-rewrite: false
2019-05-06 10:12:27 -07:00
Tim Keith 14094c71c8 [flang] Process specification parts before execution parts
Change the order in which names are resolved. Before resolving names
in the execution part of a subprogram we need to know the interface
of contained subprograms. This is because the type of some construct
entities can depend on the return type of contained functions, e.g.
```
  associate(x => f())
  end associate
contains
  function f()...
```

To do this, we now build a tree rooted at each program unit with
child nodes corresponding to subprograms contained in the parent.
This provides flexibility in choosing an order to resolve names.
The current implementation processes all specification parts before
any execution parts. This ensures contained subprogram interfaces
are know before analyzing constructs like ASSOCIATE.

Resolving a specification part involves first adding
`SubprogramNameDetails` symbols for each contained subprogram, then
processing the statement that introduces the program unit (`ModuleStmt`,
`SubroutineStmt`, etc.), then visiting all of the statements in the
specification part.

If it proves necessary, we can add a phase to do implicit declarations
in the execution part before processing the specification part of
contained subprograms.

Original-commit: flang-compiler/f18@20e803fd92
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
Tree-same-pre-rewrite: false
2019-05-06 07:26:43 -07:00
Tim Keith 12f1660117 [flang] Add DIE macro
`DIE()` is like `common::die()` but with the source location appended,
as in `CHECK()`.

Original-commit: flang-compiler/f18@ed586c3f38
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
Tree-same-pre-rewrite: false
2019-05-03 08:02:31 -07:00
Tim Keith 28f80675e9 [flang] Change how Scopes are mapped to ImplicitRules
Previously we maintained a stack of ImplicitRules in parallel with
the Scope stack. Change to maintaining a mapping from Scope to
ImplicitRules.

This makes things simpler in some cases: Block scopes don't have their
own implicit rules. And submodule scopes aren't just pushed and popped.
This will also help with future changes to the order in which scopes
are processed.

Original-commit: flang-compiler/f18@443da50352
Reviewed-on: https://github.com/flang-compiler/f18/pull/443
Tree-same-pre-rewrite: false
2019-05-02 11:19:01 -07:00
peter klausler eebc7ba001 [flang] Fix or disable broken tests.
Original-commit: flang-compiler/f18@a54396e92e
Reviewed-on: https://github.com/flang-compiler/f18/pull/445
2019-05-06 11:33:33 -07:00