peter klausler [Sat, 19 Jan 2019 22:57:04 +0000 (14:57 -0800)]
[flang] Add SHARED to add_library() invocations so f18 libraries are always built shared.
Original-commit: flang-compiler/f18@
060ced04c74b8796c7621a29da86ee2051d3ccba
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
peter klausler [Sat, 19 Jan 2019 22:38:31 +0000 (14:38 -0800)]
[flang] Enable building f18 as shared libraries
Original-commit: flang-compiler/f18@
4544d75af1b45e4c554a35327461311cff974884
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
peter klausler [Fri, 18 Jan 2019 23:53:11 +0000 (15:53 -0800)]
[flang] Rearrange code to eliminate dependence cycles between f18 library binaries
Original-commit: flang-compiler/f18@
88651eecae9cf7d5ea698eabcb315b3f2f169485
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
peter klausler [Fri, 18 Jan 2019 20:40:47 +0000 (12:40 -0800)]
[flang] Move default intrinsic type kinds from lib/semantics to lib/common
Original-commit: flang-compiler/f18@
887e72dd613f411808d1b9e9e7b64601a3b67af8
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
Peter Klausler [Wed, 23 Jan 2019 00:24:58 +0000 (16:24 -0800)]
[flang] Merge pull request flang-compiler/f18#266 from flang-compiler/pmk-x86
Make x86 fp flag edge case behavior emulation conditional.
Original-commit: flang-compiler/f18@
f21c9427fcc8024c30ec70d0a2eb8926ad1bbe50
Reviewed-on: https://github.com/flang-compiler/f18/pull/266
peter klausler [Tue, 22 Jan 2019 19:13:44 +0000 (11:13 -0800)]
[flang] Make x86 fp behavior emulation conditional.
Original-commit: flang-compiler/f18@
0c77a634b328b310206ccb00d7f40fcc9178f121
Reviewed-on: https://github.com/flang-compiler/f18/pull/266
Peter Klausler [Tue, 22 Jan 2019 17:59:29 +0000 (09:59 -0800)]
[flang] Merge pull request flang-compiler/f18#264 from flang-compiler/pmk1
Fix crash reported by Jean in error recovery case
Original-commit: flang-compiler/f18@
e2117d367bc616f32639f1551db5f32fa5f6b49e
Reviewed-on: https://github.com/flang-compiler/f18/pull/264
peter klausler [Fri, 18 Jan 2019 19:47:16 +0000 (11:47 -0800)]
[flang] Fix crash reported by Jean in error recovery case
Original-commit: flang-compiler/f18@
33db1790be41cb7e905d4bd0acf90222ddaf27e1
Reviewed-on: https://github.com/flang-compiler/f18/pull/264
Peter Klausler [Fri, 18 Jan 2019 20:03:38 +0000 (12:03 -0800)]
[flang] Merge pull request flang-compiler/f18#260 from flang-compiler/pmk2
Complete parameterized derived type instantiation
Original-commit: flang-compiler/f18@
3ecceb30d7e408116078fa9c9c7a95ff810f4ba8
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
peter klausler [Fri, 18 Jan 2019 18:45:07 +0000 (10:45 -0800)]
[flang] fix clang build warning
Original-commit: flang-compiler/f18@
799fe63779206c19a9717e84678546f592d3218c
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
peter klausler [Fri, 18 Jan 2019 00:14:36 +0000 (16:14 -0800)]
[flang] done with merge
Original-commit: flang-compiler/f18@
9c63eb7a1a87bcd075938b4ec93a45ef5bd4c1bf
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
Tree-same-pre-rewrite: false
peter klausler [Thu, 17 Jan 2019 21:52:10 +0000 (13:52 -0800)]
[flang] merge with master, implement a TODO with LEN on ASSOCIATE
Original-commit: flang-compiler/f18@
e4501c6fa4e9819dd34c58f6d462c1482ea2332e
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
Tree-same-pre-rewrite: false
peter klausler [Tue, 4 Dec 2018 18:55:32 +0000 (10:55 -0800)]
[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@
1f43d0a04813dc02909e9952ee479d13f630df4c
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
Tree-same-pre-rewrite: false
Tim Keith [Thu, 17 Jan 2019 01:29:07 +0000 (17:29 -0800)]
[flang] Merge pull request flang-compiler/f18#262 from flang-compiler/tsk4
Fix link error from last integration
Original-commit: flang-compiler/f18@
2d8c0f3e08128f3bde3892dd8e508a8798eda377
Reviewed-on: https://github.com/flang-compiler/f18/pull/262
Tim Keith [Thu, 17 Jan 2019 01:18:10 +0000 (17:18 -0800)]
[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@
9848a5d48f61f969f11814749c517990f76f6b04
Reviewed-on: https://github.com/flang-compiler/f18/pull/262
Tim Keith [Wed, 16 Jan 2019 23:31:45 +0000 (15:31 -0800)]
[flang] Merge pull request flang-compiler/f18#261 from flang-compiler/tsk2
Resolve names in ASSOCIATE and SELECT TYPE
Original-commit: flang-compiler/f18@
2e6932fb4a275f75485fbf648abd751b8002fa90
Reviewed-on: https://github.com/flang-compiler/f18/pull/261
Tim Keith [Wed, 16 Jan 2019 21:21:15 +0000 (13:21 -0800)]
[flang] Fix typo
Original-commit: flang-compiler/f18@
27af745986699f6859580285dffedb917afe3a0b
Reviewed-on: https://github.com/flang-compiler/f18/pull/261
Tim Keith [Wed, 16 Jan 2019 00:59:20 +0000 (16:59 -0800)]
[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@
b7668cebe49a122ea23c89c81eafdeba243bbfaf
Reviewed-on: https://github.com/flang-compiler/f18/pull/261
Tree-same-pre-rewrite: false
Eric Schweitz [Fri, 11 Jan 2019 00:13:40 +0000 (16:13 -0800)]
[flang] Merge pull request flang-compiler/f18#259 from flang-compiler/eas2
Eas2
Original-commit: flang-compiler/f18@
15fed726326d226ebe2031a1ff3854b8a069251e
Reviewed-on: https://github.com/flang-compiler/f18/pull/259
Eric Schweitz [Thu, 10 Jan 2019 20:13:45 +0000 (12:13 -0800)]
[flang] changes per review comments
Original-commit: flang-compiler/f18@
8a3b5b595339e18634e870f42f5cd053187f89e0
Reviewed-on: https://github.com/flang-compiler/f18/pull/259
Eric Schweitz [Thu, 10 Jan 2019 18:34:02 +0000 (10:34 -0800)]
[flang] Fix typos on superscripts.
Original-commit: flang-compiler/f18@
c9755c28f06535a5f8fd78ff4a29b1d0a1ee7604
Reviewed-on: https://github.com/flang-compiler/f18/pull/259
Tree-same-pre-rewrite: false
Eric Schweitz [Thu, 10 Jan 2019 18:28:56 +0000 (10:28 -0800)]
[flang] Add the Fortran IR document.
Original-commit: flang-compiler/f18@
35a8c66e13d4e6f54fc7ead085ca7258f0a90099
Reviewed-on: https://github.com/flang-compiler/f18/pull/259
Tree-same-pre-rewrite: false
Peter Klausler [Thu, 10 Jan 2019 00:46:35 +0000 (16:46 -0800)]
[flang] Merge pull request flang-compiler/f18#258 from flang-compiler/pmk1
cherrypick expression changes
Original-commit: flang-compiler/f18@
470b03caee0faba437202648054a23642ea1b25d
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
peter klausler [Thu, 10 Jan 2019 00:39:58 +0000 (16:39 -0800)]
[flang] address review comments
Original-commit: flang-compiler/f18@
e770e52cb10d895f082d9991a756199dd1fd1e0d
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
peter klausler [Wed, 9 Jan 2019 23:13:23 +0000 (15:13 -0800)]
[flang] remove debugging output
Original-commit: flang-compiler/f18@
3a156953c211591cdda31b3eb8cc1fe40d18b84b
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
Tree-same-pre-rewrite: false
peter klausler [Wed, 9 Jan 2019 23:06:07 +0000 (15:06 -0800)]
[flang] cherrypick expression changes
Original-commit: flang-compiler/f18@
427e267722b01af6b0bc8b41a224d49334382a1a
Reviewed-on: https://github.com/flang-compiler/f18/pull/258
Tree-same-pre-rewrite: false
Tim Keith [Tue, 8 Jan 2019 22:21:28 +0000 (14:21 -0800)]
[flang] Merge pull request flang-compiler/f18#256 from flang-compiler/tsk6
More name resolution
Original-commit: flang-compiler/f18@
3ea1c3bf4c596a3e3c4eb42189148bd0c58b54ab
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tim Keith [Mon, 7 Jan 2019 21:31:50 +0000 (13:31 -0800)]
[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@
65ae81ebacbe75094d7ec7d83ae3a0f35eb591d2
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tim Keith [Mon, 7 Jan 2019 19:28:20 +0000 (11:28 -0800)]
[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@
3bdbfc34bb75e6585eea57aa3240c3c825fff704
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tree-same-pre-rewrite: false
Tim Keith [Mon, 7 Jan 2019 18:10:15 +0000 (10:10 -0800)]
[flang] Bug fix: pass right value as MiscDetails::Kind
Original-commit: flang-compiler/f18@
94d63399bdf5409d59107f6681905f60dfe2b639
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tree-same-pre-rewrite: false
Tim Keith [Sat, 5 Jan 2019 01:10:31 +0000 (17:10 -0800)]
[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@
404c920840880bf63bb3b0984cb0e1213057d619
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tree-same-pre-rewrite: false
Peter Klausler [Tue, 8 Jan 2019 19:32:51 +0000 (11:32 -0800)]
[flang] Merge pull request flang-compiler/f18#248 from pjh40/pjh2
Define non-inline versions of ExpressionBase::derived()
Original-commit: flang-compiler/f18@
f78bba7490417d0db547007ea2db990c46434936
Reviewed-on: https://github.com/flang-compiler/f18/pull/248
Paul Henning [Thu, 3 Jan 2019 16:45:27 +0000 (09:45 -0700)]
[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@
b38b31909a4d30e3cfd77353d44ecff06ef425da
Reviewed-on: https://github.com/flang-compiler/f18/pull/248
Paul Henning [Thu, 20 Dec 2018 17:39:29 +0000 (10:39 -0700)]
[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@
074de39418299e7e53b437adfbbc381004e0886e
Reviewed-on: https://github.com/flang-compiler/f18/pull/248
Tree-same-pre-rewrite: false
Peter Klausler [Tue, 8 Jan 2019 18:50:12 +0000 (10:50 -0800)]
[flang] Merge pull request flang-compiler/f18#255 from flang-compiler/pmk1
Minor clean-up after a merge
Original-commit: flang-compiler/f18@
4bd4a2045fbe4a12d69543ba23d59cf12f52e89b
Reviewed-on: https://github.com/flang-compiler/f18/pull/255
peter klausler [Tue, 8 Jan 2019 17:56:57 +0000 (09:56 -0800)]
[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@
4f1946765e5a3d6ad013e6342f3762d62a67f363
Reviewed-on: https://github.com/flang-compiler/f18/pull/255
peter klausler [Tue, 8 Jan 2019 00:46:11 +0000 (16:46 -0800)]
[flang] address review comment
Original-commit: flang-compiler/f18@
3542f648130a506428d340732f79c2250a91568f
Reviewed-on: https://github.com/flang-compiler/f18/pull/255
Tree-same-pre-rewrite: false
Peter Klausler [Tue, 8 Jan 2019 00:45:08 +0000 (16:45 -0800)]
[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@
36601dd6ecc6bd7955b6098ad5f00491ec79cec7
Reviewed-on: https://github.com/flang-compiler/f18/pull/254
peter klausler [Mon, 7 Jan 2019 23:38:48 +0000 (15:38 -0800)]
[flang] Roll up small tweaks to parser and semantics.
Original-commit: flang-compiler/f18@
57d823a8098d6e74965d6af43cd58077e6ffcea2
Reviewed-on: https://github.com/flang-compiler/f18/pull/254
Peter Klausler [Tue, 8 Jan 2019 00:44:42 +0000 (16:44 -0800)]
[flang] Merge pull request flang-compiler/f18#253 from flang-compiler/pmk1
Symbol changes for PDT instantiation
Original-commit: flang-compiler/f18@
d3c16c6a806becea2829928c499e948026579ecd
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
peter klausler [Tue, 8 Jan 2019 00:31:59 +0000 (16:31 -0800)]
[flang] fold analyzed bounds expressions
Original-commit: flang-compiler/f18@
17810319ae0236045c510c2c25d23a6fc32956ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
peter klausler [Mon, 7 Jan 2019 23:50:04 +0000 (15:50 -0800)]
[flang] fix copyright dates
Original-commit: flang-compiler/f18@
75818658d973abbae9cca646a1d6db1cfac591f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
Tree-same-pre-rewrite: false
peter klausler [Mon, 7 Jan 2019 23:42:36 +0000 (15:42 -0800)]
[flang] Update copyright dates.
Original-commit: flang-compiler/f18@
8a7722621b29a551d564231c4734f0b42689ac8f
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
Tree-same-pre-rewrite: false
peter klausler [Mon, 7 Jan 2019 23:20:57 +0000 (15:20 -0800)]
[flang] fix comment
Original-commit: flang-compiler/f18@
2b06aff9b4134d22ea2d9b2c03fa2846ed132a65
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
Tree-same-pre-rewrite: false
peter klausler [Mon, 7 Jan 2019 23:05:53 +0000 (15:05 -0800)]
[flang] Symbol changes for PDT instantiation
Original-commit: flang-compiler/f18@
0c545a026d02955bffade6d15d3776c1de1b182e
Reviewed-on: https://github.com/flang-compiler/f18/pull/253
Tree-same-pre-rewrite: false
Peter Klausler [Mon, 7 Jan 2019 18:55:40 +0000 (10:55 -0800)]
[flang] Merge pull request flang-compiler/f18#252 from flang-compiler/pmk3
Roll up folding & expression changes
Original-commit: flang-compiler/f18@
608139c1606b00a25c3e127d6237e74a2b74d81b
Reviewed-on: https://github.com/flang-compiler/f18/pull/252
peter klausler [Mon, 7 Jan 2019 18:55:09 +0000 (10:55 -0800)]
[flang] update copyright dates
Original-commit: flang-compiler/f18@
99f4c98ccb750b7ea534f459aaef7c6ce5c245a2
Reviewed-on: https://github.com/flang-compiler/f18/pull/252
peter klausler [Mon, 7 Jan 2019 18:15:27 +0000 (10:15 -0800)]
[flang] Roll up folding & expression changes
Original-commit: flang-compiler/f18@
60affece05d4793bc81dcab36106790d02bb40cb
Reviewed-on: https://github.com/flang-compiler/f18/pull/252
Tree-same-pre-rewrite: false
Peter Klausler [Fri, 4 Jan 2019 22:35:05 +0000 (14:35 -0800)]
[flang] Merge pull request flang-compiler/f18#251 from flang-compiler/pmk3
Support operator== for expressions.
Original-commit: flang-compiler/f18@
b43f5fa5839230f0adb667ee47bc627427148cbe
Reviewed-on: https://github.com/flang-compiler/f18/pull/251
peter klausler [Fri, 4 Jan 2019 22:05:53 +0000 (14:05 -0800)]
[flang] Support operator== for expressions.
Original-commit: flang-compiler/f18@
42013513e9477d9c97c20c7e5ae01a485bb7d7e3
Reviewed-on: https://github.com/flang-compiler/f18/pull/251
Peter Klausler [Sat, 29 Dec 2018 00:54:57 +0000 (16:54 -0800)]
[flang] Merge pull request flang-compiler/f18#250 from flang-compiler/pmk1
Change expression constraint checking
Original-commit: flang-compiler/f18@
c40ce62f12a6c62406327d576479d375708fd284
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
peter klausler [Sat, 29 Dec 2018 00:52:57 +0000 (16:52 -0800)]
[flang] final clean-up
Original-commit: flang-compiler/f18@
b971754a20d7f922598cef28fe5862776e8e5c89
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
peter klausler [Sat, 29 Dec 2018 00:36:46 +0000 (16:36 -0800)]
[flang] Remove a little now-dead code.
Original-commit: flang-compiler/f18@
f000fb974c992ac4e68ace562ecd9db23b9a8b46
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
Tree-same-pre-rewrite: false
peter klausler [Sat, 29 Dec 2018 00:01:46 +0000 (16:01 -0800)]
[flang] update error message texts in test
Original-commit: flang-compiler/f18@
42c0d5d950aba45b5ed0463345d5508631648b03
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
Tree-same-pre-rewrite: false
peter klausler [Fri, 28 Dec 2018 23:58:17 +0000 (15:58 -0800)]
[flang] Rework expression constraint checking
Original-commit: flang-compiler/f18@
7a31c1ed2ba3c57575d3bd98f6b13dfc94a07af0
Reviewed-on: https://github.com/flang-compiler/f18/pull/250
Tree-same-pre-rewrite: false
Tim Keith [Fri, 28 Dec 2018 18:33:51 +0000 (10:33 -0800)]
[flang] Merge pull request flang-compiler/f18#249 from flang-compiler/tsk3
Various name resolution improvements
Original-commit: flang-compiler/f18@
a7c41c0ccdf0131d75cdd8c6165153c23e73b62b
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tim Keith [Wed, 26 Dec 2018 21:31:13 +0000 (13:31 -0800)]
[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@
0f780abcea829d807493cf6a71eab9d8cffd4673
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tim Keith [Wed, 19 Dec 2018 01:19:41 +0000 (17:19 -0800)]
[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@
aa5ca8d7b21d75ecd3c66a59589efd3ebb66af48
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tree-same-pre-rewrite: false
Tim Keith [Wed, 19 Dec 2018 00:35:31 +0000 (16:35 -0800)]
[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@
835e234ded3f4f9b47565c46fcbf42e25e966550
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tree-same-pre-rewrite: false
Tim Keith [Tue, 18 Dec 2018 22:35:58 +0000 (14:35 -0800)]
[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@
d125a0f612a320bd6faa103665ddfe0cb48199d9
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tree-same-pre-rewrite: false
Tim Keith [Tue, 18 Dec 2018 15:59:40 +0000 (07:59 -0800)]
[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@
c7f7b1e72da58a125fcc9ca6ea9cb23a8d4a1c6c
Reviewed-on: https://github.com/flang-compiler/f18/pull/249
Tree-same-pre-rewrite: false
Tim Keith [Tue, 18 Dec 2018 15:45:39 +0000 (07:45 -0800)]
[flang] Merge pull request flang-compiler/f18#247 from flang-compiler/tsk3
Support character types
Original-commit: flang-compiler/f18@
2884608901c4cced1f3860058afca832499bb218
Reviewed-on: https://github.com/flang-compiler/f18/pull/247
Tim Keith [Tue, 18 Dec 2018 01:22:42 +0000 (17:22 -0800)]
[flang] Handle TypeStar and ClassStar in GetSymbolType()
Add DeclTypeSpec::AsDerived() to get the DerivedTypeSpec from a
DeclTypeSpec when it has one.
Original-commit: flang-compiler/f18@
3bd921d8f365e9fb1422aec96d02b9ec333c4d68
Reviewed-on: https://github.com/flang-compiler/f18/pull/247
Tim Keith [Mon, 17 Dec 2018 23:46:30 +0000 (15:46 -0800)]
[flang] Treat CHARACTER like other intrinsic types with default kind
Character decl-type-specs with no kind specified had no kind written to
the .mod file. That was different from the other intrinsic types which
always have an explicit type. This change make character like the other
intrinsic types.
Original-commit: flang-compiler/f18@
5b4f047a13c76e56579c1f06dbdf7b74358f16aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/247
Tree-same-pre-rewrite: false
Tim Keith [Mon, 17 Dec 2018 23:19:11 +0000 (15:19 -0800)]
[flang] Simplify creation of Expr values from ints.
Original-commit: flang-compiler/f18@
56f007493bdc74d155d85cfaa96166907a17c54a
Reviewed-on: https://github.com/flang-compiler/f18/pull/247
Tree-same-pre-rewrite: false
Tim Keith [Mon, 17 Dec 2018 20:41:43 +0000 (12:41 -0800)]
[flang] Refactoring: improve some names
IntrinsicTypeSpec was used for all intrinsics except for character.
Change it to be a common base class for NumericTypeSpec,
LogicalTypeSpec, and CharacterTypeSpec.
Change DeclTypeSpec to categorize the intrinsics as Numeric, Logical,
and Character. Add some utility methods: AsIntrinsic() and IsNumeric().
In scope.h, give the functions that create DeclTypeSpecs better names.
In semantics.h, replace MakeIntrinsicTypeSpec() with MakeNumericType()
and MakeLogicalType() as it does not apply to character types.
Original-commit: flang-compiler/f18@
8ad92d069c5ac56a9610937e5669848b67664203
Reviewed-on: https://github.com/flang-compiler/f18/pull/247
Tree-same-pre-rewrite: false
Tim Keith [Fri, 14 Dec 2018 22:04:15 +0000 (14:04 -0800)]
[flang] Add support for character type specs
Recognize the various ways of specifying character lengths.
Define CharacterTypeSpec with length and kind and store them in the
current scope, as is done with DerivedTypeSpec (which can also have
length parameters).
Note: IntrinsicTypeSpec is no longer used for characters, so it
should have a different name. Similarly, in DeclTypeSpec::Category,
Intrinsic does not include Character.
Original-commit: flang-compiler/f18@
5f847851933b27dd30bd8165d16a7c390e787b9a
Reviewed-on: https://github.com/flang-compiler/f18/pull/247
Tree-same-pre-rewrite: false
Tim Keith [Tue, 11 Dec 2018 22:51:08 +0000 (14:51 -0800)]
[flang] Rework how DeclTypeSpecs are stored
Now DeclTypeSpecs are stored in the scope so that they remain available
as long as the scope exists. DeclTypeSpecs for intrinsic types are
stored in the global scope; those for derived types are in the current
scope. They can contains type parameter values so they can't be reused.
Add `Semantics::MakeIntrinsicTypeSpec` to simplify creating
DeclTypeSpecs for intrinsic types.
Replace `std::optional<DeclTypeSpec>` with `DeclTypeSpec *` as they do
not need to be copied around.
Also fix a small bug with writing `class(t(...))` to the module file --
the type parameters were missing.
Original-commit: flang-compiler/f18@
e4744418fc1cdc9728bba4b9ecde51cb5bdd2efa
Reviewed-on: https://github.com/flang-compiler/f18/pull/247
Tree-same-pre-rewrite: false
Peter Klausler [Mon, 17 Dec 2018 18:21:25 +0000 (10:21 -0800)]
[flang] Merge pull request flang-compiler/f18#244 from flang-compiler/pmk1
fix bug noticed by Jean
Original-commit: flang-compiler/f18@
c4c54f05f3a5aba2d9c429cb99d22f57dfdb8541
Reviewed-on: https://github.com/flang-compiler/f18/pull/244
peter klausler [Fri, 14 Dec 2018 19:07:12 +0000 (11:07 -0800)]
[flang] fix bug noticed by Jean
Original-commit: flang-compiler/f18@
9acbff7585fbc113391066e5e79c1059c0e22d54
Reviewed-on: https://github.com/flang-compiler/f18/pull/244
Peter Klausler [Fri, 14 Dec 2018 21:18:21 +0000 (13:18 -0800)]
[flang] Merge pull request flang-compiler/f18#245 from flang-compiler/pmk3
fix crash that Tim ran into
Original-commit: flang-compiler/f18@
d7e914719e7ab9851c9d8e9127930c77f0ce47a2
Reviewed-on: https://github.com/flang-compiler/f18/pull/245
peter klausler [Fri, 14 Dec 2018 19:23:14 +0000 (11:23 -0800)]
[flang] fix crash that Tim ran into
Original-commit: flang-compiler/f18@
498a8c6fb82be85a60d8ccb18e398c6a3336a035
Reviewed-on: https://github.com/flang-compiler/f18/pull/245
Peter Klausler [Fri, 14 Dec 2018 21:17:16 +0000 (13:17 -0800)]
[flang] Merge pull request flang-compiler/f18#246 from flang-compiler/pmk4
add Unwrap
Original-commit: flang-compiler/f18@
7516db24478835ea75e9e2082e8d71e9dd6ec15d
Reviewed-on: https://github.com/flang-compiler/f18/pull/246
peter klausler [Fri, 14 Dec 2018 19:33:32 +0000 (11:33 -0800)]
[flang] add Unwrap
Original-commit: flang-compiler/f18@
3003363a2d5644a4c4ce1fc93f04ac70b7e2fe38
Reviewed-on: https://github.com/flang-compiler/f18/pull/246
Peter Klausler [Tue, 11 Dec 2018 22:48:25 +0000 (14:48 -0800)]
[flang] Merge pull request flang-compiler/f18#243 from flang-compiler/pmk3
Strengthen FORALL scoping check
Original-commit: flang-compiler/f18@
0eac648123d00383bfe9acc8e828cdd05dc41c83
Reviewed-on: https://github.com/flang-compiler/f18/pull/243
peter klausler [Tue, 11 Dec 2018 22:40:01 +0000 (14:40 -0800)]
[flang] improve test
Original-commit: flang-compiler/f18@
cfcf9dae4d9268c84baaf87ab1bb85832f100f07
Reviewed-on: https://github.com/flang-compiler/f18/pull/243
peter klausler [Tue, 11 Dec 2018 22:14:24 +0000 (14:14 -0800)]
[flang] revert obsolete tweak
Original-commit: flang-compiler/f18@
9b679e34dc09da9765b2e6e9fb5b16e2bb327246
Reviewed-on: https://github.com/flang-compiler/f18/pull/243
Tree-same-pre-rewrite: false
peter klausler [Tue, 11 Dec 2018 22:03:55 +0000 (14:03 -0800)]
[flang] Strengthen FORALL scoping check
Original-commit: flang-compiler/f18@
e57eb413145080cbd1d055d2a359493f7bcfc24f
Reviewed-on: https://github.com/flang-compiler/f18/pull/243
Tree-same-pre-rewrite: false
Peter Klausler [Tue, 11 Dec 2018 22:26:50 +0000 (14:26 -0800)]
[flang] Merge pull request flang-compiler/f18#241 from flang-compiler/pmk1
More precise locations for construct name errors; some refactoring
Original-commit: flang-compiler/f18@
e41c76cf766eb1d40808b23a548c2c8b87e09a22
Reviewed-on: https://github.com/flang-compiler/f18/pull/241
peter klausler [Mon, 10 Dec 2018 18:12:11 +0000 (10:12 -0800)]
[flang] reflect review comment
Original-commit: flang-compiler/f18@
6f26bfb905a98266485ee59c6b461d30b801f3ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/241
peter klausler [Sat, 8 Dec 2018 01:03:55 +0000 (17:03 -0800)]
[flang] delete unused private member to silence clang warning
Original-commit: flang-compiler/f18@
d3c5caab3449d36880128a641af5858891897b96
Reviewed-on: https://github.com/flang-compiler/f18/pull/241
Tree-same-pre-rewrite: false
peter klausler [Sat, 8 Dec 2018 00:39:22 +0000 (16:39 -0800)]
[flang] More precise locations for construct name errors; some refactoring
Original-commit: flang-compiler/f18@
2f35605d205531b5584355a97c639c4b4611d53d
Reviewed-on: https://github.com/flang-compiler/f18/pull/241
Tree-same-pre-rewrite: false
Tim Keith [Fri, 7 Dec 2018 19:58:12 +0000 (11:58 -0800)]
[flang] Merge pull request flang-compiler/f18#239 from flang-compiler/tsk1
Preserve order of type parameters
Original-commit: flang-compiler/f18@
83fa2376fdc4374bc655285cc4367b2a0f0367f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/239
Tim Keith [Fri, 7 Dec 2018 01:52:43 +0000 (17:52 -0800)]
[flang] Preserve order of type parameters
Type parameters were sorted by the order of the type-param-def-stmts.
But we need to preserve the order of the type-param-name-list.
The is the order of positional parameters in a derived-type-spec.
So add `paramNames` to `DerivedTypeDetails` to preserve the original
order. Using this allows us to write module files with both the
type-param-name-list and type-param-def-stmts in the original order.
Also fix a bug where a duplicate type-param-def caused a spurious
extra error. If `MakeTypeSymbol()` reports an error we should not
call `SetType()` because it will just report another error.
Original-commit: flang-compiler/f18@
3ca55b63333db3d779fe263583e3cb9fe7f4b2b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/239
Tim Keith [Fri, 7 Dec 2018 18:09:51 +0000 (10:09 -0800)]
[flang] Merge pull request flang-compiler/f18#240 from flang-compiler/tsk10
Fix bug converting actual argument to Fortran
Original-commit: flang-compiler/f18@
b529f20ca3b9df397af814f6e2ad646a9e7b2f80
Reviewed-on: https://github.com/flang-compiler/f18/pull/240
Tim Keith [Fri, 7 Dec 2018 15:41:49 +0000 (07:41 -0800)]
[flang] Fix bug converting actual argument to Fortran
This fixes a problem with converting the ubound call in the example
below back to Fortran (in this case, for writing to the .mod file).
One of the ActualArguments encountered in ProcedureRef::AsFortran is
a `std::nullopt`, so we need to handle that case.
```
module m
real :: x(10)
real :: y(ubound(x, dim=1))
end module
```
Original-commit: flang-compiler/f18@
c5ace6b8241cd1ef86f0649941bf38386d99bdc4
Reviewed-on: https://github.com/flang-compiler/f18/pull/240
Tim Keith [Thu, 6 Dec 2018 22:37:32 +0000 (14:37 -0800)]
[flang] Merge pull request flang-compiler/f18#238 from flang-compiler/tsk11
Rework expression evaluation in symbol table
Original-commit: flang-compiler/f18@
0e91bd34729d4d718887b70a09a40f7a97aecc50
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
Tim Keith [Thu, 6 Dec 2018 14:59:37 +0000 (06:59 -0800)]
[flang] Rework when symbol table expressions are evaluated
It's not good enough to evaluate expressions in the symbol table after
name resolution has completed. This is because we need the values of
constant expressions for types, for example, we need to evaluate `k` in
`integer(k) :: x` to know the type of `x`.
So, eliminate `LazyExpr` and call `EvaluateExpr()` on expressions that
we need in the symbol table. The latter evaluates and folds an
expression in the current context. This is now possible because symbols
are added to `parser::Name` as soon as possible rather than in a pass
after name resolution. Along with `LazyExpr` we can eliminate the whole
`ResolveSymbolExprs` pass that used to resolve them.
In resolve-names.cc, many `Pre` functions are changed to `Post` so that
names are resolved before doing the associated processing. For example,
with intrinsic type specs, names in the kind expression must be resolved
before attempting to evaluate that expression.
In `GetSymbolType()` in type.cc, handle both `ObjectEntityDetails` and
`EntityDetails` by using `Symbol::GetType()`.
Add explicit declarations in label01.F90 because we can't handle
implicitly typed array bounds yet.
Original-commit: flang-compiler/f18@
d67716640baeedca150205f9f3845ceb5d2f6402
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
Tim Keith [Wed, 5 Dec 2018 21:11:55 +0000 (13:11 -0800)]
[flang] Fix error is Negation on integer
The minus sign was missing.
Original-commit: flang-compiler/f18@
5fa0a97de5dcdcfeecc3999a1f84dd7858f5b35c
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
Tree-same-pre-rewrite: false
Tim Keith [Sat, 17 Nov 2018 00:40:00 +0000 (16:40 -0800)]
[flang] Add common base class for context, Walk(), and Say()
We need access to the SemanticsContext and Walk() function everywhere,
so move them to a BaseVisitor, a base class at the root of the class
hierarchy.
Also move MessageHandler to be a data member of BaseVisitor and forward
Say calls to it.
Original-commit: flang-compiler/f18@
eb9adc342a5495b0070a14d163f55209c63623d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
Tree-same-pre-rewrite: false
Tim Keith [Fri, 16 Nov 2018 20:43:08 +0000 (12:43 -0800)]
[flang] Change when symbol is set in parser::Name
Rework how `parser::Name` is resolved to contain a `Symbol`. so that
constants in types can be evaluated. For example:
```
integer, parameter :: k = 8
integer(k) :: i
```
The old approach of collecting the symbols at the end of name resolution
and filling in the `parser::Name` does not work because the type of `i`
needs to be set in the symbol table.
The symbol field in `parser::Name` is now mutable so that we can set it
during name resolution. `RewriteParseTree` no longer needs to do that
(it still warns about unresolved ones), so it does not need to collect
symbols and fill them in. Consequently, we can eliminate "occurrences"
from symbols -- we just need the name where each is first defined.
This requires a lot of refactoring in `resolve-names.cc` to pass around
`parser::Name` rather than `SourceName` so that we can resolve the
name to a symbol.
Fix some bugs where we stored `SourceName *` instead of `SourceName`
in the symbol table. The pointers were into the parse tree, so they
were only valid as long as the parse tree was around. The symbol
table needs to remain valid longer than that, so the names need to
be copied. `parser::Name` is not used in the symbol table.
Eliminate `GenericSpec`. Currently all we need to do is to resolve
the kinds of GenericSpec that contain names.
Add `ScopeName` kind of `MiscDetails` for when we need a symbol in
the scope to match the name of the scope. For example, `module m`
cannot contain a declaration of a new `m`. Subprograms need real
details because they can be called recursively.
Fix output of partially resolved modules where we know it is a submodule
but have not yet resolved the ancestor.
Original-commit: flang-compiler/f18@
5c1a4b99d2421f5b32e83426488d3fdf7951cfba
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
Tree-same-pre-rewrite: false
Peter Klausler [Wed, 5 Dec 2018 21:36:03 +0000 (13:36 -0800)]
[flang] Merge pull request flang-compiler/f18#237 from flang-compiler/pmk1
Use `std::optional<>::value()` where appropriate in place of `operator*`.
Original-commit: flang-compiler/f18@
611ee9be5d610a6593072672b358f1ab038681ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/237
peter klausler [Wed, 5 Dec 2018 21:06:00 +0000 (13:06 -0800)]
[flang] one more file
Original-commit: flang-compiler/f18@
9d3f502e803ceb4a72f5ba9da9d54477656c8b1d
Reviewed-on: https://github.com/flang-compiler/f18/pull/237
peter klausler [Wed, 5 Dec 2018 21:03:39 +0000 (13:03 -0800)]
[flang] Use std::optional<>::value() where appropriate.
Original-commit: flang-compiler/f18@
4278b79b3dc3b73a8229a24d11d195015e7f2840
Reviewed-on: https://github.com/flang-compiler/f18/pull/237
Tree-same-pre-rewrite: false
Peter Klausler [Wed, 5 Dec 2018 00:39:33 +0000 (16:39 -0800)]
[flang] Merge pull request flang-compiler/f18#236 from flang-compiler/pmk1
work around template specialization problem
Original-commit: flang-compiler/f18@
d122b4e618111c05deb9abaadef6d636fa11a72c
Reviewed-on: https://github.com/flang-compiler/f18/pull/236
peter klausler [Tue, 4 Dec 2018 23:52:50 +0000 (15:52 -0800)]
[flang] work around template specialization problem
Original-commit: flang-compiler/f18@
1d67d72bea24a4ade66920527d2cc9104d2dfd48
Reviewed-on: https://github.com/flang-compiler/f18/pull/236
Peter Klausler [Tue, 4 Dec 2018 18:51:41 +0000 (10:51 -0800)]
[flang] Merge pull request flang-compiler/f18#235 from flang-compiler/pmk1
last minute changes for recent PR that were not pushed, sorry
Original-commit: flang-compiler/f18@
f9ee3753ea1e151ddfe56a0db37aa9e69626da7f
Reviewed-on: https://github.com/flang-compiler/f18/pull/235
peter klausler [Tue, 4 Dec 2018 18:21:38 +0000 (10:21 -0800)]
[flang] last minute changes for recent PR that were not pushed, sorry
Original-commit: flang-compiler/f18@
9f9258e0067bfe9406f61f5f67d37b54f004e266
Reviewed-on: https://github.com/flang-compiler/f18/pull/235
Peter Klausler [Tue, 4 Dec 2018 18:18:10 +0000 (10:18 -0800)]
[flang] Merge pull request flang-compiler/f18#234 from flang-compiler/pmk0
Refactoring of expr analysis API and implementation
Original-commit: flang-compiler/f18@
2a1fb648d96811c4d7ee0177b17aed94b66e3077
Reviewed-on: https://github.com/flang-compiler/f18/pull/234
peter klausler [Tue, 4 Dec 2018 01:20:28 +0000 (17:20 -0800)]
[flang] fixes
Original-commit: flang-compiler/f18@
d312b2298a36c5676fdac66ec2acbf188dd80f4d
Reviewed-on: https://github.com/flang-compiler/f18/pull/234