Commit graph

1712 commits

Author SHA1 Message Date
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 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 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
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 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 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
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 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
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 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
peter klausler 3028ecf0b8 [flang] Reimplement GetLastSymbol with expression visitor
Original-commit: flang-compiler/f18@a996751e97
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
Tree-same-pre-rewrite: false
2019-07-22 14:05:33 -07:00
peter klausler 3f00257e3b [flang] Fix crash
Original-commit: flang-compiler/f18@e00864f17e
Reviewed-on: https://github.com/flang-compiler/f18/pull/601
Tree-same-pre-rewrite: false
2019-07-22 14:05:07 -07:00
jeanPerier 953d93dbe8 [flang] Merge pull request flang-compiler/f18#544 from flang-compiler/jpr-reshape-only-folding
RESHAPE without shared runtime/front-end descriptor API

Original-commit: flang-compiler/f18@24856b8238
Reviewed-on: https://github.com/flang-compiler/f18/pull/544

Due to a conflicting rebase during the linearizing of flang-compiler/f18, this commit squashes a number of other commits:

flang-compiler/f18@2ec1d85d39 Implement RESHAPE folding on Constant<T> only
flang-compiler/f18@5394630539 Enable RESHAPE folding tests
flang-compiler/f18@83b2b86253 Answer review comment + Add a common path for intrsinic function folding before specializing the folding per type. + Make reshape folding return an "invalid" intrinsic after errors are met so that warnings do not get re-generated. + Misc style changes
flang-compiler/f18@2e5c29f280 add missing file to previous commit...
flang-compiler/f18@9bd5ad9875 Document issue #518 workaround
flang-compiler/f18@a4f8f51831 Go back to clang-format version 7.01
flang-compiler/f18@e871e58a52 answer comment regarding naming and interface
flang-compiler/f18@145c7c1ece Merge branch 'master' into jpr-reshape-only-folding Too many logical conflicts to simply rebase.
2019-07-23 05:36:17 -07:00
peter klausler 31ffd34a02 [flang] Avoid crash on bad subscript, refactor Constant bounds a bit
Original-commit: flang-compiler/f18@c2e01e8386
Reviewed-on: https://github.com/flang-compiler/f18/pull/597
2019-07-19 16:17:07 -07:00
peter klausler 7c03f03c67 [flang] Do not add invalid subscript triple to whole assumed-size array reference
Original-commit: flang-compiler/f18@71c134a552
Reviewed-on: https://github.com/flang-compiler/f18/pull/597
Tree-same-pre-rewrite: false
2019-07-19 14:49:25 -07:00
peter klausler 978b246229 [flang] Avoid crashing in check-allocate.cc on CLASS(*)
Original-commit: flang-compiler/f18@7ba4275998
Reviewed-on: https://github.com/flang-compiler/f18/pull/595
2019-07-19 13:50:39 -07:00
Jean Perier 815cc42e9a [flang] Fix issue flang-compiler/f18#515
Do not emit "is not a branch target" warning for old action-stmt just
because these action-stmt are depreciated. The depreciated aspect of
these features is already handled via -Mstandard.

Original-commit: flang-compiler/f18@f7d124d8cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/593
2019-07-19 07:20:47 -07:00
peter klausler 645d98719d [flang] address review comment
Original-commit: flang-compiler/f18@7012b61786
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
2019-07-19 10:37:55 -07:00
peter klausler 834c4d6bc4 [flang] document a non-extension
Original-commit: flang-compiler/f18@625daf5218
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
Tree-same-pre-rewrite: false
2019-07-18 15:26:17 -07:00
peter klausler 6da0d748d5 [flang] Accept NULL() in struct constructor for ALLOCATABLE component
Original-commit: flang-compiler/f18@7aee0e4852
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
Tree-same-pre-rewrite: false
2019-07-18 15:08:50 -07:00
peter klausler 14f693fb94 [flang] Document intent to not support modules & programs whose names conflict with contents
Original-commit: flang-compiler/f18@e23c481911
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
Tree-same-pre-rewrite: false
2019-07-18 13:57:21 -07:00
peter klausler 85db492ea0 [flang] Support SELECTED_CHAR_KIND("DEFAULT")
Original-commit: flang-compiler/f18@c05c96c474
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
Tree-same-pre-rewrite: false
2019-07-17 15:58:28 -07:00
peter klausler 99ec2fa834 [flang] Document BOZ initializers for REAL
Original-commit: flang-compiler/f18@d72d5feb01
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
Tree-same-pre-rewrite: false
2019-07-17 14:29:11 -07:00
peter klausler 3dbc1b7abe [flang] Allow BOZ initializers on REAL parameters, too.
Original-commit: flang-compiler/f18@e1ab6b316e
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
Tree-same-pre-rewrite: false
2019-07-17 14:26:35 -07:00
peter klausler 8187bc12cd [flang] Silence spurious overflow warning on negative int4->int2 folding
Original-commit: flang-compiler/f18@5f1cad3911
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
Tree-same-pre-rewrite: false
2019-07-17 14:14:09 -07:00
peter klausler 2a3f3163e6 [flang] Extension: relax "same kind" rules on some intrinsics
Original-commit: flang-compiler/f18@ce5130f84b
Reviewed-on: https://github.com/flang-compiler/f18/pull/590
Tree-same-pre-rewrite: false
2019-07-17 12:51:52 -07:00
peter klausler 2f49ddeefe [flang] review comment
Original-commit: flang-compiler/f18@f5c46291ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/580
2019-07-16 15:57:55 -07:00
peter klausler 40fb469233 [flang] Fix bug flang-compiler/f18#579 while here
Original-commit: flang-compiler/f18@eefbcdcb54
Reviewed-on: https://github.com/flang-compiler/f18/pull/580
Tree-same-pre-rewrite: false
2019-07-16 15:57:52 -07:00
peter klausler 258e8bda21 [flang] Allow forward references to procedure interfaces in derived types (fixing flang-compiler/f18#571 more)
Original-commit: flang-compiler/f18@c1aeeae776
Reviewed-on: https://github.com/flang-compiler/f18/pull/580
Tree-same-pre-rewrite: false
2019-07-16 15:57:29 -07:00
Tim Keith 16356d58bc [flang] Allow forward reference to binding name in type-bound generic
Type-bound generic statements can have binding names that refer to
bindings that occur later in the type. So save a map of generic to
binding names and process them when we get to the end of the
type-bound procedure part. This is similar to how specific procedures
of generic identifiers are handled.

Also detect duplicate binding names for a type-bound generic.

Fixes issue flang-compiler/f18#572.

Original-commit: flang-compiler/f18@d58bb77cfa
Reviewed-on: https://github.com/flang-compiler/f18/pull/577
2019-07-15 17:09:03 -07:00
peter klausler d3c8af484a [flang] Fix typo
Original-commit: flang-compiler/f18@f7d9f5bd7c
Reviewed-on: https://github.com/flang-compiler/f18/pull/565
2019-07-16 10:53:39 -07:00
peter klausler 367d3eec60 [flang] Address review comment
Original-commit: flang-compiler/f18@5d6749c3d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/565
Tree-same-pre-rewrite: false
2019-07-16 09:58:55 -07:00
peter klausler 8f40dbcd19 [flang] Fix flang-compiler/f18#571: forward reference to interface
Original-commit: flang-compiler/f18@5e00d1699c
Reviewed-on: https://github.com/flang-compiler/f18/pull/565
Tree-same-pre-rewrite: false
2019-07-16 09:58:53 -07:00
peter klausler 8c0aa90185 [flang] Handle USE and host associations in characteristics analysis
Original-commit: flang-compiler/f18@1625f72e35
Reviewed-on: https://github.com/flang-compiler/f18/pull/565
Tree-same-pre-rewrite: false
2019-07-16 09:58:51 -07:00
peter klausler 29004ece95 [flang] fix crash in ASSOCIATED() intrinsic with two arguments
Original-commit: flang-compiler/f18@1a393ff43b
Reviewed-on: https://github.com/flang-compiler/f18/pull/565
Tree-same-pre-rewrite: false
2019-07-16 09:58:48 -07:00
peter klausler fc638c021c [flang] Make warning about exponent letters more useful
Original-commit: flang-compiler/f18@9c9aaacd7b
Reviewed-on: https://github.com/flang-compiler/f18/pull/565
Tree-same-pre-rewrite: false
2019-07-16 09:58:47 -07:00