Commit graph

2311 commits

Author SHA1 Message Date
Tim Keith
dd8601162b [flang] Fix bug with generic and specific having same name
If a generic interface had a specific procedure with the same name that
is specified by an interface body, it was not handled correctly.

We were replacing the generic symbol with the symbol for the specific
procedure. Instead, leave the generic symbol in the scope and just
insert the new symbol for the specific into the generic.

Also, don't do distinguishability checks when one of the specific
procedures already has an error.

Fixes flang-compiler/f18#587.

Original-commit: flang-compiler/f18@2e90565675
Reviewed-on: https://github.com/flang-compiler/f18/pull/640
2019-08-08 17:05:49 -07:00
Tim Keith
ca973fc355 [flang] Merge pull request flang-compiler/f18#639 from flang-compiler/tsk-shared
Fix problems building with shared libraries on Linux

Original-commit: flang-compiler/f18@0e3ed603c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/639
2019-08-08 17:10:16 -07:00
Tim Keith
57af252f56 [flang] Fix problems building with shared libraries on Linux
Building with gcc 8 or 9 with shared libraries had linking
problems in test/evaluate. Fix those by adding FortranSemantics
to the library dependencies.

Original-commit: flang-compiler/f18@009b9ab171
Reviewed-on: https://github.com/flang-compiler/f18/pull/639
2019-08-08 16:23:53 -07:00
jeanPerier
ee2dd1c503 [flang] Merge pull request flang-compiler/f18#631 from flang-compiler/jpr-fix-589
Prevent result symbol to be converted into function when they are called

Original-commit: flang-compiler/f18@464310a1e3
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
2019-08-08 05:48:20 -07:00
Jean Perier
7e197e691f [flang] Fix reabsing conflict issue
Remove duplicate `IsFunctionResultWithSameNameAsFunction` declarartion.

Original-commit: flang-compiler/f18@d88597ca72
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
2019-08-08 05:30:21 -07:00
Jean Perier
3b7b2f56d5 [flang] Answer PR 631 comments:
- Create a function `IsFunctionResult(const Symbol &)` in
   lib/semantics/tools.h.
 - style edit in weird var definition style.

Original-commit: flang-compiler/f18@15e3f87b40
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
Tree-same-pre-rewrite: false
2019-08-08 04:01:34 -07:00
Jean Perier
24bb2c29cd [flang] Prevent result symbol to be converted into function when they are called.
+ Fix issue 589.
+ Catch empty subscript list in array reference
In name resolution, when skimming through the execution statement of a
function, calls to the result symbol should not trigger the conversion
of this symbol to a function symbol. The result is a data object and
cannot be called unless it was explictly declared to be a procedure
pointer.
Notably, recursive function calls cannot be made if RESULT was not used.

The symbol is prevented from being transformed into a function
symbol by transforming it into an object before skimming through the
executable statement. This is done after processing all the
specifications so that if the result actually is a procedure pointer,
the call to `ConvertToObjectEntity` introduced by this commit will
not convert it to an object by mistake.

This commit also introduce a check when fixing misparsed function
reference into array reference to verify the array reference has
array subscripts. Currently this went uncaught. It is not possible
to complain later in expressions because the subscript list of
expression might be empty for unrelated error recovery reasons
(e.g. if an entity of the wrong type appeared as susbcript).

Add related tests.

Original-commit: flang-compiler/f18@2fd8b65f58
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
Tree-same-pre-rewrite: false
2019-08-08 03:58:41 -07:00
jeanPerier
ea489de811 [flang] Merge pull request flang-compiler/f18#607 from flang-compiler/jpr-fix-594
Fix issue 594 and add a derived type component visitor framework

Original-commit: flang-compiler/f18@009db27bfa
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
2019-08-08 01:55:50 -07:00
Jean Perier
edab0a0ebb [flang] copyright update
Original-commit: flang-compiler/f18@e724438925
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
2019-07-31 10:30:42 -07:00
Jean Perier
965d114d8c [flang] use newly added DEREF in component iterator
Original-commit: flang-compiler/f18@2185f20009
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 08:56:25 -07:00
Jean Perier
153892dd66 [flang] Checkpoint: derived type component iterators
Original-commit: flang-compiler/f18@72d209bb52
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 07:26:26 -07:00
Jean Perier
0a9725607b [flang] Improve error messages about component types in allocate checks
Use component visitor framework to attach more information reagrding
where is the ultimate/potential component that is forbidden.
Also remove unused functions.

Original-commit: flang-compiler/f18@4619c5860a
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 07:26:24 -07:00
Jean Perier
b08064ca1f [flang] Do not die on typeless source expression in allocate.
While fixing 594, it appears the CHECK in allocate for non null
expression type pointer was too harsh as it could be a user error.
e.g: a boz used as source.

Original-commit: flang-compiler/f18@cbacdeaa0e
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 07:26:23 -07:00
Jean Perier
06a90e3a0c [flang] Add a derived type component visitor framework
After fixing 594, it appears there were issues in
FindUltimateComponent that was considering type bound
procedure as components.
This commit fixes and beef-up the component visitation by making a visitor
class for it. The main advantage of making it an class vs functions is that
it is possible to get the component chain to the result component for better
feedback for the user.
The framework allow a single place to define/handle what ultimate, direct and
potential components are.

Original-commit: flang-compiler/f18@d84821a1d6
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 07:26:18 -07:00
Jean Perier
1ac6396248 [flang] Fix issue 594
Add ProcBindingDetails to handling GetType.
Also add HostAssocDetails to be consitent with UseDetails handling
in this GetType.

Original-commit: flang-compiler/f18@b498aab15f
Reviewed-on: https://github.com/flang-compiler/f18/pull/607
Tree-same-pre-rewrite: false
2019-07-31 07:26:17 -07:00
Steve Scalpone
56eb30bb86 [flang] Merge pull request flang-compiler/f18#584 from CarolineConcatto/block_construct_patch
Adding semantic checks for Block Construct

Original-commit: flang-compiler/f18@47781549a3
Reviewed-on: https://github.com/flang-compiler/f18/pull/584
2019-08-07 11:52:11 -07:00
Caroline Concatto
f4a6fe026d [flang] Removing TODO comments as they are implemented by this patch
Original-commit: flang-compiler/f18@885eb92b4f
Reviewed-on: https://github.com/flang-compiler/f18/pull/584
2019-08-07 08:48:31 +01:00
Caroline Concatto
7aaf74c1bc [flang] Removing two sentence error
Original-commit: flang-compiler/f18@fd5aafc5af
Reviewed-on: https://github.com/flang-compiler/f18/pull/584
Tree-same-pre-rewrite: false
2019-08-06 09:26:40 +01:00
Caroline Concatto
23b0337598 [flang] Changes in SaveStmt message for Common Block name specifier
Original-commit: flang-compiler/f18@2e63705f5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/584
Tree-same-pre-rewrite: false
2019-07-23 10:36:47 +01:00
Caroline Concatto
6975bc3dd4 [flang] Changes requested by the comunity
Original-commit: flang-compiler/f18@309dd0fdfe
Reviewed-on: https://github.com/flang-compiler/f18/pull/584
Tree-same-pre-rewrite: false
2019-07-22 15:35:51 +01:00
Caroline Concatto
b8b0c82a18 [flang] Adding semantic checks for Block Construct
Original-commit: flang-compiler/f18@e626f431d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/584
Tree-same-pre-rewrite: false
2019-07-17 14:15:30 +01:00
Tim Keith
00b5ab683f [flang] Merge pull request flang-compiler/f18#630 from flang-compiler/tsk-array-spec
Perform more checks on array-specs

Original-commit: flang-compiler/f18@14a38209a9
Reviewed-on: https://github.com/flang-compiler/f18/pull/630
2019-08-07 11:18:50 -07:00
Tim Keith
050a921aaf [flang] Fix errors in tests and predefined modules
There were many places in tests and predefined modules that had
incorrect code that we weren't detecting until now.

Most of the problems were deferred-shape arrays that should have
been implied-shape. For example:
`real, parameter :: a(:) = [1.0, 2.0]`
should have `(*)` rather than `(:)`.

There were also a few places with deferred-shape arrays that were
not allocatable/pointer or explicit-shape ones that were.

Original-commit: flang-compiler/f18@0a959ce1d8
Reviewed-on: https://github.com/flang-compiler/f18/pull/630
2019-08-07 10:51:35 -07:00
Tim Keith
a5f6fa6b2e [flang] Improve failure message from test_modfile.sh
When test_modfile.sh fails a test, show the path to the source file
so it is easier to find the problems when grepping the log.

Original-commit: flang-compiler/f18@4a0d0d19a0
Reviewed-on: https://github.com/flang-compiler/f18/pull/630
Tree-same-pre-rewrite: false
2019-08-07 10:51:35 -07:00
Tim Keith
4887ae80cd [flang] Perform more checks on array-specs
There are many constraints on what kind of array-specs can appear
in what contexts. Add `CheckArraySpec()` to perform most of them.
When the check fails, don't set the shape of the symbol being
declared and instead set the Error flag so we can avoid cascading
errors.

Fixes flang-compiler/f18#609.

Original-commit: flang-compiler/f18@f159d97f1f
Reviewed-on: https://github.com/flang-compiler/f18/pull/630
Tree-same-pre-rewrite: false
2019-08-07 10:51:19 -07:00
Tim Keith
331c04cce6 [flang] Change ArraySpec from a type alias to a class
This allows it to have member functions `Rank()`, `IsExplicitShape()`,
`IsAssumedShape()`, etc. Make use of those new functions and remove
`isExplicit()` and `isDeferred()` from `ShapeSpec` as they are no
longer needed.

Original-commit: flang-compiler/f18@7ef7ad6359
Reviewed-on: https://github.com/flang-compiler/f18/pull/630
Tree-same-pre-rewrite: false
2019-08-07 10:51:07 -07:00
Tim Keith
73738d8bba [flang] Change parsing of ambiguous array-spec
An array-spec like `(:,:)` (with one or more colons) is either a
deferred-shape-spec-list or an assumed-shape-spec-list and they
can only be distinguished by context that the parser doesn't have.

We were parsing these as assumed-shape-spec-list but they are easier
to deal with if we parse them as deferred-shape-spec-list because
anything that is the latter is also one of the former.

Original-commit: flang-compiler/f18@78c3f3b96f
Reviewed-on: https://github.com/flang-compiler/f18/pull/630
Tree-same-pre-rewrite: false
2019-08-07 10:49:54 -07:00
Tim Keith
80678685a3 [flang] Add operator<< for parser::CharBlock
Original-commit: flang-compiler/f18@439326dc96
Reviewed-on: https://github.com/flang-compiler/f18/pull/630
Tree-same-pre-rewrite: false
2019-08-07 10:49:54 -07:00
Peter Klausler
d1d63f3646 [flang] Merge pull request flang-compiler/f18#633 from flang-compiler/pmk-warnings
Dodge two bogus warnings from g++ 8.1

Original-commit: flang-compiler/f18@2aa98a9d4d
Reviewed-on: https://github.com/flang-compiler/f18/pull/633
2019-08-07 10:41:39 -07:00
peter klausler
58ea24d3e3 [flang] Dodge two bogus warnings from g++ 8.1
Original-commit: flang-compiler/f18@aa19aeb92a
Reviewed-on: https://github.com/flang-compiler/f18/pull/633
2019-08-07 09:18:20 -07:00
jeanPerier
180ba3354b [flang] Merge pull request flang-compiler/f18#615 from flang-compiler/jpr-fix-581
Fix issue 581: extended derived type kind parameter comparison 

Original-commit: flang-compiler/f18@4670ae020b
Reviewed-on: https://github.com/flang-compiler/f18/pull/615
2019-08-07 03:39:52 -07:00
Jean Perier
0e17c8aaac [flang] Answer comments
- make `TypaParamAttr` a `ParamValue` argument. Modify
  `GetParamValue` to also take this as an argument.
- remove `GetLenParamValue` that is now useless and
  modify constructor/`GetParamValue` calls
- get it the `TypeParamAttr` right from the begining
  when visiting `parser::DerivedTypeSpec` in resolve-names.cc.
  It was set to `Kind` by default and it was hard to ensure the
  attribute would not be checked until set properly.

Original-commit: flang-compiler/f18@bcc300e714
Reviewed-on: https://github.com/flang-compiler/f18/pull/615
2019-08-06 04:46:20 -07:00
Jean Perier
0eafca9759 [flang] Fix ParamValue attribute (kind/len) of implicit type parameters
While testing fix for issue 581 it appeared that 'ParamValue`
implicit len parameters had incorrect attribute kind.
This commit:
 + Set correct attribute when creating `ParamValue` for implicit
   type parameter.
 + Also set the correct attribute foe charachter lenght `ParamValue`
   though it is currently not used anywhere.
 + Change some std::int64_t to common::ConstantSubscript on the way.

Original-commit: flang-compiler/f18@57a344b256
Reviewed-on: https://github.com/flang-compiler/f18/pull/615
Tree-same-pre-rewrite: false
2019-08-06 04:46:19 -07:00
Jean Perier
ba7ed2722a [flang] Fix extended derived type kind compatibility check
`HaveCompatibleKindParameters` was not considering the kind
parameters of the parent types leading to false answers.
This change fixes this by directly looking into the map of `ParamValue`
of the `DeclTypeSpec` instead of going through the symbols of the derived
type scope. This map contains all the parent and implicit type parameters.

Original-commit: flang-compiler/f18@cd5b976fc9
Reviewed-on: https://github.com/flang-compiler/f18/pull/615
Tree-same-pre-rewrite: false
2019-08-06 04:46:18 -07:00
Jinxin (Brian) Yang
c4e13f6be8 [flang] [OpenMP] parse tree changes for standalone directives (flang-compiler/f18#627)
* [OpenMP] parse tree changes for standalone directives

1. Put all standalone directives except FLUSH, CANCEL, and CANCELLATION POINT
   into one `OpenMPSimpleStandaloneConstruct` (for no-clause directive,
   validity checks will be deferred to Semantics). A top-level class will
   include all the standalone directive nodes. This simplies the logic a lot.

2. All the standalone directives now have their own source provenance for
   directive name itself.

3. Change check-omp-structure.* to avoid assertions

4. Add basic tests for standalone directives, more will be added during
   the clause validity checks in Semantics

* Resolve !$OMP ORDERED ambiguity by attempting block construct first - Peter

Original-commit: flang-compiler/f18@a77aa7ed84
Reviewed-on: https://github.com/flang-compiler/f18/pull/627
2019-08-06 11:59:40 -07:00
psteinfeld
fb30d812e7 [flang] Merge pull request flang-compiler/f18#612 from flang-compiler/ps-c1130
Changes to enforce constraint C1130

Original-commit: flang-compiler/f18@88af7ce563
Reviewed-on: https://github.com/flang-compiler/f18/pull/612
2019-08-06 10:20:22 -07:00
Peter Steinfeld
c2a0096b88 [flang] Responses to review comments.
- dosemantics05.f90: Added tests for ASSOCIATE, BLOCK and SELECT TYPE statements and changed the error messages.
 - check-do.cc: Changed things so that FindScope() is only called once when DoConcurrentVariableEnforce is instantiated.  I changed the error message.  I changed the type and name of CS to be an std::set and be called SymbolContainer.
 - resolve-names.cc: I changed the Pre() function for parser::Statement to add the source range of a statement to both the current scope and all of its parents.  This fixed a problem with finding the current scope based on the source position.

Original-commit: flang-compiler/f18@085b2c18f3
Reviewed-on: https://github.com/flang-compiler/f18/pull/612
2019-08-05 13:37:03 -07:00
Peter Steinfeld
270ddf8436 [flang] Changes to enforce constraint C1130.
The constraint states that "If the locality-spec DEFAULT ( NONE ) appears in a DO CONCURRENT statement; a variable that is a local or construct entity of a scope containing the DO CONCURRENT construct; and that appears in the block of the construct; shall have its locality explicitly specified by that statement."

Here's a summary of the changes:
 - In check-do.cc: Implemented the function
   CheckDefaultNoneImpliesExplicitLocality() to do the checking.  This involved
   adding the class DoConcurrentVariableEnforce to walk the DO loop's block
   looking for variable names.  I also cleaned up the code a little in
   CheckDoExpression() and EnforceConcurrentLoopControl().
 - Added the test dosemantics05.f90

Original-commit: flang-compiler/f18@2369aa805e
Reviewed-on: https://github.com/flang-compiler/f18/pull/612
Tree-same-pre-rewrite: false
2019-08-05 13:37:03 -07:00
Peter Steinfeld
657dc60544 [flang] Noted the constraint being tested.
Original-commit: flang-compiler/f18@471aea65d8
Reviewed-on: https://github.com/flang-compiler/f18/pull/612
Tree-same-pre-rewrite: false
2019-08-05 13:37:02 -07:00
Jinxin (Brian) Yang
deae08c21e [flang] [OpenMP] parse tree changes for declarative directives (flang-compiler/f18#620)
1. Changes are to save provenance for directive names
2. check-omp-structure.* is updated to avoid assertion errors
3. Tests added now are only for the basic usages for the declarative directives,
   more complete examples will be added once we start implementing the semantics
   checks for declarative directives

Original-commit: flang-compiler/f18@433e274f68
Reviewed-on: https://github.com/flang-compiler/f18/pull/620
2019-08-05 14:51:02 -07:00
Peter Klausler
bd723f22d0 [flang] Merge pull request flang-compiler/f18#623 from flang-compiler/pmk-fixes
Implement features to resolve bugs flang-compiler/f18#621 and flang-compiler/f18#622

Original-commit: flang-compiler/f18@2cd989479c
Reviewed-on: https://github.com/flang-compiler/f18/pull/623
2019-08-05 13:19:29 -07:00
peter klausler
bef468fbfd [flang] Remove obsolete code
Original-commit: flang-compiler/f18@81a97453a8
Reviewed-on: https://github.com/flang-compiler/f18/pull/623
2019-08-05 12:47:43 -07:00
peter klausler
58f93ac714 [flang] Fold SIGN()
Original-commit: flang-compiler/f18@521a02ad51
Reviewed-on: https://github.com/flang-compiler/f18/pull/623
Tree-same-pre-rewrite: false
2019-08-05 12:44:36 -07:00
peter klausler
adf204a50e [flang] Fold DIGITS
Original-commit: flang-compiler/f18@6c9adff7a6
Reviewed-on: https://github.com/flang-compiler/f18/pull/623
Tree-same-pre-rewrite: false
2019-08-05 10:46:54 -07:00
peter klausler
97848749fa [flang] Add DIGITS to intrinsic function table; fix results of some others
Original-commit: flang-compiler/f18@6d5caef352
Reviewed-on: https://github.com/flang-compiler/f18/pull/623
Tree-same-pre-rewrite: false
2019-08-05 09:42:06 -07:00
Peter Klausler
43b5fc77ba [flang] Merge pull request flang-compiler/f18#619 from flang-compiler/klausler-patch-1
Update Extensions.md

Original-commit: flang-compiler/f18@6e4f320aeb
Reviewed-on: https://github.com/flang-compiler/f18/pull/619
2019-08-02 16:52:57 -07:00
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