Commit graph

1150 commits

Author SHA1 Message Date
peter klausler
be3b765e2a [flang] basic skeleton of assignment analyzer
remove needless template<> on some function overloads

dodge bogus compiler warning from gcc 8.1.0 only

stricter typing of expressions in symbols

adjust modfile12.f90 expected test results

add Unwrap, massage folding a bit

Use Unwrap to simplify folding

Move KindSelector analysis into expression semantics

fix crash

checkpoint

updates to TypeParamInquiry

support of %KIND type parameter inquiry

equality testing for expressions

checkpoint during PDT implementation

reformat

checkpoint derived type instantiation

checkpoint

resolve merge

debugging failed tests

fix failing resolve37.f90 test

all existing tests pass

clean up all build warnings

fix bug

update copyright dates

fix copyright dates

address review comments

review comment

merge with master after peeling off changes

bugfixing new feature

fix warning from old g++s

tweaks after merging with latest head

more bugfixing

making modfile17.f90 test work

Make kinds into expressions in symbol table types

big refactor for deferring kinds in intrinsic types

modfile17.f90 test passes

clean up TODOs

Simplify types as stored in scopes

Test KIND parameter default init expressions, debug them

Update copyright dates

address comments

remove dead line

address comments

Original-commit: flang-compiler/f18@1f43d0a048
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
Tree-same-pre-rewrite: false
2019-01-17 10:41:08 -08:00
Tim Keith
3035fc25a7 [flang] Merge pull request flang-compiler/f18#262 from flang-compiler/tsk4
Fix link error from last integration

Original-commit: flang-compiler/f18@2d8c0f3e08
Reviewed-on: https://github.com/flang-compiler/f18/pull/262
2019-01-16 17:29:07 -08:00
Tim Keith
42d7ac3e36 [flang] Fix link error from last integration
We need to be able to analyze the `Variable` in a `Selector` and an
expression. That worked in a previous iteration of `expression.h` by
analyzing each variant of `Variable`.

This fix adds an explicit public function to analyze a Variable and
return a `MaybeExpr`.

Original-commit: flang-compiler/f18@9848a5d48f
Reviewed-on: https://github.com/flang-compiler/f18/pull/262
2019-01-16 17:18:10 -08:00
Tim Keith
9b7ce28e35 [flang] Merge pull request flang-compiler/f18#261 from flang-compiler/tsk2
Resolve names in ASSOCIATE and SELECT TYPE

Original-commit: flang-compiler/f18@2e6932fb4a
Reviewed-on: https://github.com/flang-compiler/f18/pull/261
2019-01-16 15:31:45 -08:00
Tim Keith
3020a18652 [flang] Fix typo
Original-commit: flang-compiler/f18@27af745986
Reviewed-on: https://github.com/flang-compiler/f18/pull/261
2019-01-16 13:21:15 -08:00
Tim Keith
ee28b70827 [flang] Resolve names in ASSOCIATE and SELECT TYPE
Create `AssocEntityDetails` for symbols that represent entities
identified by the associate-name in ASSOCIATE and SELECT TYPE
constructs.

For ASSOCIATE, create a new scope for the associated entity.
For SELECT TYPE, create a new scope for each of type guard blocks.
Each one contains an associated entity with the appropriate type.

For SELECT TYPE, also create a place-holder symbol for the
associate-name in the SELECT TYPE statement. The real symbols
are in the new scopes and none of them is uniquely identified
with the associate-name.

Handling of `Selector` is common between these, with
`associate-name => expr | variable` recorded in
`ConstructVisitor::association_`.

When the selector is an expression, derive the type of the associated
entity from the type of the expression. This required some refactoring
of how `DeclTypeSpec`s are created. The `DerivedTypeSpec` that comes
from and expression is const so we can only create const `DeclTypeSpec`s
from it. But there were times during name resolution when we needed to
set type parameters in the current `DeclTypeSpec`. Now the non-const
`DerivedTypeSpec` is saved separately from the const `DeclTypeSpec`
while we are processing a declaration type spec. This makes it
unnecessary to save the derived type name.

Add a type alias for `common::Indirection` to reduce verbosity.

Original-commit: flang-compiler/f18@b7668cebe4
Reviewed-on: https://github.com/flang-compiler/f18/pull/261
Tree-same-pre-rewrite: false
2019-01-15 16:59:20 -08:00
Eric Schweitz
6b678e48d8 [flang] Merge pull request flang-compiler/f18#259 from flang-compiler/eas2
Eas2

Original-commit: flang-compiler/f18@15fed72632
Reviewed-on: https://github.com/flang-compiler/f18/pull/259
2019-01-10 16:13:40 -08:00
Eric Schweitz
d1c5ae55aa [flang] changes per review comments
Original-commit: flang-compiler/f18@8a3b5b5953
Reviewed-on: https://github.com/flang-compiler/f18/pull/259
2019-01-10 12:13:45 -08:00
Eric Schweitz
349c623bba [flang] Fix typos on superscripts.
Original-commit: flang-compiler/f18@c9755c28f0
Reviewed-on: https://github.com/flang-compiler/f18/pull/259
Tree-same-pre-rewrite: false
2019-01-10 10:34:02 -08:00
Eric Schweitz
029b52a5e7 [flang] Add the Fortran IR document.
Original-commit: flang-compiler/f18@35a8c66e13
Reviewed-on: https://github.com/flang-compiler/f18/pull/259
Tree-same-pre-rewrite: false
2019-01-10 10:28:56 -08:00
Peter Klausler
409d26950b [flang] Merge pull request flang-compiler/f18#258 from flang-compiler/pmk1
cherrypick expression changes

Original-commit: flang-compiler/f18@470b03caee
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
2019-01-09 16:46:35 -08:00
peter klausler
70d7ab8789 [flang] address review comments
Original-commit: flang-compiler/f18@e770e52cb1
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
2019-01-09 16:39:58 -08:00
peter klausler
51dc18258b [flang] remove debugging output
Original-commit: flang-compiler/f18@3a156953c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
Tree-same-pre-rewrite: false
2019-01-09 15:13:23 -08:00
peter klausler
dc9faa270f [flang] cherrypick expression changes
Original-commit: flang-compiler/f18@427e267722
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
Tree-same-pre-rewrite: false
2019-01-09 15:06:07 -08:00
Tim Keith
003ab5d332 [flang] Merge pull request flang-compiler/f18#256 from flang-compiler/tsk6
More name resolution

Original-commit: flang-compiler/f18@3ea1c3bf4c
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
2019-01-08 14:21:28 -08:00
Tim Keith
7ec0830abd [flang] Resolve %kind and %len on intrinsic types
A `part-ref` can be `%kind` on an entity of any intrinsic type or
`%len` on a character entity. During name resolution, recognize these
and don't report an error as if they are component references.

Create symbols for these names as well as `%re` and `%im`. This is
partly for completeness so that we don't get warnings about unresolve
names. It also allows us to avoid having to do string comparisons on
these names in more than one place.

Rework `AnalyzeExpr` on structure components to make use of these
symbols and also not treat `%kind` and `%len` as derived type component
references.

Original-commit: flang-compiler/f18@65ae81ebac
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
2019-01-08 12:14:35 -08:00
Tim Keith
9ae71a0357 [flang] Fix crash evaluating kind expression
If we fail to evaluate the kind expression we were getting an invalid
optional reference. Instead, fail with an assert. This can happen if an
intrinsic function is not folded, but that will be implemented
eventually.

Original-commit: flang-compiler/f18@3bdbfc34bb
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tree-same-pre-rewrite: false
2019-01-08 12:14:35 -08:00
Tim Keith
44e7fee6d0 [flang] Bug fix: pass right value as MiscDetails::Kind
Original-commit: flang-compiler/f18@94d63399bd
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tree-same-pre-rewrite: false
2019-01-08 12:14:35 -08:00
Tim Keith
a1a55f007c [flang] Resolve name in PASS and BIND attributes
These are recognized along with other attributes and saved in
`passName_` and `bindName_`. The functions `SetPassNameOn()` and
`SetBindNameOn()` set them in a symbol if they are present.
They are also written to `.mod` files.

Add `MakePlaceholder()` to make symbols for names that otherwise
wouldn't have one. This allows us to assign a symbol to every name
and report errors for those that don't have one. Make use of this
for PASS names, which don't have explicit symbols.

Change `ObjectEntityDetails` and `ProcEntityDetails` to be sub-classes
of `EntityDetails`. They each contain a superset of the information in
`EntityDetails` so this reduces some duplication.

Original-commit: flang-compiler/f18@404c920840
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tree-same-pre-rewrite: false
2019-01-08 12:14:35 -08:00
Peter Klausler
845e02d1e1 [flang] Merge pull request flang-compiler/f18#248 from pjh40/pjh2
Define non-inline versions of ExpressionBase::derived()

Original-commit: flang-compiler/f18@f78bba7490
Reviewed-on: https://github.com/flang-compiler/f18/pull/248
2019-01-08 11:32:51 -08:00
Paul Henning
778e615158 [flang] Added preprocessor directives to limit the use of non-inline ExpressionBase<A>::derived to GCC on Mac (inlined on all other platforms)
Original-commit: flang-compiler/f18@b38b31909a
Reviewed-on: https://github.com/flang-compiler/f18/pull/248
2019-01-03 09:45:27 -07:00
Paul Henning
b61b31dfcd [flang] Addresses issue flang-compiler/f18#242 by making non-inline definitions for the two versions
of ExpressionBase::derived().  gcc-8.2 on macOS was choosing to create
non-inline instances of derived() during the explicit instantiations of
ExpressionBase in expression.cc and fold.cc.  During linking of any
executable, the linker failed when it found these duplicate definitions.

While this solution works, it removes the opportunity to inline the trivial
derived() functions.  Another solution would be to make all of the
templates related to ExpressionBase in expression.cc and fold.cc available
in a single .cc file, where the explicit instantiation
FOR_EACH_TYPE_AND_KIND(template class ExpressionBase) is done once. This
approach would allow inlining, but require something like template
implementation headers that could be included into the instantiation .cc
file.

Original-commit: flang-compiler/f18@074de39418
Reviewed-on: https://github.com/flang-compiler/f18/pull/248
Tree-same-pre-rewrite: false
2018-12-20 10:39:29 -07:00
Peter Klausler
eef439577c [flang] Merge pull request flang-compiler/f18#255 from flang-compiler/pmk1
Minor clean-up after a merge

Original-commit: flang-compiler/f18@4bd4a2045f
Reviewed-on: https://github.com/flang-compiler/f18/pull/255
2019-01-08 10:50:12 -08:00
peter klausler
4d115f2383 [flang] Restore readability improvement from code review comment that did not make it into a merge into master, and repair expected test results.
Original-commit: flang-compiler/f18@4f1946765e
Reviewed-on: https://github.com/flang-compiler/f18/pull/255
2019-01-08 09:56:57 -08:00
peter klausler
7e837d117f [flang] address review comment
Original-commit: flang-compiler/f18@3542f64813
Reviewed-on: https://github.com/flang-compiler/f18/pull/255
Tree-same-pre-rewrite: false
2019-01-07 17:01:49 -08:00
Peter Klausler
7673e0944c [flang] Merge pull request flang-compiler/f18#254 from flang-compiler/pmk3
Roll up small tweaks to parser and semantics.

Original-commit: flang-compiler/f18@36601dd6ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/254
2019-01-07 16:45:08 -08:00
peter klausler
e30ef0ec8d [flang] Roll up small tweaks to parser and semantics.
Original-commit: flang-compiler/f18@57d823a809
Reviewed-on: https://github.com/flang-compiler/f18/pull/254
2019-01-07 15:38:48 -08:00
Peter Klausler
8416801439 [flang] Merge pull request flang-compiler/f18#253 from flang-compiler/pmk1
Symbol changes for PDT instantiation

Original-commit: flang-compiler/f18@d3c16c6a80
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
2019-01-07 16:44:42 -08:00
peter klausler
5cf5315343 [flang] fold analyzed bounds expressions
Original-commit: flang-compiler/f18@17810319ae
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
2019-01-07 16:31:59 -08:00
peter klausler
e760aaa4e6 [flang] fix copyright dates
Original-commit: flang-compiler/f18@75818658d9
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
Tree-same-pre-rewrite: false
2019-01-07 15:50:04 -08:00
peter klausler
e828e0c795 [flang] Update copyright dates.
Original-commit: flang-compiler/f18@8a7722621b
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
Tree-same-pre-rewrite: false
2019-01-07 15:42:36 -08:00
peter klausler
32ba1a4a8c [flang] fix comment
Original-commit: flang-compiler/f18@2b06aff9b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
Tree-same-pre-rewrite: false
2019-01-07 15:20:57 -08:00
peter klausler
13ed85789d [flang] Symbol changes for PDT instantiation
Original-commit: flang-compiler/f18@0c545a026d
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
Tree-same-pre-rewrite: false
2019-01-07 15:05:53 -08:00
Peter Klausler
d3e451365f [flang] Merge pull request flang-compiler/f18#252 from flang-compiler/pmk3
Roll up folding & expression changes

Original-commit: flang-compiler/f18@608139c160
Reviewed-on: https://github.com/flang-compiler/f18/pull/252
2019-01-07 10:55:40 -08:00
peter klausler
67f13efa44 [flang] update copyright dates
Original-commit: flang-compiler/f18@99f4c98ccb
Reviewed-on: https://github.com/flang-compiler/f18/pull/252
2019-01-07 10:55:09 -08:00
peter klausler
fe3acf5ffc [flang] Roll up folding & expression changes
Original-commit: flang-compiler/f18@60affece05
Reviewed-on: https://github.com/flang-compiler/f18/pull/252
Tree-same-pre-rewrite: false
2019-01-07 10:15:27 -08:00
Peter Klausler
0a810d5207 [flang] Merge pull request flang-compiler/f18#251 from flang-compiler/pmk3
Support operator== for expressions.

Original-commit: flang-compiler/f18@b43f5fa583
Reviewed-on: https://github.com/flang-compiler/f18/pull/251
2019-01-04 14:35:05 -08:00
peter klausler
2ad9986698 [flang] Support operator== for expressions.
Original-commit: flang-compiler/f18@42013513e9
Reviewed-on: https://github.com/flang-compiler/f18/pull/251
2019-01-04 14:05:53 -08:00
Peter Klausler
b45b098d0f [flang] Merge pull request flang-compiler/f18#250 from flang-compiler/pmk1
Change expression constraint checking

Original-commit: flang-compiler/f18@c40ce62f12
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
2018-12-28 16:54:57 -08:00
peter klausler
d1d894c907 [flang] final clean-up
Original-commit: flang-compiler/f18@b971754a20
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
2018-12-28 16:52:57 -08:00
peter klausler
7187fbcc6d [flang] Remove a little now-dead code.
Original-commit: flang-compiler/f18@f000fb974c
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
Tree-same-pre-rewrite: false
2018-12-28 16:36:46 -08:00
peter klausler
c6df6af013 [flang] update error message texts in test
Original-commit: flang-compiler/f18@42c0d5d950
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
Tree-same-pre-rewrite: false
2018-12-28 16:01:46 -08:00
peter klausler
ee2a32e561 [flang] Rework expression constraint checking
Original-commit: flang-compiler/f18@7a31c1ed2b
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
Tree-same-pre-rewrite: false
2018-12-28 15:58:17 -08:00
Tim Keith
6fe4f5a732 [flang] Merge pull request flang-compiler/f18#249 from flang-compiler/tsk3
Various name resolution improvements

Original-commit: flang-compiler/f18@a7c41c0ccd
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
2018-12-28 10:33:51 -08:00
Tim Keith
8d959bb943 [flang] Add support for type-bound generics
Record the bindings in a symbol with GenericBindingDetails, including
bindings inherited from extended types. Check that they have consistent
accessibility.

Original-commit: flang-compiler/f18@0f780abcea
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
2018-12-26 14:31:26 -08:00
Tim Keith
37364331fb [flang] Handle structure constructor in entity-decl
As with array constructors, we can encounter a decl-type-spec for a
structure-constructor while the decl-type-spec for the
type-declaration-stmt is still active. So here too we need to save and
restore the state.

In this case, it is done in DeclarationVisitor, so add
SetDeclTypeSpecState() to get and set the state.

Example where this occurs:
```
type(t(2)) :: x = t(2)()
```

Original-commit: flang-compiler/f18@aa5ca8d7b2
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tree-same-pre-rewrite: false
2018-12-18 17:19:41 -08:00
Tim Keith
a7e91f2335 [flang] Fix bug making symbol for external procedure
When we encounter a ProcedureDesignator, if it is an external procedure
(i.e. there is no visible declaration) it must be implicitly created in
the global scope, not the current scope.

If there is already a symbol there (i.e. a module) it is an error, even
if that symbol is not visible due to an IMPORT statement.

Original-commit: flang-compiler/f18@835e234ded
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tree-same-pre-rewrite: false
2018-12-18 16:35:31 -08:00
Tim Keith
4f8d0d8d9b [flang] Handle array constructor in entity-decl
We can encounter a decl-type-spec for an array constructor while the
decl-type-spec for type-declaration-stmt is still active:
```
integer, allocatable :: a(:) = [integer :: 1, 2, 3]
```

To handle this, save the state of the current decl-type-spec while
processing the second one, then restore when done.

Original-commit: flang-compiler/f18@d125a0f612
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tree-same-pre-rewrite: false
2018-12-18 14:35:58 -08:00
Tim Keith
bc469ef570 [flang] Resolve names in ProcedureStmt and GenericStmt
We need to save the names of specific procedures that appear in a
ProcedureStmt or GenericStmt to resolve at the end of the specification
section. They may be forward references to interface bodies.

We were saving them in the GenericDetails but that was not the right
place: we need to save the parser::Name so that we can eventually
resolve it to a Symbol, but the symbol table should not contains
references to Name because they go away with the parse tree.

The fix is to save the mapping in a new multimap, specificProcs_ in
InterfaceVisitor. We can reference parser::Names there and resolve them
during ResolveSpecificsInGenerics(). We no longer need to clutter
GenericDetails with data structures for unresolved names.

Also handle the case where a specific procedure is use-associated from
another module.

Original-commit: flang-compiler/f18@c7f7b1e72d
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tree-same-pre-rewrite: false
2018-12-18 07:59:40 -08:00
Tim Keith
a040d7462e [flang] Merge pull request flang-compiler/f18#247 from flang-compiler/tsk3
Support character types

Original-commit: flang-compiler/f18@2884608901
Reviewed-on: https://github.com/flang-compiler/f18/pull/247
2018-12-18 07:45:39 -08:00