Commit graph

129 commits

Author SHA1 Message Date
peter klausler
9e9b9f0776 [flang] Pass tests
Original-commit: flang-compiler/f18@ffb057f262
Reviewed-on: https://github.com/flang-compiler/f18/pull/371
Tree-same-pre-rewrite: false
2019-04-01 12:30:08 -07:00
peter klausler
822810f017 [flang] Check int literals for overflow when kind is known.
improve test

Original-commit: flang-compiler/f18@09ce783cd3
Reviewed-on: https://github.com/flang-compiler/f18/pull/352
Tree-same-pre-rewrite: false
2019-04-01 10:14:16 -07:00
peter klausler
dfc1643f3f [flang] get clean compile
Original-commit: flang-compiler/f18@3a606d804d
Reviewed-on: https://github.com/flang-compiler/f18/pull/346
Tree-same-pre-rewrite: false
2019-03-20 13:44:00 -07:00
peter klausler
7c71e2f288 [flang] Fix parse of .TRUE._8
Original-commit: flang-compiler/f18@b03e7a691d
Reviewed-on: https://github.com/flang-compiler/f18/pull/336
2019-03-17 15:51:02 -07:00
peter klausler
615ba7754b [flang] Move dump-parse-tree.h from semantics into parser.
Original-commit: flang-compiler/f18@9075adfcdf
Reviewed-on: https://github.com/flang-compiler/f18/pull/330
Tree-same-pre-rewrite: false
2019-03-14 16:28:06 -07:00
peter klausler
c57fda817e [flang] Address review comment
Original-commit: flang-compiler/f18@8a9a41487e
Reviewed-on: https://github.com/flang-compiler/f18/pull/322
2019-03-09 10:25:08 -08:00
peter klausler
f3abed639d [flang] Fix misparsings of substrings in the parse tree, not in expressions.
Original-commit: flang-compiler/f18@53d0e26d92
Reviewed-on: https://github.com/flang-compiler/f18/pull/322
Tree-same-pre-rewrite: false
2019-03-09 10:25:07 -08:00
peter klausler
e3b632337d [flang] add structconst04.f90 test and fixes to pass it
Original-commit: flang-compiler/f18@d857c843f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/322
Tree-same-pre-rewrite: false
2019-03-09 10:25:07 -08:00
peter klausler
64ea462e3a [flang] Resolve misparse of structure constructor as function reference.
Original-commit: flang-compiler/f18@5b6b2540f6
Reviewed-on: https://github.com/flang-compiler/f18/pull/322
Tree-same-pre-rewrite: false
2019-03-09 10:25:06 -08:00
peter klausler
972b3af6d4 [flang] Rearrange/simplify expr analysis code
Original-commit: flang-compiler/f18@aa9f3a7cca
Reviewed-on: https://github.com/flang-compiler/f18/pull/320
2019-03-07 14:46:31 -08:00
Tim Keith
813e48dc21 [flang] Create framework for checking statement semantics
Add `SemanticsVisitor` as the visitor class to perform statement
semantics checks. Its template parameters are "checker" classes
that perform the checks. They have `Enter` and `Leave` functions
that are called for the corresponding parse tree nodes (`Enter`
before the children, `Leave` after). Unlike `Pre` and `Post` in
visitors they cannot prevent the parse tree walker from visiting
child nodes.

Existing checks have been incorporated into this framework:
- `ExprChecker` replaces `AnalyzeExpressions()`
- `AssignmentChecker` replaces `AnalyzeAssignments()`
- `DoConcurrentChecker` replaces `CheckDoConcurrentConstraints()`

Adding a new checker requires:
- defining the checker class:
  - with BaseChecker as virtual base class
  - constructible from `SemanticsContext`
  - with Enter/Leave functions for nodes of interest
- add the checker class to the template parameters of `StatementSemantics`

Because these checkers and also `ResolveNamesVisitor` require tracking
the current statement source location, that has been moved into
`SemanticsContext`. `ResolveNamesVisitor` and `SemanticsVisitor`
update the location when `Statement` nodes are encountered, making it
available for error messages.

`AnalyzeKindSelector()` now has access to the current statement through
the context and so no longer needs to have it passed in.

Test `assign01.f90` was added to verify that `AssignmentChecker` is
actually doing something.

Original-commit: flang-compiler/f18@3a222c3673
Reviewed-on: https://github.com/flang-compiler/f18/pull/315
Tree-same-pre-rewrite: false
2019-03-05 16:52:50 -08:00
peter klausler
6a0f9474ff [flang] Use value()/has_value() on Indirection class templates instead of operator*/operator->
Original-commit: flang-compiler/f18@a97f377ae6
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-05 12:28:08 -08:00
peter klausler
da2ebb6063 [flang] Improve error messages
Original-commit: flang-compiler/f18@4046134512
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:25 -08:00
peter klausler
8a57433273 [flang] C1594 constraint checking on pointer components in struct constructors
Original-commit: flang-compiler/f18@386cd8a9b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:24 -08:00
peter klausler
3edc423bf8 [flang] Add SetLength operator to make character length changes explicit
Original-commit: flang-compiler/f18@f2d751d8a6
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:23 -08:00
peter klausler
431b84880a [flang] snapshot of work in progress
Original-commit: flang-compiler/f18@56e83d4dd6
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:23 -08:00
peter klausler
402cc8c4e9 [flang] Represent NULL()
Original-commit: flang-compiler/f18@2c3368fb5f
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:23 -08:00
peter klausler
857da8cfe9 [flang] Type checking on values in structure components
Original-commit: flang-compiler/f18@bea98aeb96
Reviewed-on: https://github.com/flang-compiler/f18/pull/311
Tree-same-pre-rewrite: false
2019-03-04 16:30:22 -08:00
peter klausler
c7cfc3f357 [flang] Add ForwardReference<> + documentation + clean-up
Original-commit: flang-compiler/f18@09e9501951
Reviewed-on: https://github.com/flang-compiler/f18/pull/314
2019-03-04 15:15:08 -08:00
peter klausler
4eccba942e [flang] Clean up DynamicType, link it to symbol table character length
Original-commit: flang-compiler/f18@833f5f52e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/304
Tree-same-pre-rewrite: false
2019-02-26 16:21:28 -08:00
peter klausler
f953583dea [flang] checkpoint
Original-commit: flang-compiler/f18@4d907e3184
Reviewed-on: https://github.com/flang-compiler/f18/pull/304
Tree-same-pre-rewrite: false
2019-02-26 16:21:26 -08:00
peter klausler
ba56b913a4 [flang] checkpoint
Original-commit: flang-compiler/f18@e7b0f456c9
Reviewed-on: https://github.com/flang-compiler/f18/pull/304
Tree-same-pre-rewrite: false
2019-02-26 16:19:36 -08:00
peter klausler
475d72f8e6 [flang] push for review
Original-commit: flang-compiler/f18@17dc735911
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 14:26:23 -08:00
peter klausler
4417443be9 [flang] Fix CHECK() on wa22 by implementing PGI language extension
Original-commit: flang-compiler/f18@03fcb58977
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:29:10 -08:00
peter klausler
2f12ee4f52 [flang] complete transfer of struct constructor code to expression.cc
Original-commit: flang-compiler/f18@e6178b2fc7
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:29:07 -08:00
peter klausler
f5bc9fd1d1 [flang] checkpoint, much code moved out of name resolution
Original-commit: flang-compiler/f18@8a081e82fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:28:09 -08:00
peter klausler
5b79ffc5f6 [flang] checkpoint
Original-commit: flang-compiler/f18@156791b288
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:22:10 -08:00
peter klausler
4313f4c762 [flang] checkpoint array/struct constructor work
Original-commit: flang-compiler/f18@b0a574fa35
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:22:09 -08:00
Tim Keith
d396a8845b [flang] Resolve kind parameters on literal constants
When the kind parameter is a constant name, that name must be resolved.

Add `CheckIntrinsicKind` and `CheckIntrinsicSize` for common checking of
valid intrinsic kinds. Previous we had different forms of the error
message depending on the context ( "unsupported INTEGER(KIND=47)" and
"INTEGER(KIND=47) is not a supported type").

Report error for parameters without initialization where are they
declared (in `Post(EntityDecl)`) rather than where they are referenced
(in `AnalyzeExpr`).

Remove error message from `AnalyzeKindParam`: `AnalyzeExpr` will report
the error (e.g. not integer, not constant, etc.).

Remove "name was not resolved" error from `AnalyzeExpr`: it should be
reported by name resolution.

Original-commit: flang-compiler/f18@9b0a99ce66
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
2019-02-08 16:03:23 -08:00
peter klausler
56bf4f8e0f [flang] fix crash found by tim
Original-commit: flang-compiler/f18@c24120d811
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
2019-02-04 13:06:21 -08:00
peter klausler
6d8aecf981 [flang] Convert structs to classes, move some defs from variable.h to call.h
Original-commit: flang-compiler/f18@c877a34694
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 16:04:17 -08:00
peter klausler
140b4adcfe [flang] Address review comments, fix some f90_correct failures
Original-commit: flang-compiler/f18@e468f8cd54
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:37 -08:00
peter klausler
1c95fef459 [flang] pass tests
Original-commit: flang-compiler/f18@db22dc2294
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:35 -08:00
peter klausler
650b32ebfe [flang] support Constant arrays
Original-commit: flang-compiler/f18@a92d8a404f
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:32 -08:00
peter klausler
0ae3d43d76 [flang] Run expression semantic analysis with rest of semantics.
checkpoint array constructor semantics work

checkpoint

array constructors of lengthless intrinsic types

checkpoint

Correct ambiguous substring refs misparsed as array elements

Original-commit: flang-compiler/f18@2232549efe
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:28 -08:00
peter klausler
74a77dd2ed [flang] Use IEEE-754 terminology better: subnormal, not denormal(ized)
Original-commit: flang-compiler/f18@57b0ebb558
Reviewed-on: https://github.com/flang-compiler/f18/pull/273
2019-01-29 16:47:41 -08:00
peter klausler
a75f28a8a2 [flang] Fix crash reported by Jean in error recovery case
Original-commit: flang-compiler/f18@33db1790be
Reviewed-on: https://github.com/flang-compiler/f18/pull/264
2019-01-18 12:09:22 -08:00
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
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
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
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
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
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
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
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
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
8ae55f79bc [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@d67716640b
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
2018-12-06 07:16:52 -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