Commit graph

2118 commits

Author SHA1 Message Date
Tim Keith b506f39f18 [flang] Clean up temp dirs
A temp directory is created in `common.sh` and it is cleaned up by
`trap ... EXIT`. If the test script has its own trap, as this one does,
it seems to replace the first one. So the cleanup from `common.sh` was
not being executed when the `%t` feature was used and empty temp
directories were being left in the directory where the tests ran.

Since we already have a temp directory that is cleaned up, just use
that for `%t` and don't bother with another `mktemp`.

Original-commit: flang-compiler/f18@f61d62ddec
Reviewed-on: https://github.com/flang-compiler/f18/pull/754
2019-09-18 13:17:48 -07:00
Jinxin Yang bb1127efb6 [flang] [OpenMP] Simplify OmpObject with std::variant
Instead of using an `ENUM_CLASS Kind` to distinguish a `Designator`
or common-block name, change it to `std::variant`. If the `Name`
is available, then it is common-block name.

Original-commit: flang-compiler/f18@abf5db6171
2019-09-18 15:46:20 -07:00
Jean Perier ba89315523 [flang] Address comment: make error a warning instead and ignore RESULT
Instead of emitting an error when RESULT has the same name as the
function, emit a warning and ignore RESULT in the rest of the
compilation.

Original-commit: flang-compiler/f18@8ce3862d39
Reviewed-on: https://github.com/flang-compiler/f18/pull/743
2019-09-16 03:36:12 -07:00
Jean Perier ca86308453 [flang] Prevent RESULT name from being the same as the function.
Fix flang-compiler/f18#726.
Add test and error messsage for such scenario and set error on the
result symbol because it is unclear what it is inside the function.

Original-commit: flang-compiler/f18@a3d5b5af0d
Reviewed-on: https://github.com/flang-compiler/f18/pull/743
Tree-same-pre-rewrite: false
2019-09-13 09:44:05 -07:00
Tim Keith a29678ddb6 [flang] Fix bugs with use-associated derived type with rename
When a derived type is use-associated with a rename, like
`use m, only: t2 => t1`
we need to record in the `DerivedTypeSpec` both the local-name in this
scope and the symbol for the derived type.

In most cases we need to work the the type symbol and its
`DerivedTypeDetails`, but when writing the type to the module file
we need the local-name. The name of the type symbol may be hidden
or not use-associated.

When analyzing a `parser::Name` we don't want to follow use-associations
because we could end up with the wrong name in a `DataRef` (i.e. the
use-name rather than the local-name). But that means that
`GetNamedConstantValue()` does have to follow them or named constants
won't always be folded.

Fixes flang-compiler/f18#729.

Original-commit: flang-compiler/f18@50d8921c69
Reviewed-on: https://github.com/flang-compiler/f18/pull/740
2019-09-16 07:54:27 -07:00
Tim Keith 0b86ab186d [flang] Fix renames in module files
When a module contains a use-association with rename, we have to be
careful to use the correct name (i.e. the local-name, not the use-name)
when writing out its `.mod` file.

When analyzing a `Name` in an expression, follow the use-association
for details, attributes, and constant values; but if we need to make a
`Designator` or `ProcedureDesignator`, use the local name.

Original-commit: flang-compiler/f18@8f07b803e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/740
Tree-same-pre-rewrite: false
2019-09-16 07:54:27 -07:00
Tim Keith ce8b500d57 [flang] Refactoring
Eliminate two of the three overloadings of `Scope::MakeDerivedType()`.
Keep the one that has `Category` first because that's the order the
constructor of `DeclTypeSpec` uses.

In `mod-file.cc`, eliminate some calls to `PutLower()`. Symbols and
names are already lower case so they don't need to be converted.

In `modfile03.f90`, move the expected `.mod` file comments to right
after the corresponding modules. That makes it easier to work with.

Original-commit: flang-compiler/f18@86874d9bf8
Reviewed-on: https://github.com/flang-compiler/f18/pull/740
Tree-same-pre-rewrite: false
2019-09-16 07:54:27 -07:00
Tim Keith 4fde74a1c8 [flang] Address review comment
Original-commit: flang-compiler/f18@134190f75e
Reviewed-on: https://github.com/flang-compiler/f18/pull/741
2019-09-13 14:39:40 -07:00
Tim Keith f13cf9f0ed [flang] Better handling of merged generics
If a generic name is use-associated from two different modules and they
both have a specific procedure or both have a derived type with the same
name, report it as an error.

Original-commit: flang-compiler/f18@42369af96d
Reviewed-on: https://github.com/flang-compiler/f18/pull/741
Tree-same-pre-rewrite: false
2019-09-13 14:27:33 -07:00
Tim Keith d43405e4e6 [flang] Fix bug merging generics on USE
When we use-associate the same generic name from two different modules
they are merged together. If the same specific procedure occurs in both
generics it should only occur once in the merged one.

Similarly, it's not an error if they both have a derived type or
specific procedure named the same as the generic, as long as they are
the same symbol.

Fixes flang-compiler/f18#733.

Original-commit: flang-compiler/f18@d37db07691
Reviewed-on: https://github.com/flang-compiler/f18/pull/741
Tree-same-pre-rewrite: false
2019-09-12 17:38:40 -07:00
David Truby da26e76078 [flang] Changed missing tofrom:scalar error message to be more descriptive
Original-commit: flang-compiler/f18@18e0a55a02
Reviewed-on: https://github.com/flang-compiler/f18/pull/719
2019-09-11 11:23:36 +01:00
David Truby 9527a18816 [flang] Added tofrom:scalar check for defaultmap clause
Original-commit: flang-compiler/f18@1025649b64
Reviewed-on: https://github.com/flang-compiler/f18/pull/719
Tree-same-pre-rewrite: false
2019-09-10 14:04:03 +01:00
David Truby 4b30ecf11c [flang] Semantic checks for target construct
Original-commit: flang-compiler/f18@373391bc03
Reviewed-on: https://github.com/flang-compiler/f18/pull/719
Tree-same-pre-rewrite: false
2019-09-10 13:49:24 +01:00
peter klausler 1c10d963aa [flang] Remove periods from the ends of messages, per review comment
Original-commit: flang-compiler/f18@0ce32de0d6
Reviewed-on: https://github.com/flang-compiler/f18/pull/745
2019-09-13 13:57:35 -07:00
peter klausler 9c3a9375be [flang] Implement checks for test/semantics/call02.f90
Original-commit: flang-compiler/f18@38eaaa72ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/745
Tree-same-pre-rewrite: false
2019-09-13 12:32:43 -07:00
Jinxin Yang 5676797c2a [flang] Improve flag dumping for -funparse-with-symbols
Original-commit: flang-compiler/f18@768fb1b369
2019-09-13 12:39:27 -07:00
peter klausler f2917c777b [flang] Do not emit a bogus exponent (0.e-1)
Original-commit: flang-compiler/f18@3d0b13d7ed
Reviewed-on: https://github.com/flang-compiler/f18/pull/736
2019-09-12 10:28:16 -07:00
peter klausler 8fc7824feb [flang] tweak test results
Original-commit: flang-compiler/f18@360c6717e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/738
2019-09-12 09:40:29 -07:00
peter klausler 988749e8f3 [flang] Fix bug flang-compiler/f18#735
Original-commit: flang-compiler/f18@dccb16d492
Reviewed-on: https://github.com/flang-compiler/f18/pull/738
Tree-same-pre-rewrite: false
2019-09-12 09:40:28 -07:00
peter klausler c93ceeeef7 [flang] Improve error message (add types)
Original-commit: flang-compiler/f18@48b8f32d51
Reviewed-on: https://github.com/flang-compiler/f18/pull/738
Tree-same-pre-rewrite: false
2019-09-12 09:40:27 -07:00
Jean Perier 48659b1eb0 [flang] Add NEW_LINE intrinsic to the intrinsic table
NEW_LINE intrinsic folding was already implemented but it had not
yet been added the the intrinsic table and was therefore not yet
recognised an intrinsic.
Add related tests.

Original-commit: flang-compiler/f18@42fcf5b5f1
Reviewed-on: https://github.com/flang-compiler/f18/pull/734
2019-09-11 03:01:55 -07:00
peter klausler bd2bf58e7a [flang] Extend comments
Original-commit: flang-compiler/f18@9f918c2559
Reviewed-on: https://github.com/flang-compiler/f18/pull/737
2019-09-11 13:15:32 -07:00
peter klausler 62e4acf232 [flang] Allow module, submodule, and program names to be used as local identifiers. Check for USE of m in m.
Original-commit: flang-compiler/f18@9abfd9e450
Reviewed-on: https://github.com/flang-compiler/f18/pull/737
Tree-same-pre-rewrite: false
2019-09-11 12:30:24 -07:00
Tin Huynh 2e1807998c [flang] Using new Prov to Cooked mappings for get-definition.
Original-commit: flang-compiler/f18@5a42c5c9e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/698
2019-09-10 17:55:59 -07:00
Tin Huynh 69fd49a002 [flang] FindOffsetLineAndColumn also uses SourcePosition.
New tests for COMMON and BLOCK.
Added CHECK-ONCE to test_any.sh. Make sure pattern only occurs once.

Original-commit: flang-compiler/f18@ad82dafcf9
Reviewed-on: https://github.com/flang-compiler/f18/pull/698
Tree-same-pre-rewrite: false
2019-09-10 17:55:59 -07:00
Tin Huynh 2f205a5f52 [flang] Added -fget-definitions and -fget-all-symbols.
- -fget-definitions finds the definition of the symbol under specified source
position.
- -fget-all-symbols finds definition locations of all symbols in a document. For
symbols found in other modules, shows which module the symbol came from.
- Tests.
- New structure SourcePosition with file, line, column information.

Original-commit: flang-compiler/f18@e0099b0900
Reviewed-on: https://github.com/flang-compiler/f18/pull/698
Tree-same-pre-rewrite: false
2019-09-10 17:55:59 -07:00
peter klausler f9ed573b1d [flang] Recover better from syntax errors on USE statements
Original-commit: flang-compiler/f18@29968698d9
Reviewed-on: https://github.com/flang-compiler/f18/pull/731
2019-09-10 15:29:55 -07:00
peter klausler 67eb35d970 [flang] Address review comment
Original-commit: flang-compiler/f18@65dc8d4996
Reviewed-on: https://github.com/flang-compiler/f18/pull/732
2019-09-10 17:08:18 -07:00
peter klausler 9db810f5e3 [flang] Add static declaration checker; get call01.f90 to pass
Original-commit: flang-compiler/f18@7cc5bc7617
Reviewed-on: https://github.com/flang-compiler/f18/pull/732
Tree-same-pre-rewrite: false
2019-09-10 15:53:23 -07:00
peter klausler 2ae26b8501 [flang] Check recursive calls for NON_RECURSIVE and assumed-length CHARACTER(*)
Original-commit: flang-compiler/f18@92777f8f66
Reviewed-on: https://github.com/flang-compiler/f18/pull/732
Tree-same-pre-rewrite: false
2019-09-10 15:53:22 -07:00
peter klausler 34f07e50c0 [flang] commit to switch branches
Some groundwork

Original-commit: flang-compiler/f18@64ebeb511c
Reviewed-on: https://github.com/flang-compiler/f18/pull/732
Tree-same-pre-rewrite: false
2019-09-10 15:53:17 -07:00
Pete Steinfeld 97d7b398e4 [flang] Combined the implementations to ``Pre()` and `Post()`` functions that
call `PushConstruct()``` and ```PopConstruct()``` following a genius
suggestion from Peter.

Original-commit: flang-compiler/f18@be2a03ebf4
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
2019-09-10 14:45:02 -07:00
Pete Steinfeld 74112759c3 [flang] Changed ``PushConstruct()`` to be a template, which moves the implicit
creation of the ```ConstructNode``` into ```PushConstruct()```.

Original-commit: flang-compiler/f18@3984566858
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
Tree-same-pre-rewrite: false
2019-09-10 14:45:02 -07:00
Pete Steinfeld 9cc2f8300b [flang] Responses to review comments
I changed the interface of ```PushConstruct()``` to take an rvalue reference as its only parameter and made the construction of the ```ConstructNode```s explicit in all of the ```Pre()``` functions for the various construct types.

Original-commit: flang-compiler/f18@f8be813874
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
Tree-same-pre-rewrite: false
2019-09-10 14:45:02 -07:00
Pete Steinfeld eedbe90e72 [flang] Responses to review comments and team meeting
The most significant change is that I replaced the stack of
ExecutableConstruct's with a stack composed of ConstructNode's, each of which
is a variant of the constructs that made up the type ExecutableConstruct.  This
change allows the nodes of the stack to be extended to include the types needed
for OMP semantic checking.

I also extended the existing test to include some correct DO loops with CYCLE
and EXIT statements to test the code more completely.

Original-commit: flang-compiler/f18@d26f34e3a4
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
Tree-same-pre-rewrite: false
2019-09-10 14:45:02 -07:00
Pete Steinfeld 73ef31b164 [flang] Changes to add an executable construct stack
I added a stack of ExecutableConstruct's to SemanticsContext along with
functions to push and pop constructs.  I added code to the SemanticsVisitor
to use these new functions.  I also added functions Pre and Post functions
for UnlabeledStatement's so that we could isolate the source positions for
statements embedded in "if" statements to improve error messages.

I also added code to check-do.[h,cc] to use this new infrastructure to check
for CYCLE and EXIT statements that are not contained within DO constructs
along with a test.

Original-commit: flang-compiler/f18@b8370bdeb8
Reviewed-on: https://github.com/flang-compiler/f18/pull/686
Tree-same-pre-rewrite: false
2019-09-10 14:45:02 -07:00
Pete Steinfeld f8cfc7cdf9 [flang] Fixed the declarations of IEEE_SUPPORT_FLAG and IEEE_SUPPORT_HALTING to
be functions rather than subroutines.  Note that Table 17.3 in the
standard summarizes the contents of IEEE_EXCEPTIONS with the details
specified in section 17.11.

Original-commit: flang-compiler/f18@fca58d479d
Reviewed-on: https://github.com/flang-compiler/f18/pull/730
2019-09-10 12:43:16 -07:00
Steve Scalpone 654a86a277 [flang] Update comment to reflect that STORAGE_SIZE is implemented.
Original-commit: flang-compiler/f18@3c2431bbf8
Reviewed-on: https://github.com/flang-compiler/f18/pull/723
2019-09-10 08:37:08 -07:00
Steve Scalpone c1c83477ed [flang] Add storage_size intrinsic.
Original-commit: flang-compiler/f18@bcde26a7c1
Reviewed-on: https://github.com/flang-compiler/f18/pull/723
Tree-same-pre-rewrite: false
2019-09-09 14:33:04 -07:00
Jean Perier 45820f4caa [flang] address comment: add ',' for better formatting
Original-commit: flang-compiler/f18@0c85499985
Reviewed-on: https://github.com/flang-compiler/f18/pull/699
2019-09-10 04:11:19 -07:00
Jean Perier 1343cf78f3 [flang] Implement folding of x**y where y is real or complex
This was a TODO. The implementation uses the host runtime
function pow, either from libm or libpgmath.

Original-commit: flang-compiler/f18@ee58112112
Reviewed-on: https://github.com/flang-compiler/f18/pull/699
Tree-same-pre-rewrite: false
2019-08-30 08:08:08 -07:00
Steve Scalpone 02a9cdb3fd [flang] Define iso_fortran_env error_unit.
Provisionally use a value of 0 to match PGI.

Original-commit: flang-compiler/f18@ec7f0a0968
Reviewed-on: https://github.com/flang-compiler/f18/pull/722
2019-09-09 12:57:10 -07:00
peter klausler de974041da [flang] Fix expected error messages in tests to correspond with recent update to compiler
Original-commit: flang-compiler/f18@95202dd313
Reviewed-on: https://github.com/flang-compiler/f18/pull/721
2019-09-09 11:40:31 -07:00
peter klausler bf6ba0ff18 [flang] Fix some Fortran and use existing messages for errors already caught.
Original-commit: flang-compiler/f18@2d360e78ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
2019-09-09 10:43:19 -07:00
peter klausler 9dee00eccc [flang] Finish test/semantics/call12.f90
Original-commit: flang-compiler/f18@d002f0ce37
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:28 -07:00
peter klausler 99757783d2 [flang] Fix Fortran in call10.f90
Original-commit: flang-compiler/f18@8154a24232
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:28 -07:00
peter klausler 5ea5fe9b1e [flang] More tests
Original-commit: flang-compiler/f18@bd5e95e40c
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:28 -07:00
peter klausler c19c1e5abd [flang] More tests
Original-commit: flang-compiler/f18@52e3b74f4e
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:28 -07:00
peter klausler 7f52d94bf3 [flang] call09.f90 and review comment
Original-commit: flang-compiler/f18@bc2ac270c6
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:27 -07:00
peter klausler c3d35afd87 [flang] call08.f90
Original-commit: flang-compiler/f18@2bda489d45
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:27 -07:00
peter klausler c74f40f46e [flang] call07.f90
Original-commit: flang-compiler/f18@a92307c3d6
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:27 -07:00
peter klausler 7ffe10c1fb [flang] call06.f90
Original-commit: flang-compiler/f18@81b64dacaa
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:26 -07:00
peter klausler 0e1259db7a [flang] Add call04.f90 test
Original-commit: flang-compiler/f18@0b329380cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:26 -07:00
peter klausler 8068d016db [flang] First three tests
Original-commit: flang-compiler/f18@600b5263b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
2019-09-09 10:16:26 -07:00
peter klausler 0208a7d400 [flang] Remove needless include
Original-commit: flang-compiler/f18@5d2afd0ad3
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
2019-09-09 10:26:30 -07:00
peter klausler be799e4300 [flang] Check for having compiled the inverted map before using it
Original-commit: flang-compiler/f18@cef90ee11e
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
Tree-same-pre-rewrite: false
2019-09-09 09:26:37 -07:00
peter klausler 73329265ff [flang] Implement provenance -> CharBlock map
Original-commit: flang-compiler/f18@f2e7b6cd72
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
Tree-same-pre-rewrite: false
2019-09-09 09:26:36 -07:00
peter klausler fa3410d5fb [flang] Clean out some dead code, improve naming & comments
Original-commit: flang-compiler/f18@3495555565
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
Tree-same-pre-rewrite: false
2019-09-09 09:26:36 -07:00
Jinxin Yang db25a52fe7 [flang] [OpenMP] formalize DEFAULTMAP clause
OpenMP 4.5 only accepts `defaultmap(tofrom:scalar)`. The original implementation
only parses the entire `tofrom:scalar` string and does nothing else. This commit
makes it treat `tofrom` (`ImplicitBehavior`) and `scalar` (`VariableCategory`)
separately, which is clear and extendable for OpenMP 5.0 Spec.

Original-commit: flang-compiler/f18@12074dcd2c
2019-09-09 09:41:04 -07:00
peter klausler e665f1d7d1 [flang] More writing
Original-commit: flang-compiler/f18@8dce9cb7f0
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
2019-09-09 09:28:23 -07:00
peter klausler a56e5f0615 [flang] edits
Original-commit: flang-compiler/f18@ff3cab0bb5
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:28:23 -07:00
peter klausler dca31ebe93 [flang] More edits
Original-commit: flang-compiler/f18@6b9ce52250
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:28:22 -07:00
peter klausler e73a1d287a [flang] edits
Original-commit: flang-compiler/f18@07da944e4b
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:27:38 -07:00
peter klausler f0778f0fe2 [flang] edits
Original-commit: flang-compiler/f18@729cc19e0f
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:27:38 -07:00
peter klausler 28e8f7a9fd [flang] Jot down thoughts on array expr and intrinsic evaluation for Jean
Original-commit: flang-compiler/f18@83c72062d5
Reviewed-on: https://github.com/flang-compiler/f18/pull/534
Tree-same-pre-rewrite: false
2019-09-09 09:27:37 -07:00
peter klausler 7f9922203f [flang] Review comments
Original-commit: flang-compiler/f18@376359d456
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
2019-09-04 10:44:49 -07:00
peter klausler 9469ce8aeb [flang] refinements
Original-commit: flang-compiler/f18@a4de8161f9
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-29 12:45:42 -07:00
peter klausler 321fcad0a9 [flang] address review comments
Original-commit: flang-compiler/f18@793c15fd04
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-29 10:58:36 -07:00
peter klausler 76337eb4cb [flang] Simplify by using the term F77ish
Original-commit: flang-compiler/f18@063d9dc6c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-28 13:59:48 -07:00
peter klausler f4f44b90f0 [flang] Limitations on function results with assumed type parameters
Original-commit: flang-compiler/f18@4ba9fdb0ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-28 11:54:19 -07:00
peter klausler a26bbed6d6 [flang] Corrections and additions
Original-commit: flang-compiler/f18@000301fcf9
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-28 11:25:55 -07:00
peter klausler c71ba62c9f [flang] Correct obsolete comment in descriptor.h
Original-commit: flang-compiler/f18@8ff52c493a
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-28 09:14:46 -07:00
peter klausler c236c83775 [flang] Resolve some TODOs
Original-commit: flang-compiler/f18@3f3e9c9320
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-27 15:59:46 -07:00
peter klausler c6041dfecf [flang] Enumerate semantics checks
Original-commit: flang-compiler/f18@3ddf31109a
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-27 14:27:14 -07:00
peter klausler 6d7fef5cd0 [flang] More research
Original-commit: flang-compiler/f18@1e2b0be07f
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-27 13:09:31 -07:00
peter klausler fe7ea5325f [flang] Address some review comments
Original-commit: flang-compiler/f18@5666998b0f
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-27 10:15:31 -07:00
peter klausler a000beae71 [flang] fix typo, add examples
Original-commit: flang-compiler/f18@e0964fe076
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-26 15:56:08 -07:00
peter klausler e9c6ab3615 [flang] refine naming
Original-commit: flang-compiler/f18@a4888a08cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-26 15:44:38 -07:00
peter klausler 1e90c6b948 [flang] naming
Original-commit: flang-compiler/f18@c3673287f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-26 14:23:35 -07:00
peter klausler 0c3a942422 [flang] trampolines
Original-commit: flang-compiler/f18@3e9cebe8dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-26 12:41:10 -07:00
peter klausler 311300b15d [flang] more writing
Original-commit: flang-compiler/f18@16a8b0065a
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-23 15:35:18 -07:00
peter klausler d732d10b80 [flang] more writing
Original-commit: flang-compiler/f18@a067cca183
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-23 15:22:53 -07:00
peter klausler 700448d39c [flang] More writing
Original-commit: flang-compiler/f18@f475086c0c
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-23 14:35:38 -07:00
peter klausler 9dcbed4735 [flang] Extract Calls.md into its own branch.
Original-commit: flang-compiler/f18@8a5a2c99dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/683
Tree-same-pre-rewrite: false
2019-08-23 13:42:13 -07:00
Jinxin Yang d7443b5ad2 [flang] Add missing include for unordered_map
Original-commit: flang-compiler/f18@a9aadfb607
2019-09-05 14:34:44 -07:00
Jinxin Yang bc52fc1922 [flang] [OpenMP] extend IF clause to accept modifier on composite/combined constructs
Original-commit: flang-compiler/f18@03302a1546
2019-09-05 13:35:21 -07:00
Jinxin Yang 5c543da53a [flang] [OpenMP] add structural checks for TASKLOOP SIMD
Original-commit: flang-compiler/f18@21b4dde276
2019-09-05 13:35:21 -07:00
Jinxin Yang d1bbccf1d5 [flang] [OpenMP] update declare simd directive with exclusive set
Original-commit: flang-compiler/f18@dc1bd8edc6
2019-09-05 13:35:21 -07:00
Jinxin Yang e902c1d6b7 [flang] [OpenMP] enable check for IF clause modifier
Original-commit: flang-compiler/f18@f56fe4a389
2019-09-05 13:35:21 -07:00
Jinxin Yang c4fa8b867e [flang] [OpenMP] Add structural checks for TASK
1. fix `OmpIfClause` on `Task`
2. add structural checks

Original-commit: flang-compiler/f18@a77830a191
2019-09-05 13:35:21 -07:00
Jinxin Yang 77ed1df8a7 [flang] [OpenMP] fix type for Final clause
The type should be `ScalarLogicalExpr`.

Original-commit: flang-compiler/f18@97e4282d7c
2019-09-05 13:35:21 -07:00
Jinxin Yang 658cf65249 [flang] [OpenMP] Expand full sets for do, simd, and do simd
Original-commit: flang-compiler/f18@1f5bbeb3ea
2019-09-05 13:35:21 -07:00
David Truby f1212c6606 [flang] Implement semantic checking for TASKLOOP
Original-commit: flang-compiler/f18@a8e65f2c2d
Reviewed-on: https://github.com/flang-compiler/f18/pull/688
2019-09-03 17:17:22 +01:00
Tim Keith cc07c43a84 [flang] Name resolution for Cray pointers
Resolve the pointer and pointee names in a `BasedPointerStmt` and
enforce some of the constraints on them. There are still some
constraints to be implemented, mainly about what kind of attributes
the pointers and pointees can have.

The rules for these are a little vague. I mostly followed
- Cray Fortran Reference Manual section 9.3.2
- https://gcc.gnu.org/onlinedocs/gfortran/Cray-pointers.html
- VSI Fortran for OpenVMS Language Reference Manual section B.11

Note that the first two use the term "Cray pointer" but the last does
not. That is confusing because you have to know from context whether
it is referring to Cray pointers or Fortran pointers, so I used
"Cray pointer" and "Cray pointee" in error messages to refer to the
two names in the pointer statement.

Original-commit: flang-compiler/f18@cabb112be2
Reviewed-on: https://github.com/flang-compiler/f18/pull/697
2019-09-04 16:55:08 -07:00
Tim Keith 9f49ffb94f [flang] Fix declaration of module procedure subprograms
Names of subprograms declared with MODULE PROCEDURE in a submodule
were not found correctly. The fix is to separate the handling of
these from other subprograms. The subprogram being defined must have
been declared in the same module or an ancestor module/submodule.

Fixes flang-compiler/f18#709

Original-commit: flang-compiler/f18@80b635d343
Reviewed-on: https://github.com/flang-compiler/f18/pull/710
2019-09-04 15:15:57 -07:00
Steve Scalpone 689e6ee7b6 [flang] Fold more cases of cmplx and dcmplx.
Original-commit: flang-compiler/f18@57401319b0
Reviewed-on: https://github.com/flang-compiler/f18/pull/706
2019-09-02 15:02:46 -07:00
Steve Scalpone 93aa7a8640 [flang] Add support and documentation for DREAL.
Original-commit: flang-compiler/f18@5b6a2dc26c
Reviewed-on: https://github.com/flang-compiler/f18/pull/705
2019-09-02 13:54:01 -07:00
Steve Scalpone d33a5652a8 [flang] Update OpenMP-semantics.md
Formatting changes.

Original-commit: flang-compiler/f18@007b3e31d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/692
2019-08-30 11:22:13 -07:00
Steve Scalpone 67a5f04be8 [flang] Update OpenMP-semantics.md
Item 4 can be removed since we decided to keep the code in Semantics.

Original-commit: flang-compiler/f18@7377a61345
Reviewed-on: https://github.com/flang-compiler/f18/pull/692
Tree-same-pre-rewrite: false
2019-08-29 12:55:41 -07:00
Steve Scalpone 12c9b9429b [flang] Update OpenMP-semantics.md
Repond to review comments about grammar and formatting.

Original-commit: flang-compiler/f18@4811ea2b94
Reviewed-on: https://github.com/flang-compiler/f18/pull/692
Tree-same-pre-rewrite: false
2019-08-27 18:12:50 -07:00
Steve Scalpone 6e4c8b88c5 [flang] Create OpenMP-semantics.md
Initial markdown document.

Original-commit: flang-compiler/f18@787a0ca058
Reviewed-on: https://github.com/flang-compiler/f18/pull/692
Tree-same-pre-rewrite: false
2019-08-27 14:38:48 -07:00
Jinxin Yang 23a7f38741 [flang] [OpenMP] flang-compiler/f18#691 Update on Tim and Varun's review
Change CheckMatching to return `beginDir`, which hides the unnecessary
`std::get<>` for `endDir`.

Original-commit: flang-compiler/f18@d9689e10f4
2019-08-29 10:19:36 -07:00
Jinxin Yang f6273d7194 [flang] [OpenMP] structural checks for PARALLEL SECTIONS
Original-commit: flang-compiler/f18@c18452159d
2019-08-29 10:19:36 -07:00
Jinxin Yang ffb88549cb [flang] [OpenMP] add Begin and End Directive matching check
Straightforward check for Begin and End directive of:
1. Block related constructs
2. Loop related constructs (End directive is optional)
3. Sections related constructs

Original-commit: flang-compiler/f18@d0436f13ee
2019-08-29 10:19:36 -07:00
Jinxin Yang 0a85616b07 [flang] [OpenMP] update validity check for OmpNowait.
Because now we set the flag for `End` directives that accept clauses,
no need to check the specific directives anymore.

Original-commit: flang-compiler/f18@a5cdc4b035
2019-08-29 10:19:36 -07:00
Jean Perier 296b0d9374 [flang] Remove unused function after last commit
Original-commit: flang-compiler/f18@029fbf64c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
2019-08-28 05:50:23 -07:00
Jean Perier d93f493438 [flang] Address comment: store current enum value in an int
During enumerator name resolution, instead of keeping the current
enumerator value inside an expression, fold it to an int and keep
it as an int. This is clearer and will be easier if one wants to
provide some enum type size optimization.

Original-commit: flang-compiler/f18@4e49d5396c
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
Tree-same-pre-rewrite: false
2019-08-28 04:58:38 -07:00
Jean Perier 93aefc3940 [flang] Address comments: Update comments
Original-commit: flang-compiler/f18@6308613244
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
Tree-same-pre-rewrite: false
2019-08-28 03:35:40 -07:00
Jean Perier f23200963f [flang] Simplify name resolution visitor for parser::Enumerator
Do not define a Pre and a Post, simply walk the expression
with Walk in Pre to resolve the names inside the expression
before evaluating it.

Original-commit: flang-compiler/f18@b0e3c1691e
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
Tree-same-pre-rewrite: false
2019-08-27 07:14:51 -07:00
Jean Perier e3b5330fda [flang] Introduce IsNamedConstant to hide attr::PARAMETER details
for named constant that are actually enumerators.

Original-commit: flang-compiler/f18@d9c4888b72
Reviewed-on: https://github.com/flang-compiler/f18/pull/689
Tree-same-pre-rewrite: false
2019-08-27 07:14:51 -07:00
Tim Keith 396a659413 [flang] Resolve index in pointer assignment to array element
When the LHS of a pointer assignment is an array element, the
index must be resolved.

Fixed flang-compiler/f18#684.

Original-commit: flang-compiler/f18@c39c7872d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/687
2019-08-26 17:37:52 -07:00
Kiran Chandramohan 911cb63719 [flang] Fix for segfault in invalid proc interface message
The segfault happened due to a missing argument.

Original-commit: flang-compiler/f18@8a4f49e86d
Reviewed-on: https://github.com/flang-compiler/f18/pull/693
2019-08-27 23:28:15 +01:00
peter klausler 142fed87c1 [flang] Clean up omp_lib.h
Original-commit: flang-compiler/f18@7119cd0534
Reviewed-on: https://github.com/flang-compiler/f18/pull/690
2019-08-27 11:17:43 -07:00
peter klausler 9d5d73aa77 [flang] Reformat omp_lib.h
Original-commit: flang-compiler/f18@892d91b161
Reviewed-on: https://github.com/flang-compiler/f18/pull/690
Tree-same-pre-rewrite: false
2019-08-27 09:28:30 -07:00
Steve Scalpone 5c62bfb4f8 [flang] Implement int_ptr_kind.
Split omp_lib.F90 into two files: a Fortran file used to
create the omp_lib module and a .h file that can be used
directly, which apparently some codes do. Because of the
split, and wanting to avoid forcing use isc_c_binding,
use int_ptr_kind()  instead of c_intptr_t.

Original-commit: flang-compiler/f18@ce6a9fb173
Reviewed-on: https://github.com/flang-compiler/f18/pull/690
Tree-same-pre-rewrite: false
2019-08-26 14:58:10 -07:00
Steve Scalpone 9b5e691814 [flang] Add the OpenMP module.
Original-commit: flang-compiler/f18@09d8b0d6e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/690
Tree-same-pre-rewrite: false
2019-08-26 09:57:06 -07:00
David Truby 1281b9c5fc [flang] Misc changes for review
Original-commit: flang-compiler/f18@6d9ddb8f5e
Reviewed-on: https://github.com/flang-compiler/f18/pull/681
2019-08-23 21:17:57 +01:00
David Truby 0adca8bedc [flang] Fix for builds with libc++9 and libstdc++10
Original-commit: flang-compiler/f18@137de8a1cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/681
Tree-same-pre-rewrite: false
2019-08-23 14:57:05 +01:00
Tim Keith 51fe223916 [flang] Fix bug with statement functions
When the name of a statement function was previously declared, we
weren't correctly recognizing it as a statement function. E.g.
```
integer :: f, i
f(i) = i + 1
```

`f` was entered in the symbol table with `EntityDetails` and the
`parser::Name` on the first line was resolved to that symbol.
On the second line we replaced the symbol for `f` in the scope
with a subprogram symbol, but that didn't change the symbol in
the first `parser::Name`.

The fix requires:
1. don't erase the original symbol for `f`, just replace its details
2. when we erase the symbol for `f` in the subprogram scope, don't
   unresolve it

Original-commit: flang-compiler/f18@31212686ea
2019-08-26 15:46:49 -07:00
Jean Perier 98af2162d0 [flang] Fix intrinsic table probing issue with DOUBLE COMPLEX
The probing table was only expecting REAL for kind code
`KindCode::doublePrecision` that is also used for
`DoublePrecisionComplex`.
Add related tests.

Original-commit: flang-compiler/f18@342ed7e769
Reviewed-on: https://github.com/flang-compiler/f18/pull/680
2019-08-23 05:37:37 -07:00
Jean Perier 252e22ea97 [flang] Fix issue: Enforce specific intrinsic characteristics
Fix issue flang-compiler/f18#661.
The issue was that when probing a specific intrinsic, the
constraints of the related generic intrinsic were tested instead
of the more restrictive constraints of the specific intrinsic.

Original-commit: flang-compiler/f18@dd971e901d
Reviewed-on: https://github.com/flang-compiler/f18/pull/680
Tree-same-pre-rewrite: false
2019-08-23 05:03:41 -07:00
Jean Perier 8c4d2e8763 [flang] Fix SELECTED_CHAR_KIND('DEFAULT') folding issue
Fix issue flang-compiler/f18#676
The issue was that the 'DEFAULT' case was handled
directly in fold.cc which did not lowercase/trim trailing
space of the argument befaore comparing to "default".

Modify the `Selected_char_kind` function to accept the default
char kind as argument and to return it if the processed argument
matches "default".

Original-commit: flang-compiler/f18@14222ae914
Reviewed-on: https://github.com/flang-compiler/f18/pull/679
2019-08-23 03:36:29 -07:00
peter klausler 9717cc43b8 [flang] Make it easier to enable minimal FP output by default for module files (but do not enable it)
Original-commit: flang-compiler/f18@f6b640319b
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
2019-08-23 11:31:47 -07:00
peter klausler b7d463f1d5 [flang] Cope better with ridiculously large exponents on input
Original-commit: flang-compiler/f18@e55cc39bad
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:47 -07:00
peter klausler 787b997830 [flang] Address most review comments
Original-commit: flang-compiler/f18@e6164782ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:46 -07:00
peter klausler 79e8749f25 [flang] Address comments, fix a bug
Original-commit: flang-compiler/f18@e095bbb23f
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:45 -07:00
peter klausler b4f34801c6 [flang] Improve comments, clean up a couple of things
Original-commit: flang-compiler/f18@8d94d643b6
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:43 -07:00
peter klausler 1502542fe7 [flang] Fix copyright date on new file.
Original-commit: flang-compiler/f18@60b1be7ce2
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:43 -07:00
peter klausler 474c43a075 [flang] Correct header guards
Original-commit: flang-compiler/f18@77688d0392
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:40 -07:00
peter klausler bd3debe841 [flang] Reenable thorough test
Original-commit: flang-compiler/f18@431254483e
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:38 -07:00
peter klausler 28d55be08b [flang] Better unsigned division by constants
Original-commit: flang-compiler/f18@1b35c24a8a
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:37 -07:00
peter klausler b5408d26ed [flang] Clean up some static_casts
Original-commit: flang-compiler/f18@a5f81388a2
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:34 -07:00
peter klausler 3f15d46f63 [flang] Simplify guard bits (only use 3)
Original-commit: flang-compiler/f18@b710268c1b
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:33 -07:00
peter klausler 64a0a58bed [flang] Work around slow clang-7
Original-commit: flang-compiler/f18@ed634d72e3
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:32 -07:00
peter klausler b235c63caf [flang] faster Parse
Original-commit: flang-compiler/f18@ca97439c68
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:31 -07:00
peter klausler c4696eaf8e [flang] Get clean build with gcc
Original-commit: flang-compiler/f18@e6b5ed152d
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:30 -07:00
peter klausler 94d8b3f25b [flang] Simplify decimal->binary
Original-commit: flang-compiler/f18@01aefbbd7a
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:29 -07:00
peter klausler d08c9c9d1d [flang] Make thorough test thorough again
Original-commit: flang-compiler/f18@c24b10e434
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:27 -07:00
peter klausler 95165a3921 [flang] Replace usage of original decimal conversion code with calls to new library
Original-commit: flang-compiler/f18@7a164451f2
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:26 -07:00
peter klausler 099838a34d [flang] Debug test
Original-commit: flang-compiler/f18@bf2c22bcf4
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:25 -07:00
peter klausler 77b3c6d53a [flang] More testing, added thorough 32-bit sweep test
Original-commit: flang-compiler/f18@f81b92f91c
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:25 -07:00
peter klausler 3863551b31 [flang] Testing & debugging
Original-commit: flang-compiler/f18@f7f933e7f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:24 -07:00
peter klausler afda616c31 [flang] Begin adding tests
Original-commit: flang-compiler/f18@8776d8b663
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:20 -07:00
peter klausler 9cdb101a4d [flang] clean up a todo
Original-commit: flang-compiler/f18@1107bd1f02
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:18 -07:00
peter klausler 93f3ae8aeb [flang] Enforce digit limits
Original-commit: flang-compiler/f18@33600e127d
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:16 -07:00
peter klausler b53e09c44c [flang] Add rounding modes
Original-commit: flang-compiler/f18@9caa1a29a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:13 -07:00
peter klausler 9e26defed3 [flang] Code snapshot
Original-commit: flang-compiler/f18@46923344ca
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:12 -07:00
peter klausler f2cb0a8015 [flang] Move leading zero bit count into lib/common
Original-commit: flang-compiler/f18@1ed184febe
Reviewed-on: https://github.com/flang-compiler/f18/pull/671
Tree-same-pre-rewrite: false
2019-08-23 11:31:11 -07:00
Tim Keith a03a0432f3 [flang] Add conversions from EnumSet<Attr> to Attrs
This allows operations from EnumSet (e.g. `operator&`) to work as expected.

Original-commit: flang-compiler/f18@c8b8b742c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/675
2019-08-23 08:28:20 -07:00
Tim Keith 5e65aaa921 [flang] Fix .mod file bug with IMPORT of USEd name
If a symbol (derived type, for example) was use-associated into a scope
and then imported into a nested interface block, we were not including
the correct IMPORT statement in the .mod file.

This fixes refines the test for when the IMPORT is needed.

Fixes flang-compiler/f18#657.

Original-commit: flang-compiler/f18@8383de47ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/675
Tree-same-pre-rewrite: false
2019-08-23 07:14:55 -07:00
Tim Keith 191a5e34b0 [flang] Fix bug in .mod file for some subprogram attributes
Some attributes for subprograms can be in the subprogram prefix but
others cannot. For the latter, emit a separate attribute statement
to specify them. We were already doing that for PRIVATE but not for
OPTIONAL. Those may be the only two attributes this can apply to.

Fixes flang-compiler/f18#659.

Original-commit: flang-compiler/f18@ae67e08780
Reviewed-on: https://github.com/flang-compiler/f18/pull/675
Tree-same-pre-rewrite: false
2019-08-23 07:14:55 -07:00
Tim Keith abd56ee7fd [flang] Fix writing defined operators to .mod files
When defined operators were written to .mod files in USE statement
they did not come out correctly. They have to be emitted with
`PutGenericName()` so that `operator` is included.

Original-commit: flang-compiler/f18@d40e65a2f9
Reviewed-on: https://github.com/flang-compiler/f18/pull/675
Tree-same-pre-rewrite: false
2019-08-23 07:14:55 -07:00
Jinxin (Brian) Yang 20eaba0392 [flang] [OpenMP] miscellaneous parse tree updates (flang-compiler/f18#673)
1. Big chunk: update comments in parse-tree.h and openmp-grammar.h
   with Spec chapter/section info, simple explanation, or productions.

2. Update `To`, `Link`, and `From` clauses with `OmpObjectList` to allow
   `/Common Block/`. Spec does not mention whether `Common Block name`
   should be accepted or not, so we should assume that these clauses
   accept normal `list-item`, which is `Variable`, `Array Section`, or
   `Common Block name`.

Original-commit: flang-compiler/f18@140315cb62
Reviewed-on: https://github.com/flang-compiler/f18/pull/673
2019-08-23 09:45:03 -07:00
Jean Perier 511cd36a58 [flang] Address comment: remove useless const
Original-commit: flang-compiler/f18@60983f5021
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
2019-08-22 01:12:20 -07:00
Jean Perier 52e72abb67 [flang] Change Scope::name() to Scope::GetName()
Address comments. Not all scopes are related to
a name. This change makes this more visible to compiler
programers by changing `scope:name()` into `Scope::GetName()`
that returns an optional `SourceName` instead of always
returning a `SourceName` and dying when it cannot.

Original-commit: flang-compiler/f18@0addb79919
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
Tree-same-pre-rewrite: false
2019-08-21 06:29:11 -07:00
Jean Perier 281d41cc10 [flang] Use value semantic for SourceName
Change all SourceName* to std::optional<SourceName> because
SourceName is small enough (16 bytes) to be passed and stored
by value which avoid having to worry about life-time, storage and
value constance issues that comes with pointers.

Original-commit: flang-compiler/f18@73fc08d7bd
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
Tree-same-pre-rewrite: false
2019-08-21 05:33:03 -07:00
Jean Perier 5cc20f6ae8 [flang] Fix test copyright year.
Original-commit: flang-compiler/f18@25819aaf7a
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
Tree-same-pre-rewrite: false
2019-08-21 02:56:25 -07:00
Jean Perier f2453c9f15 [flang] Fix a crash with IMPORT in BLOCK (issue 604)
Only call scope.name() if the scope has a symbol (Block, Global,
Forall and ImpliedDo kind of scopes do not have a symbol).

Original-commit: flang-compiler/f18@81c6b67dd2
Reviewed-on: https://github.com/flang-compiler/f18/pull/634
Tree-same-pre-rewrite: false
2019-08-21 02:56:24 -07:00
Jinxin (Brian) Yang 5330ebbc4a [flang] [OpenMP] Canonicalization framework (flang-compiler/f18#599)
* [OpenMP] Canonicalization framework

This is mainly designed for loop association work but can be used for others,
and `CanonicalizeOmp` must be after `CanonicalizeDo`.

At the `Block` level, recognize legal sequence of `OpenMPLoopConstruct`,
`DoConstruct`, and `OmpEndLoopDirective`. Move available `DoConstruct`
and optional `OmpEndLoopDirective` into `OpenMPLoopConstruct`. Throw error
messages if:
 1. `DoConstruct` is not following `OpenMPLoopConstruct`
 2. `OmpEndLoopDirective` is not following associated do-loop

Once this pass this done, Semantics will not proceed if error exists.

* Update on reviews

1. extract matching and move part into its own function (once `DoConstruct`
   is moved, see whether `OpenMPEndLoopDirective` is available)

2. Use a template function to access construct from ExecutionPartConstruct.

3. Move this code into namespace semantics

Original-commit: flang-compiler/f18@52979f1e93
Reviewed-on: https://github.com/flang-compiler/f18/pull/599
2019-08-22 10:34:15 -07:00
Jean Perier 1bb0e9e362 [flang] Add comments and tests for issue 574 fix
Original-commit: flang-compiler/f18@89337cefc7
Reviewed-on: https://github.com/flang-compiler/f18/pull/672
2019-08-21 02:42:34 -07:00
Jean Perier ccb0b48805 [flang] Handle AssocEntityDetails in mis-parsed function reference
Fix issue flang-compiler/f18#574.
Array references can be mistaken for function references during
parsing. This is handled and fixed by semantics. however, if the
symbol in the misparsed array reference was construct associated,
then semantics was not handling the case correctly because
semantics was only expecting `ObjectEntityDetails`.
It was not possible to change the related `GetUltimate` into
`GetAssociationRoot` because associated symbols are not always
associated to another symbol (variable) but may be assoicated to
an expression. Hence, this change allow `AssocEntityDetails` to
be also accepted when dealing with array references misparsed as
function references.

Original-commit: flang-compiler/f18@b6a8b5f42b
Reviewed-on: https://github.com/flang-compiler/f18/pull/672
Tree-same-pre-rewrite: false
2019-08-20 06:15:52 -07:00
Eric Schweitz 7f2ce553e4 [flang] Add FIR dialect header
Original-commit: flang-compiler/f18@3c902e04d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/668
2019-08-16 19:01:49 -07:00
Eric Schweitz 9325f9974a [flang] Add mlir-tablegen for FIR ops
Original-commit: flang-compiler/f18@aae4b525da
Reviewed-on: https://github.com/flang-compiler/f18/pull/668
Tree-same-pre-rewrite: false
2019-08-16 16:14:22 -07:00
Peter Steinfeld d440b2e166 [flang] Responses to comments on the pull request:
- I removed the redundant test s3() from dosemantics90.f90
 - I changed the error messages to state "LOCAL locality-spec" rather than just
   "locality-spec"
 - I changed the names of a couple of variables/parameters in check-do.cc to
   make the code more understandable.

Original-commit: flang-compiler/f18@bcc6291e83
Reviewed-on: https://github.com/flang-compiler/f18/pull/663
2019-08-20 15:18:37 -07:00
Peter Steinfeld 6b8a1e8248 [flang] Changes to implement constraint C1129
"C1129 A variable that is referenced by the scalar-mask-expr of a concurrent-header or by any concurrent-limit or concurrent-step in that concurrent-header shall not appear in a LOCAL locality-spec in the same DO CONCURRENT statement."

In the process of implementing these checks, I found and fixed some other problems.  I also cleaned up some of the code in check-do.cc.  I ran into two notable difficulties in implementing these checks.  First, the symbols associated with the names in a locality spec get created when the locality specs are process during name resolution.  Thus, they're different from the symbols associated with names that appear in the control expressions.  At Tim's suggestion, I dealt with this by looking up the symbols from the names in the locality spec starting with the closest enclosing scope containing the DO construct.  Second, the symbols can be hidden behind host- use- and construct-associations.

Original-commit: flang-compiler/f18@055788c2f0
Reviewed-on: https://github.com/flang-compiler/f18/pull/663
Tree-same-pre-rewrite: false
2019-08-20 15:18:37 -07:00
Peter Steinfeld d8c4f96f14 [flang] Clean-up of check-do.cc
I got rid of duplicate functions that test for a procedure being PURE, renamed
the type SymbolContainer to SymbolSet, and moved some functions into the class
where they're referenced.

Original-commit: flang-compiler/f18@e48bfdf573
Reviewed-on: https://github.com/flang-compiler/f18/pull/663
Tree-same-pre-rewrite: false
2019-08-20 15:18:37 -07:00
Jinxin (Brian) Yang ca5fee5375 [flang] [OpenMP] miscellaneous parse tree fix (flang-compiler/f18#669)
Fix `aligned(argument-list[ : alignment])` for `declare simd`

(original implementation will throw parser error if `: alignment` is present.


Original-commit: flang-compiler/f18@f3f50f9ad3
Reviewed-on: https://github.com/flang-compiler/f18/pull/669
2019-08-20 10:30:29 -07:00
Jinxin (Brian) Yang 39be4ad473 [flang] [OpenMP] parse tree fix for Declare Target (flang-compiler/f18#670)
The original implementation will throw parsing error for multiple
clauses on `declare target` directive, for example:
```
!$omp declare target to(Q) link(R)
```

Based on the OpenMP Spec, we only need two types for the specifier:

```
!$omp declare target (extended-list)
```
or
```
!$omp declare target [clause[ [,] clause] ... ]
```

This fix makes `declare target` accepts either the `list` or `clauses`,
which is more general and better for error messages.

Adjusted existing test for checking the parse tree changes. More tests
will be added during Semantics.

Original-commit: flang-compiler/f18@60f47fc1a1
Reviewed-on: https://github.com/flang-compiler/f18/pull/670
2019-08-20 10:23:56 -07:00
Tim Keith ff768d92dd [flang] Special handling for VOLATILE and ASYNCHRONOUS
The VOLATILE and ASYNCHRONOUS attributes are special in two ways:
- they can be applied to use-associated variables
- if they are applied to a host-associated variable in a block, that
  variable has the attribute only within the scope of the block

The latter is implemented by making a new `HostAssocDetails` symbol
within the block where the attribute can be set without affecting the
variable in the outer scope. This is similar to how the SHARED locality
spec is implemented.

Fixes flang-compiler/f18#649.

Original-commit: flang-compiler/f18@471aba4513
Reviewed-on: https://github.com/flang-compiler/f18/pull/655
2019-08-13 13:50:24 -07:00
peter klausler 7749d43f3f [flang] Another pass with clean builds
Original-commit: flang-compiler/f18@e05dc1f444
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
2019-08-16 09:41:08 -07:00
peter klausler 10688e0903 [flang] Enable more warnings, deal with fallout
Original-commit: flang-compiler/f18@65c5b485af
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
Tree-same-pre-rewrite: false
2019-08-16 09:41:07 -07:00
peter klausler e8c453f4ae [flang] Clean up all newly enabled warnings
Original-commit: flang-compiler/f18@34a917c761
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
Tree-same-pre-rewrite: false
2019-08-16 09:41:07 -07:00
peter klausler 73632f5c36 [flang] Enable some new warnings, clean up some of their consequences
Original-commit: flang-compiler/f18@b82d1e9ac9
Reviewed-on: https://github.com/flang-compiler/f18/pull/666
Tree-same-pre-rewrite: false
2019-08-16 09:41:06 -07:00
Jean Perier 16b8b4cf78 [flang] Address review comments
Rename SetType to SetTypeMapping and change argumnet names.
Style changes.

Original-commit: flang-compiler/f18@3860097815
Reviewed-on: https://github.com/flang-compiler/f18/pull/635
2019-08-14 23:55:16 -07:00
Jean Perier 0818c53966 [flang] Transform implict none ternaries to bool in ImplicitRules
Original-commit: flang-compiler/f18@324567bd2d
Reviewed-on: https://github.com/flang-compiler/f18/pull/635
Tree-same-pre-rewrite: false
2019-08-08 08:38:01 -07:00
Jean Perier 069ea6ec75 [flang] Fix IMPLICIT issue 547
So far, in `ImplicitRules` class, `isImplicitNoneType_` is a ternary
unset -> nothing about implicit in this scope, look into parents
set true -> There is an IMPLICIT NONE for types in this scope.
set to false -> There is an IMPLICIT statement mapping types in
this false.

However, it was never set to false, so the IMPORT NONE of parent scopes
was "leaking" when it should not.

Set `isImplicitNoneType_` to false if an IMPLICIT statement is met to
fix the issue.

However, this change made the current name-resolution to then completly
disregard parent scope IMPLICIT NONE even for letters for which no
mapping were defined in the current scope. To fix this `GetType` was
modified to check for implicit none.

This led to `ApplyImplicitRules` to do redudant check, so it was
reorganised to querry for a type and complain if gets a nuulptr.

`GetImplicitType` was modified to avoid redundant error message.

Original-commit: flang-compiler/f18@962dbf3d8b
Reviewed-on: https://github.com/flang-compiler/f18/pull/635
Tree-same-pre-rewrite: false
2019-08-08 07:20:12 -07:00
Steve Scalpone da480fc6ce [flang] Use ACHAR() instead of the nonstandard backslash escape sequences.
Original-commit: flang-compiler/f18@103ed895fe
Reviewed-on: https://github.com/flang-compiler/f18/pull/660
2019-08-14 10:36:29 -07:00
Steve Scalpone 7b17a67190 [flang] Define the named constants for the C characters with
special semantics in the ISO_C_BINDING intrinsic module.

Original-commit: flang-compiler/f18@bee546fdb2
Reviewed-on: https://github.com/flang-compiler/f18/pull/660
Tree-same-pre-rewrite: false
2019-08-13 20:41:43 -07:00
Jinxin (Brian) Yang bcaba6e571 [flang] [OpenMP] parse tree changes for OpenMPLoopConstruct (flang-compiler/f18#656)
1. Following Block and Sections constructs, re-structure loop related
   constructs into `{Begin, Loop, End}`. Being part of the work in
   PR flang-compiler/f18#599, the `Loop` and `End` nodes are optional during parser. They
   should be filled in during the phase of `CanonicalizationOfOmp`. This
   commit is solely for the parse tree change. So, after this commit,
   PR flang-compiler/f18#599 needs to be changed accordingly.

2. Removed parse tree nodes for `END DO` and `END DO SIMD`. Similar to
   Block and Sections constructs, `End` node now accepts clauses too,
   the validity checks are deferred into Semantics. This is more genernal
   and error message could be better.

3. With this commit alone, assertion error would occur when `End` directive
   is present, for example `!$OMP END DO` because the `End` node is not
   moved into `OpenMPLoopConstruct` yet. Again, PR flang-compiler/f18#599 will handle that.

More tests will be added in PR flang-compiler/f18#599 and during the future Semantics work.

Original-commit: flang-compiler/f18@8cd1932fd6
Reviewed-on: https://github.com/flang-compiler/f18/pull/656
2019-08-14 15:16:27 -07:00
Steve Scalpone 0653dab8de [flang] Add dcmplx to the intrinsic table and extensions documentation.
Formatting change to dimag intrinsic table entry.

Original-commit: flang-compiler/f18@7f9237531c
Reviewed-on: https://github.com/flang-compiler/f18/pull/662
2019-08-14 11:32:32 -07:00
Jinxin (Brian) Yang e59305d7ae [flang] [OpenMP] parse tree changes for Sections/Parallel Sections constructs (flang-compiler/f18#652)
```
!$omp sections [clause[ [,] clause] ... ]
[!$omp section]
structured-block
[!$omp section
structured-block]
...
!$omp end sections [nowait]
```

1. Following parse tree node changes for Block constructs, changing the
   Sections/Parallel Sections to `{Begin, Section-Blocks, End}`

2. Handles `!$omp section` in the parser, do not create parse tree node
   for this directive because basically it is a delimiter to split the
   code into different `Block`s within the Sections/Parallel Sections
   constructs. So, the `Section-Blocks` here is a `std::list` of `Block`s.
   (thanks to Tim's suggestion)

3. Modify check-omp-structure.* to avoid breaking existing tests

More tests will be added during Semantics. Also, similar to Block constructs,
the `Begin` and `End` directive matching will be done in future PR.

This commit also contains Peter's important fix for allowing "!$OMP END SECTION"
as a legal statement following `Block` (daf5630: Modify execution part error
recovery to not consume !$OMP SECTION).


Original-commit: flang-compiler/f18@75d016f6d2
Reviewed-on: https://github.com/flang-compiler/f18/pull/652
2019-08-14 08:42:28 -07:00
Steve Scalpone 51fea2427f [flang] Change the suffix of the module files to be .f18.mod
so makefiles with "rm *.mod" will still work. Add a
new option to f18, -intrinsic-module-directory, which
supplies a directory in which f18 searches for standard
intrinsic modules. Neither the option nor the path is passed to F18_FC.

Original-commit: flang-compiler/f18@0bbda4c39e
Reviewed-on: https://github.com/flang-compiler/f18/pull/653
2019-08-13 16:02:03 -07:00
Steve Scalpone af794f959b [flang] Create a throwaway wrapper for the throwaway driver.
Add a script called flang to the bin directory that calls
f18 with the -I option pointing to the module files for the
predefined modules. The wrapper also sets the module suffix
to .fmf to avoid naming conflicts with module files generated
by other compilers. Now, the build creates and installs both
.mod and .fmf files for the predefined module files to
accommodate the flang script.

Original-commit: flang-compiler/f18@b6c30284e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/653
Tree-same-pre-rewrite: false
2019-08-12 21:40:03 -07:00
Steve Scalpone 465393f40f [flang] Add an entry to the intrinsics table for dimag.
Also, document extensions dconjg and dimag.

Original-commit: flang-compiler/f18@21535280ee
Reviewed-on: https://github.com/flang-compiler/f18/pull/654
2019-08-13 07:36:22 -07:00
Tim Keith d151b5e88b [flang] Fix bug writing character array constructor to .mod file
Character literals in an array constructor were always written
with no kind prefix, so if kind was not 1 they were incorrect.
`c4a` in `modfile28.f90` was an example of this.

Change it to always include the kind as is done with non-array
character literals.

Original-commit: flang-compiler/f18@4f4caa7006
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
2019-08-13 09:15:50 -07:00
Tim Keith 47ca9b8da2 [flang] Small .mod file fixes
- Only emit initializations for parameters and derived type components.
- Use `=>` for pointer initializations.
- Don't emit intrinsic symbols.

Original-commit: flang-compiler/f18@b91748c053
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
Tree-same-pre-rewrite: false
2019-08-13 09:15:50 -07:00
Tim Keith 7fcaf88bf8 [flang] Fix source location of some symbol names
Symbols can be declared across multiple statements. The CharBlock
that is used for the symbol name is from the first of these.

Sometimes that is not the best choice. If a name appears in a
type-declaration-stmt or a derived-type-stmt, that occurrence is a
better choice. Errors referencing that symbol should normally point
at that name (not its appearance in an earlier PUBLIC statement,
for example).

Also, the order of symbols in .mod files is based on the order of
their names in the cooked source. Here is an example where it is
necessary to sort `a` based on where its type-declaration-stmt
occurs rather than the first occurrence of `a`:
```
  public :: a
  type t
  end type
  type(t), parameter :: a = t()
```

The fix is to add `Symbol::ReplaceName()` so that we can update the
CharBlock for a symbol name when a better one is found, without
changing the actual characters that make up the name.

Original-commit: flang-compiler/f18@5544f16348
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
Tree-same-pre-rewrite: false
2019-08-13 09:15:44 -07:00
Tim Keith 2bc9a1ebed [flang] Write function result to .mod file after dummy args
The function result can depend on the declaration of the dummy
arguments so it should be written to the .mod file after them.

For example:
```
  function f(x)
    integer :: x(:)
    integer :: f(size(x))
  end
```

Original-commit: flang-compiler/f18@f6c8c58c24
Reviewed-on: https://github.com/flang-compiler/f18/pull/650
Tree-same-pre-rewrite: false
2019-08-13 09:15:39 -07:00
Jinxin (Brian) Yang 65de6787e2 [flang] [OpenMP] parse tree changes for Critical Construct (flang-compiler/f18#641)
Simple changes: add source provenance for directive itself and renaming

Original-commit: flang-compiler/f18@9246d266b0
Reviewed-on: https://github.com/flang-compiler/f18/pull/641
2019-08-12 16:08:10 -07:00
peter klausler cbb0be6a37 [flang] Fix bug flang-compiler/f18#643
Original-commit: flang-compiler/f18@29bb4312e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/646
2019-08-12 10:56:18 -07:00
peter klausler f3b5d156cb [flang] Fix bug flang-compiler/f18#642
Original-commit: flang-compiler/f18@d898b29285
Reviewed-on: https://github.com/flang-compiler/f18/pull/648
2019-08-12 12:10:43 -07:00
peter klausler 165ab68837 [flang] Fix bug flang-compiler/f18#644, always enable backslash escapes when reading module files
Original-commit: flang-compiler/f18@f1c897ceda
Reviewed-on: https://github.com/flang-compiler/f18/pull/645
2019-08-12 10:11:59 -07:00
Peter Steinfeld 8768a11d4c [flang] - ieee_exceptions.f90: I added all of the routines listed in table 17.3 of the standard that were not currently specified. I also re-ordered the routines to be in the same order as the standard.
- doconcurrent01.f90: I removed the custom versions of ieee_exceptions and
 iso_fortran_env.  I also fixed a typo in a comment.  Also, the use of the real
 standare interface caused one of the error messages to go away, so I fixed
 that.

Original-commit: flang-compiler/f18@a8b310a968
Reviewed-on: https://github.com/flang-compiler/f18/pull/637
2019-08-09 11:38:49 -07:00
Peter Steinfeld 5bade83a0b [flang] Tests for DO loop semantics
These are tests for checks that are already implemented, but for which we
did not have tests.

Original-commit: flang-compiler/f18@68f5acf7b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/637
Tree-same-pre-rewrite: false
2019-08-09 11:38:49 -07:00
Jinxin (Brian) Yang b41d10beae [flang] [OpenMP] parse tree changes for OpenMPBlockConstruct (flang-compiler/f18#632)
* [OpenMP] parse tree changes for `OpenMPBlockConstruct`

1. merge `Workshare` and `Single` into `OpenMPBlockConstruct` because
   they both accept structured-block and syntax is similar to other block
   directives.

2. `OpenMPBlockConstruct` changes to structure like `{Begin, Block, End}`,
   where `Begin` and `End` are tuple of `{Directive, ClauseList}`.

3. Updated the check-omp-structure.* for necessary parts. Added all the END
   directive enumeration types that may have clauses.

More tests will be added during Semantics.

* [OpenMP] Update on Tim's suggestion

1. Fix unspecified enumeration for `OmpDirective` in the `OmpContext`.
   This is through getting rid of `PushContext(source)` function to
   make sure whenever it is about to push a NEW context, directive
   source location and enumeration are available. To do that, I moved
   around all the switches for directive into high level `Construct`'s
   `Enter` node. Besides fixing the issue, the side benefit is that
   whenever we call `GetContext().directive`, we are sure that the
   `directive` here was set already.

2. When `Enter` the `OmpEndBlockDirective` node, partial context
   information, such as directive source location or legal clause lists,
   needs to be reset. The new directive source location should be
   `OmpEndBlockDirective`'s `source`. The enumeration `directive`
   should not be reset for the END directives that do not accept
   clauses because nothing needs to be checked (for example any clause
   that is on `END PARALLEL` is illegal).

Original-commit: flang-compiler/f18@e5bd6b7ba0
Reviewed-on: https://github.com/flang-compiler/f18/pull/632
2019-08-09 15:11:20 -07:00
peter klausler bc4d468d29 [flang] address comments
Original-commit: flang-compiler/f18@2bf995562c
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
2019-08-09 09:41:53 -07:00
peter klausler f13f372833 [flang] Add test for forward references in pointer initializers
Original-commit: flang-compiler/f18@9e01c102a1
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:52 -07:00
peter klausler e071162e04 [flang] More fixes; tests now all pass (with updates to some)
Original-commit: flang-compiler/f18@236ff3a3db
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:52 -07:00
peter klausler da6445198a [flang] rebase
Original-commit: flang-compiler/f18@a2086f0406
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:51 -07:00
peter klausler 699b499469 [flang] prep for review
Original-commit: flang-compiler/f18@41f11f4fa0
Reviewed-on: https://github.com/flang-compiler/f18/pull/638
Tree-same-pre-rewrite: false
2019-08-09 09:41:51 -07:00