Commit graph

2265 commits

Author SHA1 Message Date
Peter Klausler
f23a18c996 [flang] Update Extensions.md
Add note about type parameter declarations needing to come first in a derived type definition.

Original-commit: flang-compiler/f18@01358ac86e
Reviewed-on: https://github.com/flang-compiler/f18/pull/619
2019-08-02 15:42:54 -07:00
Peter Klausler
b40ee46b00 [flang] Merge pull request flang-compiler/f18#611 from flang-compiler/pmk-bounds
Fold LBOUND and UBOUND intrinsic functions

Original-commit: flang-compiler/f18@46d77ab006
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
2019-08-02 11:15:24 -07:00
peter klausler
c940fb6641 [flang] Fix test failure, clean up for merging
Original-commit: flang-compiler/f18@77bad27366
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
2019-08-02 10:17:10 -07:00
peter klausler
61fdf0a93e [flang] Take suggestion from review comment
Original-commit: flang-compiler/f18@7616b1f71b
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:12 -07:00
peter klausler
ca57deed00 [flang] Address review comment re: ALLOCATED intrinsic argument
Original-commit: flang-compiler/f18@b24381c7df
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:11 -07:00
peter klausler
25ff9296e0 [flang] Fix LBOUND/UBOUND of associated expr, add test
Original-commit: flang-compiler/f18@009095a9bc
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:11 -07:00
peter klausler
6df445d0e7 [flang] Fix LBOUND & UBOUND(function()), add tests
Original-commit: flang-compiler/f18@1e093e9927
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:10 -07:00
peter klausler
63423667fe [flang] Clean up some usage of std::optional lambda results
Original-commit: flang-compiler/f18@9a66f9da97
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:09 -07:00
peter klausler
29d3343910 [flang] Extract LBOUND/UBOUND folding into their own functions
Original-commit: flang-compiler/f18@bf9146ad77
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:06 -07:00
peter klausler
16f94adf9b [flang] Address some review comments, fix crash
Original-commit: flang-compiler/f18@7b7579eb5a
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:04 -07:00
peter klausler
2ca6f8220c [flang] Handle association entities; fix problems found in testing
Original-commit: flang-compiler/f18@c4d9fe9587
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:03 -07:00
peter klausler
43b3e49490 [flang] Fold LBOUND and UBOUND; do not insert empty triplets into whole array expressions
Original-commit: flang-compiler/f18@82fba68a66
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:22:00 -07:00
peter klausler
a7041f3a78 [flang] Implement GetShape with expression visitor
Original-commit: flang-compiler/f18@d607d02847
Reviewed-on: https://github.com/flang-compiler/f18/pull/611
Tree-same-pre-rewrite: false
2019-08-02 09:21:59 -07:00
Tim Keith
b72ef0b370 [flang] Merge pull request flang-compiler/f18#617 from flang-compiler/tsk-issue616
Fix bug with use-associated base of component reference

Original-commit: flang-compiler/f18@ded6d831ee
Reviewed-on: https://github.com/flang-compiler/f18/pull/617
2019-08-02 10:20:14 -07:00
Tim Keith
9764563f4d [flang] Fix bug with use-associated base of component reference
When the base of a component reference (`a` in `a%b`) was use
associated, we were failing to follow it to the real symbol.

Fixes flang-compiler/f18#616.

Original-commit: flang-compiler/f18@95bfac6f65
Reviewed-on: https://github.com/flang-compiler/f18/pull/617
2019-08-02 09:21:34 -07:00
Peter Klausler
f812a7d7f1 [flang] Merge pull request flang-compiler/f18#613 from flang-compiler/pmk-component-scope
Correct scopes of components

Original-commit: flang-compiler/f18@00bdacd6d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/613
2019-08-02 09:20:50 -07:00
peter klausler
d9bbf47cdc [flang] Do not inherit bindings as bare names, just components and type parameters
Original-commit: flang-compiler/f18@c4c70a6a81
Reviewed-on: https://github.com/flang-compiler/f18/pull/613
2019-08-01 15:04:27 -07:00
peter klausler
971744e106 [flang] Correct scopes of components and type parameters
Original-commit: flang-compiler/f18@6d9f85a241
Reviewed-on: https://github.com/flang-compiler/f18/pull/613
Tree-same-pre-rewrite: false
2019-08-01 15:04:25 -07:00
Jinxin (Brian) Yang
cdd1ca064c [flang] [OpenMP] Add Sections and Single Construct check (flang-compiler/f18#585)
* [OpenMP] Add Sections and Single Construct check

Parse tree for OmpEndSingle needs to be modified to save the provenance
of END SINGLE directive and check its own clauses

* Update on reviews

1. PushContext is created to push new context with source provenance

2. Tweak the logic for SECTION nesting, treak Orphaned or wrong nesting
   as the same error type

3. Make sure the check for NOWAIT clause only applies to the ones that
   are not handled by parser.
   Note that the case for DO or DO_SIMD will take effect after the
   loop association work (parse tree change) is done. But I still list
   them there for completeness.

4. Happen to find that NOWAIT is not accepted by PARALLEL SECTIONS,
   fixed it in the parser.


Original-commit: flang-compiler/f18@236cf1efea
Reviewed-on: https://github.com/flang-compiler/f18/pull/585
2019-08-01 14:32:33 -07:00
Tim Keith
38114c07d0 [flang] Merge pull request flang-compiler/f18#614 from flang-compiler/tsk-generics
Improve handling of generics with same name as type or procedure

Original-commit: flang-compiler/f18@a1e26df148
Reviewed-on: https://github.com/flang-compiler/f18/pull/614
2019-08-01 14:07:38 -07:00
Tim Keith
723add0b8d [flang] Fix merging of use associated generics
When we use-associate a generic interface name and then add more
procedures to the generic, we create a new symbol for the merged
generic. That symbol has to include a pointer to the derived type
or procedure with the same name, just as the original generic did.

To achieve that, change `AddSpecificProcsFrom` to also copy those
fields from the original symbol and change its name to `CopyFrom`
to reflect its new purpose. Also, change it to take `GenericDetails`
instead of `Symbol` as its argument so we can't call it on the wrong
kind of symbol.

Original-commit: flang-compiler/f18@1e22970e43
Reviewed-on: https://github.com/flang-compiler/f18/pull/614
2019-08-01 13:06:25 -07:00
Tim Keith
5e39c9aa1d [flang] Fix bug when writing empty generic to .mod file
When a generic interface had no specific procedures, we were writing
it the `.mod` file as `generic::g=>`, which is not valid Fortran.

Change to writing generics as interface blocks rather than generic
statements so that this case is handled. Include an access stmt if it
was declared private.

Also fix a bug in `test_errors.sh` where the expected/actual error
messages weren't sorted by line number correctly.

Original-commit: flang-compiler/f18@1c32a289b5
Reviewed-on: https://github.com/flang-compiler/f18/pull/614
Tree-same-pre-rewrite: false
2019-07-31 16:02:54 -07:00
Tim Keith
ebe4ff24b4 [flang] Improve handling of generics with same name as type or procedure
Create symbols for generics in a pre-pass over the specification part so
it is easier to handle cases when they have the same name as a derived
type or subprogram. This is done by calling `PreSpecificationConstruct`
on each `SpecificationConstruct` of a specification part before we
continue walking it. The generics symbols are created there and the same
mechanism will be used to handle forward references to derived types.

Report an error when the same name is used for a generic interface,
derived type, and subprogram.

Improve the error message issued when a procedure and generic interface
have the same name but the procedure is not a specific of the generic.

Change `SayAlreadyDeclared` to report the error on the second occurence
of the name when possible. This can arise for declarations the are
processed out of order, e.g. contained subprograms and generic interfaces.

Avoid multiple "already declared" errors for the case when a contained
subprogram has the same name as a declared entity. We first create the
symbol with SubprogramNameDetails, then replace it with the entity (and
report the error), then replace it with the real subprogram (and get the
error again). By setting and checking the error flag we avoid the second
error.

Original-commit: flang-compiler/f18@48fc076783
Reviewed-on: https://github.com/flang-compiler/f18/pull/614
Tree-same-pre-rewrite: false
2019-07-31 16:02:43 -07:00
Tim Keith
1f490974d8 [flang] Merge pull request flang-compiler/f18#608 from flang-compiler/tsk-deref
Add a way to check and dereference a pointer

Original-commit: flang-compiler/f18@31a3fae9f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/608
2019-07-30 06:13:19 -07:00
Tim Keith
423fcec801 [flang] Add a way to check and dereference a pointer
It is common to get a pointer, check it is not null, and dereference it.
Sometimes that requires a named temporary just to be able to do the check.

The macro `DEREF(p)` provides this capability: it asserts that `p` is not null
and returns `*p`. This is analagous to `.value()` on an `std::optional`.

We might want to add a way to disable `CHECK` and the check in `DEREF` together.

This change also includes some examples of making use of `DEREF`.

Original-commit: flang-compiler/f18@d7aa90e55a
Reviewed-on: https://github.com/flang-compiler/f18/pull/608
2019-07-29 09:12:52 -07:00
psteinfeld
de551721e5 [flang] Merge pull request flang-compiler/f18#596 from flang-compiler/ps-variable-definition
Changes for constraint C1128

Original-commit: flang-compiler/f18@d79137104e
Reviewed-on: https://github.com/flang-compiler/f18/pull/596
2019-07-25 16:41:14 -07:00
Peter Steinfeld
177948f9f6 [flang] More changes in response to review comments.
- resolve-names.cc: I reworded the message when a name appears in a
   locality-spec when a name is used that cannot appear in a variable
   definition context.
 - tools.cc: I removed the unused functions ```IsValueDummy()``` and
   ```IsModifiable()```.  I made the function ```GetAssociatedVariable()```
   static.  I cleaned up the code in ```GetAssociationRoot()```.  I cleaned up
   the code in ```IsOrContainsEventOrLockComponent()```.  I added a TODO to
   ```WhyNotModifiable()``` and made some other improvements to it.
 - tools.h: Removed some deleted and unnecessary functions.
 - I fixed up a couple of tests related to the changes in error messages.

Original-commit: flang-compiler/f18@47da8ff9c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/596
2019-07-25 13:37:11 -07:00
Peter Steinfeld
0904c4cfd1 [flang] Responses to previous review comments, specifically --
- expression.cc - fixed an error message.  This required changing the tests
 structconst0[3,4].f90
 - tools.[h,cc] - Added a new function called ```WhyNotModifiable()``` to see
 if a name can be modified.  This function returns a string that describes why
 the name cannot be modified.  I changed the existing function
 ```IsModifiable()``` to call ```WhyNotModifiable()```.  I fixed and
 restructured the code for ```GetAssociationRoot()```.  This involved creating
 the mutually recursive function ```GetAssociatedVariable()```.  I added a
 check  to see if a name is an INTENT(IN) dummy argument to the function
 ```IsVariableName()```.
 - resolve-names.cc - Wrote the function ```SayWithReason()``` that allows an
 arbitrary message to be added to an existing message.  I changed the code in
 ```PassesLocalityChecks()``` to call the new function ```WhyNotModifiable()```
 to get the specifics of why a variable name cannot be used in a variable
 modification context and then call the new function ```SayWithReason()``` to
 report the error.  I also cleaned up the code as per Jean's suggestion.

Original-commit: flang-compiler/f18@8a2f4bdfd2
Reviewed-on: https://github.com/flang-compiler/f18/pull/596
Tree-same-pre-rewrite: false
2019-07-25 13:02:17 -07:00
Peter Steinfeld
814b241b45 [flang] Changes for constraint C1128.
Specifically, these changes enforce the last sentence of the constraint, which
prohibits names that cannot appear in a variable definition context from
appearing in a locality-spec.  Here are the details.

 - Created the function "IsModifiableName" to return "true" when its parameter
   is the name of a variable that can appear in a variable definition context.
 - Created the function "GetAssociationRoot" to follow construct associations
   to potentially get to an underlying variable.  This function is similar to
   the existing "GetUltimate" function that follows use associations and host
   associations.  One difference is that "GetAssociationRoot" requires access
   to the types "MaybeExpr" and "SomeExpr", which makes is inappropriate to put
   into symbol.cc, which is where "GetUltimate" lives.  Perhaps we should move
   "GetUltimate" to tools.[h,cc].
 - Generalized the functions "IsPureFunction" to "IsPureProcedure" since either
   a pure function or subroutine can provide a context for variables that
   cannot be modified.  Changed "FindPureFunctionContaining" to
   "FindPureProcedueContaining" to go along with this.
 - Added the function "IsExternalInPureContext" to detect the case where a
   nominally pure procedure potentially modifies a variable.
 - Created the function "IsOrContainsEventOrLockComponent" to detect variables
   that either are of EVENT_TYPE or LOCK_TYPE or contain components of these
   types.  Such variables cannot appear in variable definition contexts.
 - Added the test resolve56.f90 to test most of these conditions.  Note that I
   only tested the new code from the perspective of locality-specs.

Original-commit: flang-compiler/f18@c9d2507b74
Reviewed-on: https://github.com/flang-compiler/f18/pull/596
Tree-same-pre-rewrite: false
2019-07-25 13:02:16 -07:00
Peter Klausler
bc7dfc3be3 [flang] Merge pull request flang-compiler/f18#603 from flang-compiler/pmk-fix
Fix IsVariable for Pete

Original-commit: flang-compiler/f18@73e8c365e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/603
2019-07-25 10:49:23 -07:00
peter klausler
6347b7c695 [flang] Fix bug
Original-commit: flang-compiler/f18@482f882e3f
Reviewed-on: https://github.com/flang-compiler/f18/pull/603
2019-07-25 10:40:09 -07:00
peter klausler
5eebbe7c9b [flang] Fix IsVariable for Pete
Original-commit: flang-compiler/f18@4a24f74ae4
Reviewed-on: https://github.com/flang-compiler/f18/pull/603
Tree-same-pre-rewrite: false
2019-07-25 10:40:07 -07:00
Peter Klausler
02826fbfe0 [flang] Merge pull request flang-compiler/f18#602 from flang-compiler/pmk-next
Fold more model inquiry intrinsics

Original-commit: flang-compiler/f18@7d1aeea409
Reviewed-on: https://github.com/flang-compiler/f18/pull/602
2019-07-25 10:30:22 -07:00
peter klausler
4aa659f795 [flang] Address comments; allow "real,parameter::x=tiny(x)"
Original-commit: flang-compiler/f18@e865358871
Reviewed-on: https://github.com/flang-compiler/f18/pull/602
2019-07-25 10:16:28 -07:00
peter klausler
9b079deed5 [flang] Fold more model inquiry intrinsics
Original-commit: flang-compiler/f18@a3d82893b7
Reviewed-on: https://github.com/flang-compiler/f18/pull/602
Tree-same-pre-rewrite: false
2019-07-24 14:07:03 -07:00
jeanPerier
23bf80fb7c [flang] Merge pull request flang-compiler/f18#583 from flang-compiler/jpr-fix-582
Fix issue flang-compiler/f18#582: implicit ac-do-variable kind in expressions

Original-commit: flang-compiler/f18@cebc2be4b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/583
2019-07-24 10:07:30 -07:00
Jean Perier
5ab96a8604 [flang] Fix issue flang-compiler/f18#582: implicit ac-do-variable kind in expressions
Original-commit: flang-compiler/f18@4150a5e411
Reviewed-on: https://github.com/flang-compiler/f18/pull/583
2019-07-17 05:19:10 -07:00
Tim Keith
8269bf6c8c [flang] Merge pull request flang-compiler/f18#591 from flang-compiler/tsk-issue586
Merge use-associated generics

Original-commit: flang-compiler/f18@e0b28015f1
Reviewed-on: https://github.com/flang-compiler/f18/pull/591
2019-07-24 06:18:36 -07:00
Tim Keith
64a8b9b3d3 [flang] Merge use-associated generics
When the same generic is use-associated from two different modules,
they must be merged together into a symbol with GenericDetails.

After that merger, if there is a use association of the same name
with a non-generic we have to report an error. So save the UseDetails
from the original USE in GenericDetails so we can create the
appropriate UseErrorDetails.

Fixes flang-compiler/f18#586.

Original-commit: flang-compiler/f18@5067345f70
Reviewed-on: https://github.com/flang-compiler/f18/pull/591
2019-07-24 06:14:42 -07:00
jeanPerier
7d8a0733c3 [flang] Merge pull request flang-compiler/f18#600 from flang-compiler/jpr-fix-598
Avoid interference between different construct association in name resolutions

Original-commit: flang-compiler/f18@28c32a7538
Reviewed-on: https://github.com/flang-compiler/f18/pull/600
2019-07-24 02:40:30 -07:00
Jean Perier
ee845d4c64 [flang] Address comment: make CHECK test more explicit
Original-commit: flang-compiler/f18@a346462676
Reviewed-on: https://github.com/flang-compiler/f18/pull/600
2019-07-24 02:06:31 -07:00
Jean Perier
8ed0f4c806 [flang] Avoid interference between different association variable resoltions
Fix issue 598 and related issues.

Transform resolve-names.cc ConstructVisitor association_ member into a
stack so that different association construct (select-type, select-rank,
change-team, associate) imbrication/succession do not interfere with each
other leading to wrong erronous symbol resolution.

Original-commit: flang-compiler/f18@5781f29ed6
Reviewed-on: https://github.com/flang-compiler/f18/pull/600
Tree-same-pre-rewrite: false
2019-07-23 08:57:40 -07:00
Peter Klausler
165b0b8053 [flang] Merge pull request flang-compiler/f18#601 from flang-compiler/pmk-fixes
Fix legal pointer target test

Original-commit: flang-compiler/f18@751cb64ae9
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
2019-07-23 15:12:29 -07:00
peter klausler
ee23b2fbbd [flang] Do not remove things from .gitignore
Original-commit: flang-compiler/f18@27c896ea0b
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
2019-07-23 14:57:46 -07:00
peter klausler
a65661d5e6 [flang] Review comment
Original-commit: flang-compiler/f18@784d2cc6df
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
Tree-same-pre-rewrite: false
2019-07-23 14:07:49 -07:00
peter klausler
353202bdcf [flang] Fix handling of ALLOCATABLE components in GetLastTarget
Original-commit: flang-compiler/f18@6b3b404bdc
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
Tree-same-pre-rewrite: false
2019-07-23 13:42:06 -07:00
peter klausler
3f753af937 [flang] Fix pointer target check
Original-commit: flang-compiler/f18@8249bc8cd4
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
Tree-same-pre-rewrite: false
2019-07-23 12:35:56 -07:00
peter klausler
00861127ac [flang] Improve comments
Original-commit: flang-compiler/f18@277fb1cc91
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
Tree-same-pre-rewrite: false
2019-07-23 11:45:55 -07:00
peter klausler
e4945e5d09 [flang] Improve expression traversal, use it more for tools
Original-commit: flang-compiler/f18@4980b928bc
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
Tree-same-pre-rewrite: false
2019-07-23 10:55:56 -07:00
peter klausler
daf9eb09d4 [flang] Add root/ to .gitignore, remove old build-specific directory names
Original-commit: flang-compiler/f18@d5843aa319
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
Tree-same-pre-rewrite: false
2019-07-22 14:06:06 -07:00