Commit graph

1072 commits

Author SHA1 Message Date
Tim Keith
d7ba02ab8c [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@5c1a4b99d2
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
Tree-same-pre-rewrite: false
2018-12-06 07:16:52 -08:00
Peter Klausler
018d850af9 [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@611ee9be5d
Reviewed-on: https://github.com/flang-compiler/f18/pull/237
2018-12-05 13:36:03 -08:00
peter klausler
d5bb7c5888 [flang] one more file
Original-commit: flang-compiler/f18@9d3f502e80
Reviewed-on: https://github.com/flang-compiler/f18/pull/237
2018-12-05 13:06:00 -08:00
peter klausler
1b1f60ff50 [flang] Use std::optional<>::value() where appropriate.
Original-commit: flang-compiler/f18@4278b79b3d
Reviewed-on: https://github.com/flang-compiler/f18/pull/237
Tree-same-pre-rewrite: false
2018-12-05 13:03:39 -08:00
Peter Klausler
bf9d7ba483 [flang] Merge pull request flang-compiler/f18#236 from flang-compiler/pmk1
work around template specialization problem

Original-commit: flang-compiler/f18@d122b4e618
Reviewed-on: https://github.com/flang-compiler/f18/pull/236
2018-12-04 16:39:33 -08:00
peter klausler
d8f4072aba [flang] work around template specialization problem
Original-commit: flang-compiler/f18@1d67d72bea
Reviewed-on: https://github.com/flang-compiler/f18/pull/236
2018-12-04 15:52:50 -08:00
Peter Klausler
840acd5314 [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@f9ee3753ea
Reviewed-on: https://github.com/flang-compiler/f18/pull/235
2018-12-04 10:51:41 -08:00
peter klausler
46aee9943c [flang] last minute changes for recent PR that were not pushed, sorry
Original-commit: flang-compiler/f18@9f9258e006
Reviewed-on: https://github.com/flang-compiler/f18/pull/235
2018-12-04 10:21:38 -08:00
Peter Klausler
72dc00cdbd [flang] Merge pull request flang-compiler/f18#234 from flang-compiler/pmk0
Refactoring of expr analysis API and implementation

Original-commit: flang-compiler/f18@2a1fb648d9
Reviewed-on: https://github.com/flang-compiler/f18/pull/234
2018-12-04 10:18:10 -08:00
peter klausler
34642dab32 [flang] fixes
Original-commit: flang-compiler/f18@d312b2298a
Reviewed-on: https://github.com/flang-compiler/f18/pull/234
2018-12-03 17:20:28 -08:00
peter klausler
972e4b59d5 [flang] address review comments
Original-commit: flang-compiler/f18@2f4b7ac97c
Reviewed-on: https://github.com/flang-compiler/f18/pull/234
Tree-same-pre-rewrite: false
2018-12-03 16:44:25 -08:00
peter klausler
1089f0195c [flang] complete refactor of expression analysis api and impl
Original-commit: flang-compiler/f18@fc83cdeabb
Reviewed-on: https://github.com/flang-compiler/f18/pull/234
Tree-same-pre-rewrite: false
2018-12-03 11:40:53 -08:00
peter klausler
e5df69e965 [flang] checkpoint before another refactoring
Original-commit: flang-compiler/f18@033efb95c2
Reviewed-on: https://github.com/flang-compiler/f18/pull/234
Tree-same-pre-rewrite: false
2018-11-30 16:04:51 -08:00
peter klausler
4da74f5107 [flang] checkpoint
Original-commit: flang-compiler/f18@1c65ed9a6f
Reviewed-on: https://github.com/flang-compiler/f18/pull/234
Tree-same-pre-rewrite: false
2018-11-30 15:23:33 -08:00
peter klausler
659c32947c [flang] checkpoint during refactor
Original-commit: flang-compiler/f18@01fe82b95b
Reviewed-on: https://github.com/flang-compiler/f18/pull/234
Tree-same-pre-rewrite: false
2018-11-30 14:03:05 -08:00
Peter Klausler
3e5f360c9f [flang] Merge pull request flang-compiler/f18#233 from flang-compiler/pmk1
small TODO: eliminate per-specialization flag in expression type representation

Original-commit: flang-compiler/f18@03a2a10a48
Reviewed-on: https://github.com/flang-compiler/f18/pull/233
2018-11-29 13:39:51 -08:00
peter klausler
a0a60e8d6a [flang] address TODO: replace Type flag member with IsSpecificIntrinsicType<T> predicate
Original-commit: flang-compiler/f18@68b89c008f
Reviewed-on: https://github.com/flang-compiler/f18/pull/233
2018-11-29 10:25:46 -08:00
Tim Keith
ec2183cd75 [flang] Merge pull request flang-compiler/f18#230 from flang-compiler/tsk2
Add mapping of source location to Scope

Original-commit: flang-compiler/f18@bec1cfdc05
Reviewed-on: https://github.com/flang-compiler/f18/pull/230
2018-11-29 12:27:34 -08:00
Tim Keith
7704b1fcf9 [flang] Add ExtendToCover() to CharBlock and Interval
Use them in Scope::AddSourceRange().

Original-commit: flang-compiler/f18@ec2f6db46a
Reviewed-on: https://github.com/flang-compiler/f18/pull/230
2018-11-29 09:10:19 -08:00
Tim Keith
cef802b1b4 [flang] Add mapping of source location to Scope
Each Scope now tracks the source locations that it and its nested scopes
span. This is achieved by extending the source range of a scope for each
statement encountered while it is the current scope.

Semantics::FindScope maps a source location (from the cooked character
stream) to the narrowest scope that contains it.

Original-commit: flang-compiler/f18@7b4d2bb113
Reviewed-on: https://github.com/flang-compiler/f18/pull/230
Tree-same-pre-rewrite: false
2018-11-28 15:55:55 -08:00
Tim Keith
a640a8f0dd [flang] Merge pull request flang-compiler/f18#232 from flang-compiler/tsk9
Change formatting of common::visitors{}

Original-commit: flang-compiler/f18@a442658ec5
Reviewed-on: https://github.com/flang-compiler/f18/pull/232
2018-11-29 12:26:57 -08:00
Tim Keith
daa0b054ba [flang] Change formatting of common::visitors{}
Including a comma after the last lambda in a `common::visitors{}` list
causes clang-format to do a better job of formatting them.

Add that recommendation to C++style.md, insert the missing commas,
and reformat the changed files.

Original-commit: flang-compiler/f18@a2486ca3b6
Reviewed-on: https://github.com/flang-compiler/f18/pull/232
2018-11-29 09:27:34 -08:00
Peter Klausler
ffa47bfbeb [flang] Merge pull request flang-compiler/f18#231 from flang-compiler/pmk0
Lossless binary floating-point -> decimal, and correct decimal -> binary FP

Original-commit: flang-compiler/f18@57cf544a08
Reviewed-on: https://github.com/flang-compiler/f18/pull/231
2018-11-29 09:36:34 -08:00
peter klausler
8cb33d85a7 [flang] dodge gcc warning on test
Original-commit: flang-compiler/f18@10e9a82088
Reviewed-on: https://github.com/flang-compiler/f18/pull/231
2018-11-28 16:44:38 -08:00
peter klausler
2067929b5a [flang] tested
Original-commit: flang-compiler/f18@e77681a2ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/231
Tree-same-pre-rewrite: false
2018-11-28 16:20:16 -08:00
peter klausler
7f603f6e15 [flang] debugged full precision FP formatting
Original-commit: flang-compiler/f18@ac9a684b91
Reviewed-on: https://github.com/flang-compiler/f18/pull/231
Tree-same-pre-rewrite: false
2018-11-28 10:33:09 -08:00
peter klausler
2fe5b128bd [flang] debugging
Original-commit: flang-compiler/f18@9f30eac130
Reviewed-on: https://github.com/flang-compiler/f18/pull/231
Tree-same-pre-rewrite: false
2018-11-28 10:33:09 -08:00
peter klausler
1df60f3ceb [flang] initial exact decimal conversion code
Original-commit: flang-compiler/f18@a34afdc73b
Reviewed-on: https://github.com/flang-compiler/f18/pull/231
Tree-same-pre-rewrite: false
2018-11-28 10:33:08 -08:00
Peter Klausler
846f8c6cda [flang] Merge pull request flang-compiler/f18#229 from flang-compiler/pmk1
document C++17 feature usage

Original-commit: flang-compiler/f18@d1d18fad36
Reviewed-on: https://github.com/flang-compiler/f18/pull/229
2018-11-28 10:31:41 -08:00
peter klausler
6dd3b8b724 [flang] proofreading
Original-commit: flang-compiler/f18@2af5c40bc1
Reviewed-on: https://github.com/flang-compiler/f18/pull/229
2018-11-26 12:46:11 -08:00
peter klausler
d1cc618f2c [flang] document C++17 feature usage
Original-commit: flang-compiler/f18@40d84ca20f
Reviewed-on: https://github.com/flang-compiler/f18/pull/229
Tree-same-pre-rewrite: false
2018-11-26 12:42:11 -08:00
Peter Klausler
abe5168bdd [flang] Merge pull request flang-compiler/f18#228 from flang-compiler/pmk0
Extend `AnalyzeExpr` to handle wrapped expression parse trees

Original-commit: flang-compiler/f18@7ddf0c159f
Reviewed-on: https://github.com/flang-compiler/f18/pull/228
2018-11-19 14:49:57 -08:00
peter klausler
3fc0f54b24 [flang] Analyze wrapped expressions
Original-commit: flang-compiler/f18@b34db5d38f
Reviewed-on: https://github.com/flang-compiler/f18/pull/228
2018-11-19 11:14:41 -08:00
peter klausler
791ef8c407 [flang] fix comments
Original-commit: flang-compiler/f18@a01eaaacc2
Reviewed-on: https://github.com/flang-compiler/f18/pull/228
Tree-same-pre-rewrite: false
2018-11-19 10:29:35 -08:00
Peter Klausler
609d3824ff [flang] Merge pull request flang-compiler/f18#226 from flang-compiler/pmk2
fix issue#224

Original-commit: flang-compiler/f18@cd6e4f0ada
Reviewed-on: https://github.com/flang-compiler/f18/pull/226
2018-11-14 16:12:23 -08:00
peter klausler
ac9e17f4cf [flang] fix issue#224
Original-commit: flang-compiler/f18@c40e197c61
Reviewed-on: https://github.com/flang-compiler/f18/pull/226
2018-11-14 15:44:17 -08:00
Peter Klausler
a2983e9069 [flang] Merge pull request flang-compiler/f18#225 from flang-compiler/pmk1
Roll up a bunch of changes

Original-commit: flang-compiler/f18@9ad19cd892
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
2018-11-14 15:23:40 -08:00
peter klausler
aa34fc6042 [flang] review comments
Original-commit: flang-compiler/f18@32c02cb668
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
2018-11-14 14:35:10 -08:00
peter klausler
12b0f643ab [flang] bugfixing and review comments
Original-commit: flang-compiler/f18@6df4a52d6b
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-14 11:57:47 -08:00
peter klausler
972d2d52c5 [flang] bugfixing from regression testing
Original-commit: flang-compiler/f18@f1bcaa0292
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-14 11:12:09 -08:00
peter klausler
c41e8706d5 [flang] remove unused variable
Original-commit: flang-compiler/f18@64773cef2c
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-13 16:26:26 -08:00
peter klausler
a10b7bc006 [flang] revamp Real::Read(), use it for mutual testing of ScaledDecimals
Original-commit: flang-compiler/f18@a2054bb9df
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-13 16:02:52 -08:00
peter klausler
bf7c03dbfb [flang] binary->decimal conversion for module files
Original-commit: flang-compiler/f18@6364799e7a
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-13 11:29:54 -08:00
peter klausler
c4601e2bc2 [flang] save work in progress
Original-commit: flang-compiler/f18@98bac3d297
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-08 09:38:04 -08:00
peter klausler
4f6275a1f7 [flang] Rename Dump() as AsFortran(), tweak output for use in .mod files
Original-commit: flang-compiler/f18@4e9dd16d6a
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-08 09:38:03 -08:00
peter klausler
ef59a45f50 [flang] fix warning
Original-commit: flang-compiler/f18@92003070de
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-08 09:38:03 -08:00
peter klausler
10aa1eafa0 [flang] multi-byte character TODOs
Original-commit: flang-compiler/f18@3bd2d227dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-08 09:38:02 -08:00
peter klausler
4e56600a8a [flang] more substring clean-up
Original-commit: flang-compiler/f18@e1c19ccd16
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-08 09:38:02 -08:00
peter klausler
2b2ea8d1a5 [flang] documentation
Original-commit: flang-compiler/f18@92f0c397f6
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-08 09:38:01 -08:00
peter klausler
9ddf39811c [flang] documentation
Original-commit: flang-compiler/f18@9aba35a258
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-08 09:38:01 -08:00