Commit graph

521 commits

Author SHA1 Message Date
Tim Keith
0c575ed548 [flang] Implement writing of .mod files.
Module file writing is implemented in mod-file.cc. They need to be
written after all semantic checking. Until then, for testing, write
them out whenever names are resolved.

There is a header comment in the .mod files but it is mostly a
placeholder until we can read them in and do something with it.

Rename `Symbol::details<D>` to `Symbol::get<D>`. This asserts that the
details of the symbol match D and returns that type. But we need a way
to access the details as a variant as well (not just one of its types).
`details()` is the best name for that, especially as we already have
`set_details()`. Renaming the old `details` to `get` also better matches
`has` which is used to check which variant is present.

Original-commit: flang-compiler/f18@8d14be1a16
Reviewed-on: https://github.com/flang-compiler/f18/pull/126
Tree-same-pre-rewrite: false
2018-07-16 16:23:18 -07:00
peter klausler
296040aa96 [flang] Improve error recovery further, using a test case from Tim.
Original-commit: flang-compiler/f18@9ef79fa991
Reviewed-on: https://github.com/flang-compiler/f18/pull/123
2018-07-12 16:23:25 -07:00
peter klausler
2c1b7bfd14 [flang] Extend documentation on extensions.
Original-commit: flang-compiler/f18@672e468252
Reviewed-on: https://github.com/flang-compiler/f18/pull/122
2018-07-12 15:32:31 -07:00
peter klausler
18d58f9fb3 [flang] Tweak code for readability and maybe better performance.
Original-commit: flang-compiler/f18@e4d9b8587e
Reviewed-on: https://github.com/flang-compiler/f18/pull/122
Tree-same-pre-rewrite: false
2018-07-12 15:05:34 -07:00
peter klausler
3577ee5f5f [flang] More documentation. These changes fix two bugs noted in f18 issue#121.
Original-commit: flang-compiler/f18@f386472c5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/122
Tree-same-pre-rewrite: false
2018-07-12 14:58:06 -07:00
peter klausler
0b8d07cc42 [flang] Allow empty statements and improve error recovery error messages.
Original-commit: flang-compiler/f18@018e81e2c4
Reviewed-on: https://github.com/flang-compiler/f18/pull/122
Tree-same-pre-rewrite: false
2018-07-12 14:47:15 -07:00
Tim Keith
be886c18ac [flang] Sort enumerators in enum class Attr.
Original-commit: flang-compiler/f18@ce43e4e556
Reviewed-on: https://github.com/flang-compiler/f18/pull/120
2018-07-12 10:14:58 -07:00
Tim Keith
d42bb955a6 [flang] Support intent-stmt and resolve subprogram prefixes and suffixes.
Recognize `IntentStmt` and use `HandleAttributeStmt()` to implement it
as is done with other attribute statements. Add `Attr::INTENT_INOUT` as
a separate attribute for `INTENT(INOUT)`.

Collect attributes from the prefix and suffix of `FunctionStmt` and
`SubroutineStmt` (including `BIND(C)`) and set them on the subprogram
symbol.

Create a test for this using `test_symbol.sh`. It compiles with
`-funparse-with-symbols` and compares the output with the symbols in
comments in the input.

Change `test_errors.sh` to be similar to `test_symbol.sh`: check usage
and allow `F18` environment variable to override the path to the
compiler.

Original-commit: flang-compiler/f18@384828a22f
Reviewed-on: https://github.com/flang-compiler/f18/pull/120
Tree-same-pre-rewrite: false
2018-07-11 17:45:13 -07:00
peter klausler
bfc6c3b9ae [flang] Documentation
Original-commit: flang-compiler/f18@d2855c6474
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
2018-07-11 10:26:53 -07:00
peter klausler
148b7d1f4a [flang] merge and reformat
Original-commit: flang-compiler/f18@2e3d67aa79
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
Tree-same-pre-rewrite: false
2018-07-11 10:22:05 -07:00
peter klausler
a85fc58b93 [flang] correct typo in unparse.cc found in test
Original-commit: flang-compiler/f18@1aa60cccc4
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
Tree-same-pre-rewrite: false
2018-07-11 10:21:35 -07:00
peter klausler
d28adc2e7f [flang] Use braces for auto initialization in lib/common and lib/evaluate
Original-commit: flang-compiler/f18@b0d1dd434b
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
Tree-same-pre-rewrite: false
2018-07-11 10:21:34 -07:00
peter klausler
f147abdee2 [flang] Use braces in auto initializers.
Original-commit: flang-compiler/f18@b68fdff537
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
Tree-same-pre-rewrite: false
2018-07-11 10:21:32 -07:00
peter klausler
8d0f44fb91 [flang] Better error recovery (for a case from Tim) and fix a problem where context is lost.
Original-commit: flang-compiler/f18@522822fd5a
Reviewed-on: https://github.com/flang-compiler/f18/pull/118
2018-07-10 16:09:21 -07:00
peter klausler
ea08e1bc72 [flang] Extend documentation
Original-commit: flang-compiler/f18@ac375a00ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
2018-07-10 10:56:55 -07:00
peter klausler
b081bc9d04 [flang] Address review comments
Original-commit: flang-compiler/f18@9e59b9b79d
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-10 10:18:34 -07:00
peter klausler
10d54a505a [flang] Resolve build issues with older compilers.
Original-commit: flang-compiler/f18@d8723284d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:01 -07:00
peter klausler
74b12f1a31 [flang] Refine variable structure definitions, add references to Standard.
Original-commit: flang-compiler/f18@dbc6d45e02
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:01 -07:00
peter klausler
d218ddcae4 [flang] Start cleaning up for merging.
Original-commit: flang-compiler/f18@7355bd5b42
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:01 -07:00
peter klausler
e6fc51c731 [flang] Use Indirection. Get variables to work in int expressions.
Original-commit: flang-compiler/f18@1000717da8
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:00 -07:00
peter klausler
f8f98ca3b6 [flang] More abstraction in expressions.
Original-commit: flang-compiler/f18@2dc425acf5
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:00 -07:00
peter klausler
d7b3accb32 [flang] tweaks
Original-commit: flang-compiler/f18@624c1d2ec8
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:59 -07:00
peter klausler
897e78defb [flang] clean up dumping code
Original-commit: flang-compiler/f18@2969888360
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:58 -07:00
peter klausler
22786d89e4 [flang] Fix issue flang-compiler/f18#113.
Original-commit: flang-compiler/f18@835e51b6e6
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:58 -07:00
peter klausler
06fe266998 [flang] work on variables and traversal
Original-commit: flang-compiler/f18@432779b221
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:57 -07:00
peter klausler
4795738c40 [flang] Commit work in progress to branch for f18 repository move.
Original-commit: flang-compiler/f18@e0db6903c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:57 -07:00
Tim Keith
d7d69474c8 [flang] Fix bug recognizing derived type constructor call
A ProcedureDesignator is a derived type constructor call if the name
resolves to a derived type. We need to recognize it as such and not
report an error. It may be in another derived type so we have to call
FindSymbol() first to find the derived type.

Most of the diffs are due to `symbol` changing from a reference to a
pointer.

In this example we were reporting an error on the first `t1()` and
resolving the second as an external function call.
```
module m
  type :: t1
  end type
  type(t1) :: x = t1()
  type t2
    type(t1) :: y = t1()
  end type
end module
```

Original-commit: flang-compiler/f18@717b22ca2b
Reviewed-on: https://github.com/flang-compiler/f18/pull/116
2018-07-09 15:25:49 -07:00
Tim Keith
a39376c08b [flang] Add missing copyright.
Original-commit: flang-compiler/f18@cf7087b381
Reviewed-on: https://github.com/flang-compiler/f18/pull/114
2018-07-05 10:36:18 -07:00
Tim Keith
c0c19100be [flang] Check consistency of generic interfaces.
The specific procedures in a generic interface must be all functions or
all subroutines. If there is a derived type with the same name they can
only be functions.

Original-commit: flang-compiler/f18@e02cef047a
Reviewed-on: https://github.com/flang-compiler/f18/pull/114
Tree-same-pre-rewrite: false
2018-07-05 10:28:34 -07:00
Tim Keith
f77f9309fc [flang] Add -funparse-with-symbols to enable new behavior
Original-commit: flang-compiler/f18@7ad44e7e33
Reviewed-on: https://github.com/flang-compiler/f18/pull/112
2018-06-26 15:40:52 -07:00
Tim Keith
89840b5087 [flang] Support unparse with symbol annotations.
When `-fdebug-dump-symbols` is supplied with `-funparse`, include symbol
information in comments in the Fortran output. This will be used for
testing to verify that correct symbols are defined and references in
the right place.

In `UnparseWithSymbols()`, walk the parse tree and collect symbol
definitions and references, organized by statement. When a symbol is
defined across several statement it is associated with the first.
The definition of implicitly defined symbols is associated with the
first reference.

To write out the symbol information, a new optional argument is added to
`Unparse()`: it is a function that is called immediately before each
statement is unparsed. We pass in a function that prints out the symbol
information collected for that statement.

Add `Symbol::GetType()` to make it easier to write the symbol types
and add `Symbol::SetType()` for uniformity.

Original-commit: flang-compiler/f18@2e827de4ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/112
Tree-same-pre-rewrite: false
2018-06-26 15:01:42 -07:00
peter klausler
97f0a05235 [flang] Incorporate suggestions from code review.
Original-commit: flang-compiler/f18@c66bd9ab15
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
2018-06-22 16:44:23 -07:00
peter klausler
cf410675cf [flang] Begin folding, with simple test, as sanity check on usability.
Original-commit: flang-compiler/f18@3839c65cd5
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:28 -07:00
peter klausler
efcbf1f7df [flang] clean up for push
Original-commit: flang-compiler/f18@8b5bbcedba
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:28 -07:00
peter klausler
4c11bc07d4 [flang] Prepare for check-in
Original-commit: flang-compiler/f18@2f5b2d5f40
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:28 -07:00
peter klausler
4da490882b [flang] Operator overloads for expression construction.
Original-commit: flang-compiler/f18@a4d3a736cf
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:27 -07:00
peter klausler
e5e5f6319f [flang] clean up clang warnings from master
Original-commit: flang-compiler/f18@1c9aa95f8d
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:25 -07:00
peter klausler
7a3f25ce8a [flang] More refinement, use const on subexpressions.
Original-commit: flang-compiler/f18@f484325c61
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:06 -07:00
peter klausler
953c667703 [flang] Simplification
Original-commit: flang-compiler/f18@a50ce6e499
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:06 -07:00
peter klausler
a55ea1b5d5 [flang] fix builds, all now clear
Original-commit: flang-compiler/f18@7c32a531a0
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:06 -07:00
peter klausler
4b3dea1d38 [flang] Dump complex expressions
Original-commit: flang-compiler/f18@da25b870d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:05 -07:00
peter klausler
32b2ce7282 [flang] More dumping code
Original-commit: flang-compiler/f18@43d147144a
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:05 -07:00
peter klausler
508ed8dd76 [flang] Use unique_ptr for operands. Refactor comparisons.
Original-commit: flang-compiler/f18@92e154e76e
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:05 -07:00
peter klausler
a88a55b500 [flang] Expression formatting
Original-commit: flang-compiler/f18@3d0977a57e
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:04 -07:00
peter klausler
dd5470b128 [flang] Change memcpy to memmove for overlap case.
Original-commit: flang-compiler/f18@cb400284e4
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:04 -07:00
peter klausler
9e1ba097f5 [flang] Numeric constant formatting and tests.
Original-commit: flang-compiler/f18@ade6442020
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:04 -07:00
peter klausler
3d867f3202 [flang] Character LEN, operator overloadings
Original-commit: flang-compiler/f18@08c32de24c
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:04 -07:00
peter klausler
229d6c413a [flang] Finish first cut at expression.h.
Original-commit: flang-compiler/f18@07142e7fad
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:18 -07:00
peter klausler
e03280c09c [flang] Expression work
Original-commit: flang-compiler/f18@b60c84fff4
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:17 -07:00
peter klausler
c2e06e25cd [flang] reformat c++
Original-commit: flang-compiler/f18@6c5c9b3165
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:17 -07:00