Commit graph

205 commits

Author SHA1 Message Date
peter klausler 75b29335ab [flang] Clean out obsolete parsing code. Handle !cdir$ fixed and free in parser.
Work on scanning compiler directive lines.

Fix glitch in earlier change to parse-state.h.

Add ClassifyLine(), simplify some token sequence data lifetimes and interfaces.

Handle continued directives.  Obey !DIR$ FIXED and FREE in prescanner.

Some refactoring of TokenSequence API, then support initial directives (FIXED, FREE, IGNORE_TKR).

Fix !DIR$ IGNORE_TKR syntax, manual was wrong.

Debugging directive scanning & parsing.

Profiling-directed speed-up - do not map cooked source locations to Provenance until a Message is emitted.  Turn some non-nullable pointers into references.

Debugging.

Handle !DIR$ IVDEP too, it is in a test.

Accept directives in the execution part.

Original-commit: flang-compiler/f18@fb2ff367ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/34
Tree-same-pre-rewrite: false
2018-03-28 15:04:36 -07:00
Stephane Chauveau c90cffab34 [flang] Merge pull request flang-compiler/f18#24 from ThePortlandGroup/sch_sema
Add initial semantic analysis on statements

Original-commit: flang-compiler/f18@68bb9f670d
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
2018-03-26 16:35:34 +02:00
Stephane Chauveau 8391357e5e [flang] Merge branch 'sch_sema' of https://github.com/ThePortlandGroup/f18 into sch_sema
Conflicts:
	lib/parser/parse-tree.h
	lib/semantics/CMakeLists.txt
	tools/f18/CMakeLists.txt
	tools/f18/test-sema.cc

Original-commit: flang-compiler/f18@2282b5759b
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
2018-03-26 16:35:34 +02:00
Stephane Chauveau f5b3f10622 [flang] Remove files in include/flang/Sema/
Original-commit: flang-compiler/f18@7791319414
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau f49e2dfa2a [flang] Merge with current master and move code to lib/semantics/
Original-commit: flang-compiler/f18@8b31a01102
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 934b518443 [flang] commit before rebase master
Original-commit: flang-compiler/f18@77f6a25f8a
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau eb766702f1 [flang] Commit changes made while at Portland. Some of them will disapear
Original-commit: flang-compiler/f18@0972ffe185
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau a7cf13c738 [flang] Provide an emacs style for editing Flang C++ sources
Original-commit: flang-compiler/f18@e9922dda1d
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 6ef4d355c8 [flang] remove long comment
Original-commit: flang-compiler/f18@c20912629b
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 99dd6d03de [flang] several changes following pull comments
Original-commit: flang-compiler/f18@ba1275a7cb
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau b65824fb32 [flang] Implement dump of parse-tree
Original-commit: flang-compiler/f18@ca6dbfc477
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 43591d3010 [flang] remove unused member
Original-commit: flang-compiler/f18@1d39fd8c5f
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 4c025af548 [flang] Mostly code cleanup
Original-commit: flang-compiler/f18@f78fef7a17
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau b6ae080cd6 [flang] Fix misc issues with closing of LabelDo
Original-commit: flang-compiler/f18@8134331da8
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 10e3b1cfb2 [flang] add resolution of CYCLE target construct
Original-commit: flang-compiler/f18@669ab24267
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 325d2d677c [flang] Target construct of EXIT statements are now identified
Original-commit: flang-compiler/f18@2000ae4904
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 68ef98cb5c [flang] fix incorrect handling of select rank and select type
Original-commit: flang-compiler/f18@9970fb02b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 9b520937e0 [flang] LabelDo are now properly handled (for cases supported by parser)
Also, construct names are now matched

Original-commit: flang-compiler/f18@0e09016059
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau 20ac31fa9f [flang] Very early semantic analysis.
Original-commit: flang-compiler/f18@862eca9c5b
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau cb463ab27b [flang] add fummy cc file for experiment
Original-commit: flang-compiler/f18@3972ad954b
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Stephane Chauveau fc2ec6a68b [flang] commit before rebase
Original-commit: flang-compiler/f18@8366a87e47
Reviewed-on: https://github.com/flang-compiler/f18/pull/24
Tree-same-pre-rewrite: false
2018-03-26 16:35:34 +02:00
Tim Keith 92cd5b1beb [flang] Merge pull request flang-compiler/f18#31 from ThePortlandGroup/tsk7
Add ENUM_CLASS to define enum class with ToString function.

Original-commit: flang-compiler/f18@bd1fc89b73
Reviewed-on: https://github.com/flang-compiler/f18/pull/31
2018-03-23 15:33:50 -07:00
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