Commit graph

183 commits

Author SHA1 Message Date
Tim Keith 9f755666fb [flang] Add ENUM_CLASS to define enum class with ToString function.
This replaces DEFINE_NESTED_ENUM_CLASS in parse-tree.h but works
similarly. "ENUM_CLASS(Foo, A, B, C)" defined enum class Foo with
enumerators A, B, C. It also defines an overloading of EnumToString
that converts enumerators to their string representation.

Change unparse.cc to adapt to this change.

Make use of ENUM_CLASS in attr.h and attr.cc.

Original-commit: flang-compiler/f18@c45b8f172a
Reviewed-on: https://github.com/flang-compiler/f18/pull/31
2018-03-23 14:41:48 -07:00
Peter Klausler 43ac92e696 [flang] Merge pull request flang-compiler/f18#29 from ThePortlandGroup/pmk-prov
Source provenance ranges for statements and names, plus clean-up.

Original-commit: flang-compiler/f18@13d976bb0f
Reviewed-on: https://github.com/flang-compiler/f18/pull/29
2018-03-23 14:19:27 -07:00
peter klausler 938d1eba15 [flang] Disable code in development before merging into master.
Original-commit: flang-compiler/f18@f9484682d1
Reviewed-on: https://github.com/flang-compiler/f18/pull/29
2018-03-23 14:18:59 -07:00
peter klausler 24ca79adb8 [flang] Rebase and merge with current master branch.
Original-commit: flang-compiler/f18@71544b8462
Reviewed-on: https://github.com/flang-compiler/f18/pull/29
Tree-same-pre-rewrite: false
2018-03-23 14:02:11 -07:00
peter klausler 424ec7b35b [flang] Handle empty files gracefully.
Create interval.h.  Use std::size_t instead of bare size_t.  Redefine parser::Name to not be just a bare string.

Break out and rename CharBlock from token-sequence.h for use in the parse tree.

Incremental replacement of name strings with pointers to cooked characters.

Fix case sensitivity problem.

Use new CharBlock encoding to replace strings for real literal constants.

Normalized cooked character stream to lower case.

Simplify parsing now that cooked stream is lower case.  Replace Keyword in parse tree.

Add static_asserts to || and recovery parsers to enforce same result types.

Remove needless TODO comment inserted earlier.

Fix case conversion on prefixed character literals (f90_correct/dc04.f90).

Use CharBlock in user-state.h.

Complete transition from nextChar to nextCh (i.e., always use pointers).

Document extensions.  Begin work on compiler directive lines.

More documentation work.

Reformat prescan.cc.

More work on compiler directive scanning.

Original-commit: flang-compiler/f18@38d0404e16
Reviewed-on: https://github.com/flang-compiler/f18/pull/29
Tree-same-pre-rewrite: false
2018-03-23 13:32:55 -07:00
Tim Keith a91ad74d8e [flang] Merge pull request flang-compiler/f18#30 from ThePortlandGroup/tsk6
Partial implementation of Symbols and Scopes.

Original-commit: flang-compiler/f18@cd8bb82ecd
Reviewed-on: https://github.com/flang-compiler/f18/pull/30
2018-03-23 12:27:57 -07:00
Tim Keith d384116347 [flang] Address review comments.
Use "namespace Fortran::semantics".

Add helper MakeSymbol() functions to ResolveNameVisitor to make a symbol
in the current scope.

Start work on subroutines, similar to what's been done for functions.

Original-commit: flang-compiler/f18@afe84af1c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/30
2018-03-23 12:24:29 -07:00
Tim Keith a3de9d789c [flang] Partial implementation of Symbols and Scopes.
A Symbol consists of a common part (in class Symbol) containing name,
owner, attributes. Information for a specific kind of symbol is in a
variant containing one of the *Details classes. So the kind of symbol is
determined by the type of details class stored in the details_ variant.

For scopes there is a single Scope class with an enum indicating the
kind. So far there isn't a need for extra kind-specific details as with
Symbols but that could change. Symbols defined in a Scope are stored
there in a simple map.

resolve-names.cc is a partial implementation of a parse-tree walker that
resolves names to Symbols. Currently is only handles functions (which
introduce a new Scope) and entity-decls. The test-type executable was
reused as a driver for this to avoid the need for a new one.

Sample output is below. When each "end function" is encountered the
scope is dumped, which shows the symbols defined in it.

$ cat a.f90
pure integer(8) function foo(arg1, arg2) result(res)
  integer :: arg1
  real :: arg2
contains
  function bar(arg1)
    real :: bar
    real :: arg1
  end function
end function

$ Debug/tools/f18/test-type a.f90
Subprogram scope: 0 children
  arg1:  Entity type: REAL
  bar:  Entity type: REAL
Subprogram scope: 1 children
  arg1:  Entity type: INTEGER
  arg2:  Entity type: REAL
  bar:  Subprogram (arg1)
  foo:  Subprogram (arg1, arg2) result(res)
  res:  Entity type: INTEGER(8)

Original-commit: flang-compiler/f18@1cd2fbc04d
Reviewed-on: https://github.com/flang-compiler/f18/pull/30
Tree-same-pre-rewrite: false
2018-03-22 17:25:34 -07:00
Steve Scalpone c0e48be0dd [flang] Merge pull request flang-compiler/f18#28 from ThePortlandGroup/sjs-doc
Overview of scope creation and symbol resolution

Original-commit: flang-compiler/f18@fc901a48f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/28
2018-03-22 11:55:04 -07:00
Steve Scalpone a857f382ce [flang] Add 'todo' for the predefined scope
Incorporate review feedback; shorten long lines.

Original-commit: flang-compiler/f18@699fb076d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/28
2018-03-22 11:53:59 -07:00
Steve Scalpone 58074411eb [flang] Formatting changes
Original-commit: flang-compiler/f18@ac704fb586
Reviewed-on: https://github.com/flang-compiler/f18/pull/28
Tree-same-pre-rewrite: false
2018-03-21 22:45:43 -07:00
Steve Scalpone 54f101e05d [flang] Update formatting
Extract questions and rationals from the step-wise descriptions.

Original-commit: flang-compiler/f18@38f49e0894
Reviewed-on: https://github.com/flang-compiler/f18/pull/28
Tree-same-pre-rewrite: false
2018-03-21 22:42:05 -07:00
Steve Scalpone 87ecf37155 [flang] Add semantics documentation
Overview of scoping, symbols, and basic semantics.

Original-commit: flang-compiler/f18@b28880a361
Reviewed-on: https://github.com/flang-compiler/f18/pull/28
Tree-same-pre-rewrite: false
2018-03-20 15:47:52 -07:00
Peter Klausler 63b549bf36 [flang] Merge pull request flang-compiler/f18#26 from ThePortlandGroup/pmk-f90
More fixes for bugs found by running f90_correct tests.

Original-commit: flang-compiler/f18@5e27ec4ab9
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
2018-03-20 10:17:05 -07:00
peter klausler 92bcb7ceb2 [flang] Make unreadable code less so, per review comments.
Original-commit: flang-compiler/f18@78073c15a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
2018-03-19 16:17:23 -07:00
peter klausler 554a5641c4 [flang] Improve preprocessor error message provenances, pass f90_correct test pre21.
Original-commit: flang-compiler/f18@af5943e3bc
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
2018-03-19 11:48:49 -07:00
peter klausler 2bde61360e [flang] Pass as much of f90_correct as I think we can.
Original-commit: flang-compiler/f18@6d101d3ec8
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
2018-03-16 16:58:35 -07:00
peter klausler 0983fbc3d6 [flang] More f90_correct work.
Original-commit: flang-compiler/f18@92b68f705f
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
2018-03-16 16:13:49 -07:00
peter klausler ad4adc2d28 [flang] More f90_correct work.
Original-commit: flang-compiler/f18@442771db3c
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
2018-03-15 17:09:27 -07:00
peter klausler 4e02b9e4b0 [flang] Make previous commit more precise.
Original-commit: flang-compiler/f18@543da95754
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
2018-03-15 16:28:37 -07:00
peter klausler 2e5300ce4e [flang] Never emit :: when /-bracketed initializers appear on a type declaration stmt.
Original-commit: flang-compiler/f18@2ed327a4f8
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
2018-03-15 16:22:38 -07:00
peter klausler dcd094234c [flang] Unparsing fixes, PGF90 bug work-arounds.
Original-commit: flang-compiler/f18@c9c98c0e5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
2018-03-15 16:03:28 -07:00
peter klausler 4933243d3a [flang] Remove excess newlines from cooked source, no longer needed.
Original-commit: flang-compiler/f18@9330b0d7fd
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
2018-03-15 13:25:37 -07:00
Peter Klausler d96d2c4837 [flang] Merge pull request flang-compiler/f18#27 from ThePortlandGroup/pmk-doc
New documentation

Original-commit: flang-compiler/f18@e3886bac53
Reviewed-on: https://github.com/flang-compiler/f18/pull/27
2018-03-20 10:07:39 -07:00
peter klausler 393c441767 [flang] Extend documentation.
Original-commit: flang-compiler/f18@f090167356
Reviewed-on: https://github.com/flang-compiler/f18/pull/27
2018-03-20 09:58:45 -07:00
peter klausler 1a4662d6be [flang] Write documentation/preprocessing.md
Original-commit: flang-compiler/f18@4c8f4a97ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/27
Tree-same-pre-rewrite: false
2018-03-19 17:10:53 -07:00
peter klausler f123105c7a [flang] More typing into documentation/parsing.md
Original-commit: flang-compiler/f18@73f68d0ea1
Reviewed-on: https://github.com/flang-compiler/f18/pull/27
Tree-same-pre-rewrite: false
2018-03-19 15:30:32 -07:00
peter klausler 6e83386c78 [flang] Initial cut at documentation/parsing.md
Original-commit: flang-compiler/f18@5484515b09
Reviewed-on: https://github.com/flang-compiler/f18/pull/27
Tree-same-pre-rewrite: false
2018-03-19 15:17:32 -07:00
Peter Klausler cd99b3b048 [flang] Merge pull request flang-compiler/f18#25 from ThePortlandGroup/pmk-walk-unparse
Take flang-compiler/f18#2 on unparsing, now using the new parse tree walker.

Original-commit: flang-compiler/f18@1f6c2c390e
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
2018-03-15 12:25:20 -07:00
peter klausler cbf39d56d4 [flang] Do not forget to run the linker even if there was nothing to compile.
Original-commit: flang-compiler/f18@4f4f853e5b
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
2018-03-15 12:22:41 -07:00
peter klausler 42b72c46d1 [flang] Get clean parse-unparse-reparse-unparse on f90_correct too.
Original-commit: flang-compiler/f18@901a9e462c
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-15 10:59:46 -07:00
peter klausler ed5a6c9faf [flang] Fix regression from last commit on STAT=/ERRMSG=.
Original-commit: flang-compiler/f18@f031d07c30
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-14 17:07:15 -07:00
peter klausler 62d9cdd15c [flang] More f90 unparsing.
Original-commit: flang-compiler/f18@b9991c1a04
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-14 17:02:21 -07:00
peter klausler d71f3cf532 [flang] More unparsing.
Original-commit: flang-compiler/f18@a3ef9de518
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-14 16:31:41 -07:00
peter klausler b7cf512e0d [flang] Incorporate more code review comments, fix more f90.
Original-commit: flang-compiler/f18@2428121ab4
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-14 15:31:16 -07:00
peter klausler b28ea527b4 [flang] Address review comments. Add note to style guide condemning if((x=y)).
Original-commit: flang-compiler/f18@4ca8b8e514
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 17:20:40 -07:00
peter klausler 46c3538c7a [flang] Fix some F90 unparsings; address review comments.
Original-commit: flang-compiler/f18@af33f37600
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 17:11:26 -07:00
peter klausler d39a33f80c [flang] Start on f90_correct. Incorporate review comments.
Original-commit: flang-compiler/f18@3f8cecef8e
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 16:59:30 -07:00
peter klausler 47dbbda25d [flang] Bugfixing and review comments.
Original-commit: flang-compiler/f18@29cabc7100
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 16:47:48 -07:00
peter klausler 79d044e9b5 [flang] Take flang-compiler/f18#2 on unparsing, now using the new parse tree walker.
Clean out old data structure formatter.

Create stand-alone Parsing class to compose parts of the parser together.

Hello, world!

Better error recovery on command line errors.

Fix bugs from initial run at f77_correct.

Allow parentheses on PROGRAM statement.

Fix Hollerith scanning.

Remove REDIMENSION with good error recovery.

Fix new "spaces" parser, clean up calls to it.

Fix bugs exposed by in38.f90.

Escaped \a is not special to pgf90; get slashes around STRUCTURE name right.

Better multi-byte source encoding support in Hollerith.

Reformat C++.

More work on multi-byte source encoding.

Pass 219 tests in f77_correct, with good excuses for the rest.

Original-commit: flang-compiler/f18@8a1a0aa2dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 16:32:09 -07:00
Tim Keith 6fab60d6db [flang] Merge pull request flang-compiler/f18#23 from ThePortlandGroup/tsk4
Add MakeTypes to build types using visitor.

Original-commit: flang-compiler/f18@30a4b46d4b
Reviewed-on: https://github.com/flang-compiler/f18/pull/23
2018-03-01 18:09:18 -08:00
Tim Keith 01580dd19a [flang] Replace raw pointers with std::unique_ptr.
This simplifies the "delete and set to null" pattern to just a call to
reset(), and "assign and set to null" to a call to std::move.

The ideal would be a custom deleter that throws an error when an
implicit delete happens but not when reset() is called, but I'm not sure
that's possible.

Original-commit: flang-compiler/f18@f618fc729a
Reviewed-on: https://github.com/flang-compiler/f18/pull/23
2018-03-01 18:04:05 -08:00
Tim Keith 600788e5f7 [flang] Add MakeTypes to build types using visitor.
This replaces the manual walking code in test-type.cc. It walks the
parse tree and constructs DeclTypeSpec and DerivedTypeDef objects for
each type encountered. It's in a new file, make-types.cc, so that
failing compilations complete faster.

Handle more parts of derived type definitions.

Also some minor cleanups in type.h and type.cc.

Original-commit: flang-compiler/f18@859e7e2665
Reviewed-on: https://github.com/flang-compiler/f18/pull/23
Tree-same-pre-rewrite: false
2018-03-01 15:24:35 -08:00
Peter Klausler 801378a5f0 [flang] Merge pull request flang-compiler/f18#22 from ThePortlandGroup/pmk-fix2
Ensure that the parse tree visitation Walk template works on FORMAT.

Original-commit: flang-compiler/f18@e693dd320d
Reviewed-on: https://github.com/flang-compiler/f18/pull/22
2018-03-01 14:47:28 -08:00
peter klausler 20364f0351 [flang] Ensure that the parse tree visitation Walk template works on FORMAT.
The classes that were segregated into format-specification.h have
also been grouped into a new Fortran::format namespace.
Code added to tools/f18/f18.cc to run a minimal visitor over
the parse trees resulting from successful parses so that any
future build problems with Walk() will be caught earlier.

Rearrange Walk instances, keep format:: ones together.

Original-commit: flang-compiler/f18@685ddb91ce
Reviewed-on: https://github.com/flang-compiler/f18/pull/22
2018-03-01 13:35:58 -08:00
Peter Klausler c88b23e04e [flang] Merge pull request flang-compiler/f18#21 from ThePortlandGroup/pmk-fix
Fix parsing error on PROCEDURE statement in derived type definition.

Original-commit: flang-compiler/f18@e9c218df42
Reviewed-on: https://github.com/flang-compiler/f18/pull/21
2018-03-01 13:34:48 -08:00
peter klausler 1b0705ca0f [flang] Fix parsing error on PROCEDURE statement in derived type definition.
Improve error recovery in that context.

Original-commit: flang-compiler/f18@b9e48504e6
Reviewed-on: https://github.com/flang-compiler/f18/pull/21
2018-03-01 11:28:13 -08:00
Peter Klausler a4a355940c [flang] Merge pull request flang-compiler/f18#20 from ThePortlandGroup/pmk-traits
Trait-based parse tree traversal.

Original-commit: flang-compiler/f18@0f8a4aaf07
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
2018-02-28 14:59:03 -08:00
peter klausler aa3aad34ea [flang] Follow own new style rule about returns and elses.
Original-commit: flang-compiler/f18@665fdf72d1
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
2018-02-28 14:55:45 -08:00
peter klausler 65ed9e1dae [flang] Run clang-format.
Original-commit: flang-compiler/f18@cd52d99f21
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
Tree-same-pre-rewrite: false
2018-02-28 14:53:04 -08:00