Commit graph

708 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
peter klausler
375dcec348 [flang] When creating symbols for intrinsics, do not put them in the global scope, and do not emit them to module files.
Original-commit: flang-compiler/f18@9907026609
Reviewed-on: https://github.com/flang-compiler/f18/pull/565
Tree-same-pre-rewrite: false
2019-07-16 09:58:46 -07:00
Jean Perier
31cab04be7 [flang] Add fix for issue flang-compiler/f18#517
Original-commit: flang-compiler/f18@d9bb6890d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/552
2019-07-10 08:44:05 -07:00
Jean Perier
93e05161ea [flang] Answer comment: split cannondo new tests
Original-commit: flang-compiler/f18@7ebf7f72b0
Reviewed-on: https://github.com/flang-compiler/f18/pull/552
Tree-same-pre-rewrite: false
2019-07-10 03:53:25 -07:00
Jean Perier
16cf494888 [flang] Add non standard feature for labeled do not ending with END DO or CONTINUE
* The warning was already here, this commit only refactors things so that
 it can be controled with -Mstandard.
* Also makes the warning point to the do-stmt and adds a note to the warning
  pointing to the statements where it ends.

Original-commit: flang-compiler/f18@11e1eb6edd
Reviewed-on: https://github.com/flang-compiler/f18/pull/552
Tree-same-pre-rewrite: false
2019-07-09 11:54:40 -07:00
Jean Perier
8a4b595bf6 [flang] Answer comments
* Support target label of label-do on all executable constructs as well as
  forall and where.
* Re-oder and rename related checks in resolve-labels.cc

Original-commit: flang-compiler/f18@e5ac8a1660
Reviewed-on: https://github.com/flang-compiler/f18/pull/552
Tree-same-pre-rewrite: false
2019-07-09 10:40:14 -07:00
Jean Perier
5597f366e1 [flang] Fix issues 518 and 546
- Only allow out-of-scope label target for label-do-stmt
  when the label is on an end-stmt of a scope directly nested
  into the one of the label-do-stmt.
- Also transform label-do-stmt into non-label-do constructs
  so that later phases do not have to handle label-do-stmt.

Original-commit: flang-compiler/f18@91cff2f296
Reviewed-on: https://github.com/flang-compiler/f18/pull/552
Tree-same-pre-rewrite: false
2019-07-08 09:19:07 -07:00
Tim Keith
97e60b7354 [flang] Procedure distinguishability rules for operators
Generic operators and assignment have different rules than generic
names for their procedures being distinguishable.

Implement those rules in `DistinguishableOpOrAssign`. The rules are
considerably simpler: they must have the name number of dummy arguments
and at least one pair in the same position must be distinguishable.

Fixes issue flang-compiler/f18#563.

Original-commit: flang-compiler/f18@276bb08206
Reviewed-on: https://github.com/flang-compiler/f18/pull/576
2019-07-15 13:05:42 -07:00
peter klausler
6599bdf9b5 [flang] Convert more empty classes to enums
Original-commit: flang-compiler/f18@9cf8b9eea7
Reviewed-on: https://github.com/flang-compiler/f18/pull/569
Tree-same-pre-rewrite: false
2019-07-15 13:05:28 -07:00
peter klausler
2d0f9636a8 [flang] Change some empty classes into enums
Original-commit: flang-compiler/f18@652e474556
Reviewed-on: https://github.com/flang-compiler/f18/pull/569
Tree-same-pre-rewrite: false
2019-07-15 13:05:27 -07:00
Tim Keith
714d3be8bf [flang] Use passed-object dummy in distinguishability checks
Complete the checks for distinguishable specifics procedure in a generic
by considering any passed-object dummy arguments.

C1514 rule 3 is implemented and the checks for the other rules are
extended to consider the PASS attribute, including the concept of the
"effective" position of an argument in an argument list, computed by
ignoring passed-object arguments.

Add `pass` to `characteristics::DummyArgument` to mark each
passed-object dummy argument.

Change symbols to store the index of the passed-object dummy argument
rather than its symbol.

Check that specifics of a type-bound generic are distinguishable only
after all of the procedure bindings have been processed. They don't have
to be before the generic.

Original-commit: flang-compiler/f18@2751490f95
Reviewed-on: https://github.com/flang-compiler/f18/pull/567
2019-07-12 12:18:00 -07:00
Tim Keith
507cc50866 [flang] Add IsGlobal and IsDerivedType to Scope
These are properties of Scopes that are checked frequently
so add IsGlobal and IsDerivedType for convenience.

Original-commit: flang-compiler/f18@aebb2379d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/567
Tree-same-pre-rewrite: false
2019-07-12 12:17:56 -07:00
Jinxin (Brian) Yang
800b96540b [flang] Examples of Composite and Combined constructs (flang-compiler/f18#558)
* Examples of Composite and Combined constructs

2.8.3 Loop SIMD Construct
2.11.1 Parallel Loop Construct
2.11.3 Parallel Loop SIMD Construct

Not in the implementation:
2.8.3 DO SIMD: A list item may appear in a linear or firstprivate clause but not both

Original-commit: flang-compiler/f18@75d9c1a081
Reviewed-on: https://github.com/flang-compiler/f18/pull/558
2019-07-11 15:18:09 -07:00
peter klausler
20dd13e492 [flang] Better name resolution for intrinsics
Original-commit: flang-compiler/f18@31fd9c82e9
Reviewed-on: https://github.com/flang-compiler/f18/pull/561
2019-07-11 11:52:47 -07:00
Tim Keith
cc8e1e9e9f [flang] Change two member functions of DerivedTypeDetails to non-member
In `OrderParameterNames` and `OrderParameterDeclarations` it was
always true that `this == &type.get<DerivedTypeDetails>()` which
meant that `this` was redundant.

So convert them to non-member functions in `tools.h` that get the
details from the symbol passed in. This makes life simpler for the
callers.

Original-commit: flang-compiler/f18@81710d4e6e
Reviewed-on: https://github.com/flang-compiler/f18/pull/559
2019-07-11 08:51:40 -07:00
Tim Keith
c37707a5b1 [flang] Move various Instantiate functions to tools.cc
Move these functions from scope.cc, symbol.cc, type.cc into tools.cc:
  Scope::FindOrInstantiateDerivedType
  Scope::InstantiateDerivedType
  Scope::InstantiateIntrinsicType
  Symbol::Instantiate
  DerivedTypeSpec::ProcessParameterExpressions
  DerivedTypeSpec::Instantiate

This eliminates some dependencies in these files on SemanticsContext,
FoldingContext, etc.

It also allows three of the functions to be private to tools.cc
because they are only called from the others.

Original-commit: flang-compiler/f18@48c6efbf95
Reviewed-on: https://github.com/flang-compiler/f18/pull/559
Tree-same-pre-rewrite: false
2019-07-11 08:51:40 -07:00
Tim Keith
ca06058da8 [flang] Fix formatting
Original-commit: flang-compiler/f18@bef7ddd43b
Reviewed-on: https://github.com/flang-compiler/f18/pull/559
Tree-same-pre-rewrite: false
2019-07-11 08:51:21 -07:00
peter klausler
caf9e8e624 [flang] Fix name resolution with directly recursive calls.
Original-commit: flang-compiler/f18@b8e8610430
Reviewed-on: https://github.com/flang-compiler/f18/pull/557
Tree-same-pre-rewrite: false
2019-07-10 16:42:09 -07:00
Peter Steinfeld
542264e519 [flang] Improved warning message base on feedback from Peter.
Original-commit: flang-compiler/f18@030f364324
Reviewed-on: https://github.com/flang-compiler/f18/pull/551
2019-07-10 12:53:56 -07:00
Peter Steinfeld
18f2628287 [flang] Changed the warning as recommended.
Original-commit: flang-compiler/f18@7887331705
Reviewed-on: https://github.com/flang-compiler/f18/pull/551
Tree-same-pre-rewrite: false
2019-07-10 12:53:56 -07:00
Peter Steinfeld
66e8935dec [flang] Changes related to feedback from pull request flang-compiler/f18#551
- Changed the name a a function to FindOrDeclareEnclosingEntity
 - Changed that function to return a reference rather than a pointer
 - Polished the setting of the IMPLICIT flag on a declared entity in a
 locality-spec
 - Changed a test to remove an unreported error

Original-commit: flang-compiler/f18@0c1a00d7c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/551
Tree-same-pre-rewrite: false
2019-07-10 12:53:56 -07:00
Peter Steinfeld
2ce7432bb8 [flang] Enabling automatic declaration of names in SHARED locality-spec's
Prior to this change, the compiler issued an error message when a name in a
SHARED locality-spec had not been declared explicitly in an enclosing scope.
Presumably, this was done to enforce constraint C1124.  This constraint states
that "A variable-name in a locality-spec shall be the name of a variable in the
innermost executable construct or scoping unit that includes the DO CONCURRENT
statement".  For LOCAL and LOCAL_INIT locality-spec's, we were automatically
creating a local variable in the situation where one had not been explicitly
declared rather than issuing an error message.

The only compiler I could find that implements the SHARED locality-spec was the
PGI compiler, which automatically creates a variable and does not emit an error
message.  Also, @vdonaldson said that he had consulted with a member of the
Fortran standards committee who said that the correct thing was to create a
variable if necessary.

This change has the compiler creating a variable in the enclosing scope of a DO
CONCURRENT statement if necessary.  I also changed a test to adapt to the new
behavior.  I also consolidated the semantic checking for the constraints
associated with all of the locality-spec's.

Original-commit: flang-compiler/f18@d9253a76fc
Reviewed-on: https://github.com/flang-compiler/f18/pull/551
Tree-same-pre-rewrite: false
2019-07-10 12:53:55 -07:00
Jinxin (Brian) Yang
0f8e792455 [flang] 2.8.1 SIMD structural checks (flang-compiler/f18#554)
Straightforward implementation but not including:
* list-item on aligned clause
* nesting check with the ordered construct (parse tree changes needed!)
* list-item attributes check on aligned clause

Original-commit: flang-compiler/f18@cf04d8ad26
Reviewed-on: https://github.com/flang-compiler/f18/pull/554
2019-07-09 14:08:50 -07:00
peter klausler
008e697192 [flang] Fix regressions found in testing
Original-commit: flang-compiler/f18@ea09b191df
Reviewed-on: https://github.com/flang-compiler/f18/pull/553
2019-07-08 16:02:50 -07:00
peter klausler
644b2aabd0 [flang] Support *length character length specifiers
Original-commit: flang-compiler/f18@874b13b7d8
Reviewed-on: https://github.com/flang-compiler/f18/pull/553
Tree-same-pre-rewrite: false
2019-07-08 14:07:56 -07:00
Peter Steinfeld
5b7b8866b8 [flang] Improved the implementation of "IsCoarray()" suggested by @tskeith.
Original-commit: flang-compiler/f18@efaf5fca2e
Reviewed-on: https://github.com/flang-compiler/f18/pull/542
2019-07-03 13:59:44 -07:00