Commit graph

195 commits

Author SHA1 Message Date
peter klausler
3509503e18 [flang] Remove some needless std::move() calls for readability.
Original-commit: flang-compiler/f18@88aadf45dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:27 -07:00
peter klausler
ca696230bc [flang] Better solution in grammar for a data statement value parse.
Original-commit: flang-compiler/f18@05b437506a
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:27 -07:00
peter klausler
334f47bc76 [flang] Handle pp-directives amid continuations correctly, and fix a Hollerith ambiguity.
Original-commit: flang-compiler/f18@dcd7820a97
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:26 -07:00
peter klausler
a4904e663b [flang] Adjust TODO messages to reflect deliberate behavior.
Original-commit: flang-compiler/f18@9636998ee4
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:26 -07:00
peter klausler
dbd691838b [flang] Fix naming: list_type -> listType
Original-commit: flang-compiler/f18@9bf6adc41c
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:26 -07:00
peter klausler
3274977aa5 [flang] Rearrange alternatives in data statement values to put longer parse earlier.
Original-commit: flang-compiler/f18@867cefaafb
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:25 -07:00
peter klausler
de180f4ed0 [flang] Prevent misrecognition of a digit string that is the kind parameter of a character literal from being misrecognized as an integer literal.
Original-commit: flang-compiler/f18@bd7ed0b162
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:25 -07:00
peter klausler
efc6c480fb [flang] Parse unlimited format item -- needed to adjust its precedence in grammar.
Original-commit: flang-compiler/f18@318bebe485
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:25 -07:00
peter klausler
52b0de7b2a [flang] Parser mistakenly attempted error recovery in specification part when it saw END statement with label.
Original-commit: flang-compiler/f18@69b8ad8380
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:24 -07:00
peter klausler
70895d3da0 [flang] Fix two errors in the grammar (array constructors with type but no values did not consume the ::, and ERR= was omitted from CLOSE(). Add CONVERT= extension to OPEN().
Original-commit: flang-compiler/f18@e3e584f060
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:24 -07:00
peter klausler
c52e5792db [flang] Crash more gracefully when files include themselves.
Original-commit: flang-compiler/f18@6da9ec4228
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:23 -07:00
peter klausler
8ea4a0a060 [flang] Avoid most uses of Boolean-valued Pre() callbacks in unparse.cc.
Original-commit: flang-compiler/f18@f4ea2f94f3
Reviewed-on: https://github.com/flang-compiler/f18/pull/43
2018-04-09 13:47:39 -07:00
Tim Keith
ced6d642e0 [flang] Address review comments.
Make map_type private -- it is not part of the API.

Add cbegin() and cend().

Original-commit: flang-compiler/f18@1ad699dbfd
Reviewed-on: https://github.com/flang-compiler/f18/pull/46
2018-04-09 11:53:20 -07:00
Tim Keith
75e4108d55 [flang] Change API of Scope to match std::map
The Scope can be thought of as (among other things) a mapping of Name to
Symbol. This change reflects that by changing the API to match std::map.

Original-commit: flang-compiler/f18@37f6ad73cc
Reviewed-on: https://github.com/flang-compiler/f18/pull/46
Tree-same-pre-rewrite: false
2018-04-09 10:07:36 -07:00
Tim Keith
0083eb5259 [flang] Address review comments.
Maintain stack of ImplicitRules in parallel with the scope stack.
I doesn't have to live as long as the scopes.

Allow for '_', '$', and '@' in ImplicitRules if they come through from
the parser.

Original-commit: flang-compiler/f18@b70e9fc956
Reviewed-on: https://github.com/flang-compiler/f18/pull/41
2018-04-06 14:09:49 -07:00
Tim Keith
807886fb81 [flang] Address code review comments.
Original-commit: flang-compiler/f18@b0dd895905
Reviewed-on: https://github.com/flang-compiler/f18/pull/41
Tree-same-pre-rewrite: false
2018-04-06 14:09:49 -07:00
Tim Keith
da414d7c3f [flang] Collect implicit type rules and report related errors.
ImplicitRules maintains a mapping of initial character of an identifier
to its implicit type.

ImplicitRulesVisitor visits the ImplicitStmt and related parse tree
nodes and updates the rules.

Emit errors messages in these cases:
- implicit type specified more than once for a letter
- IMPLICIT statement and IMPLICIT NONE in same scope
- IMPLICIT statement and IMPLICIT NONE(TYPE) in same scope
- more than one IMPLICIT NONE in a scope
- IMPLICIT statement with empty range of letters
- IMPLICIT NONE statement after PARAMETER statement
- TYPE or EXTERNAL repeated in an IMPLICIT NONE statement

Also start emitting error messages through the parser::Messages
interface. An instance of Messages is created from the cooked source and
saved in the MessageHandler class. It tracks the source location of the
current statement and provides a way to emit messages associated with
that statement.

Original-commit: flang-compiler/f18@e12fea9850
Reviewed-on: https://github.com/flang-compiler/f18/pull/41
Tree-same-pre-rewrite: false
2018-04-06 14:09:49 -07:00
peter klausler
216999318b [flang] Address review comments.
Original-commit: flang-compiler/f18@66ecc10722
Reviewed-on: https://github.com/flang-compiler/f18/pull/42
2018-04-06 10:34:59 -07:00
peter klausler
91b324ee71 [flang] Generalize semantics/attr.h into enum-set.h, implementing it atop std::bitset.
Original-commit: flang-compiler/f18@d827c8bcc3
Reviewed-on: https://github.com/flang-compiler/f18/pull/42
Tree-same-pre-rewrite: false
2018-04-05 16:49:48 -07:00
peter klausler
8fcc1aaf8c [flang] Improvements to memory-mapped source files.
Original-commit: flang-compiler/f18@67066468e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/42
Tree-same-pre-rewrite: false
2018-04-05 14:39:55 -07:00
peter klausler
2f2a8451cf [flang] Avoid having too many file descriptors open or using mmap() for small files.
Original-commit: flang-compiler/f18@750483a1be
Reviewed-on: https://github.com/flang-compiler/f18/pull/42
Tree-same-pre-rewrite: false
2018-04-05 13:06:36 -07:00
peter klausler
ff7d3c7126 [flang] Do not allow "-" to denote standard input on INCLUDE/#include.
Original-commit: flang-compiler/f18@f645036a16
Reviewed-on: https://github.com/flang-compiler/f18/pull/42
Tree-same-pre-rewrite: false
2018-04-04 08:06:15 -07:00
peter klausler
eec3705f58 [flang] Fix __VA_ARGS__, was broken due to typo.
Original-commit: flang-compiler/f18@ba90b1fc27
Reviewed-on: https://github.com/flang-compiler/f18/pull/42
Tree-same-pre-rewrite: false
2018-04-03 15:50:25 -07:00
peter klausler
382edf056b [flang] Resolve some TODOs in the grammar.
Original-commit: flang-compiler/f18@6ef9e2388b
Reviewed-on: https://github.com/flang-compiler/f18/pull/39
2018-04-03 14:14:39 -07:00
peter klausler
828cff6dbb [flang] Error recovery for specification part.
Original-commit: flang-compiler/f18@187075c7a0
Reviewed-on: https://github.com/flang-compiler/f18/pull/39
Tree-same-pre-rewrite: false
2018-04-03 13:02:40 -07:00
peter klausler
41d9cfd728 [flang] Address review comments (thanks!).
Original-commit: flang-compiler/f18@1e61fbaeae
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
2018-04-03 10:29:04 -07:00
peter klausler
b493458e00 [flang] More clean-up in token-parsers.h.
Original-commit: flang-compiler/f18@3202134542
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
Tree-same-pre-rewrite: false
2018-04-02 16:44:34 -07:00
peter klausler
10907c73db [flang] Debugging and a TODO.
Original-commit: flang-compiler/f18@4fab40bc37
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
Tree-same-pre-rewrite: false
2018-04-02 16:33:10 -07:00
peter klausler
1e1ea723c5 [flang] Better error recovery, some debugging.
Original-commit: flang-compiler/f18@b7509f0e5b
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
Tree-same-pre-rewrite: false
2018-04-02 16:06:18 -07:00
peter klausler
af22e07f71 [flang] Revamp messaging. Add ""_err_en_US to denote fatal error messages.
Original-commit: flang-compiler/f18@7ddc807a1b
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
Tree-same-pre-rewrite: false
2018-04-02 15:51:04 -07:00
peter klausler
bb273e9ecb [flang] Fix debug-parser.h after recent merge.
Original-commit: flang-compiler/f18@97b6df606c
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
Tree-same-pre-rewrite: false
2018-04-02 11:52:53 -07:00
peter klausler
0fb7dca452 [flang] Fix indentation bug in unparsed output that I introduced in last merge.
Original-commit: flang-compiler/f18@aa0ba5acac
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
Tree-same-pre-rewrite: false
2018-04-02 11:05:07 -07:00
peter klausler
6ec5f8fa2c [flang] Work around clang-format issue by using "auto" where type is obvious.
Original-commit: flang-compiler/f18@7499bccaa9
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
Tree-same-pre-rewrite: false
2018-04-02 11:01:31 -07:00
Tim Keith
dcc4dd8627 [flang] Fix bug parsing "implicit none(type)"
"implicit none(type)" was being recognized as "implicit none(external)".

Original-commit: flang-compiler/f18@0cc8867836
Reviewed-on: https://github.com/flang-compiler/f18/pull/36
2018-04-02 10:49:22 -07:00
Tim Keith
fc89541e96 [flang] Respond to review comments.
Original-commit: flang-compiler/f18@d2497a6485
Reviewed-on: https://github.com/flang-compiler/f18/pull/36
Tree-same-pre-rewrite: false
2018-04-02 10:49:22 -07:00
Tim Keith
86726d8ee4 [flang] Continue work on name resolution
Enhance DeclTypeSpecVisitor to find derived-type-specs, including with
type parameter values.

Change DerivedTypeSpec so it only needs the name of the derived type,
not the definition, as that isn't necessarily known when we encounter
it.

Fix how memory is managed in DeclTypeSpec: Intrinsic type specs aren't a
problem -- they are one of a few types that live throughout the program.
Derived type specs are dynamically allocated and the memory is owned by
the DeclTypeSpec -- it allocates it when a DeclTypeSpec for a derived
type is created and deletes it when it is destroyed. Pass around
references to TypeSpecs rather than pointers as they can never be null.

In AttrsVisitor, DeclTypeSpecVisitor, ResolveNamesVisitor: make most
functions out-of-line to clean up the class declaration.

In AttrsVisitor, use preprocessor to simplify the simple case of
encountering a parse-tree class causing an attribute to be set.
Handle all such attributes.

Remove old testing code from type.cc.

Remove some of the declarations for IntExpr and IntConst -- they are
only placeholder classes anyway. Don't distinguish kind and length
parameter values.

Original-commit: flang-compiler/f18@e172b51212
Reviewed-on: https://github.com/flang-compiler/f18/pull/36
Tree-same-pre-rewrite: false
2018-04-02 10:49:22 -07:00
peter klausler
2b79b0bc67 [flang] Elide a useless local variable that used to be a formal argument.
Original-commit: flang-compiler/f18@419b5d07ee
Reviewed-on: https://github.com/flang-compiler/f18/pull/37
2018-03-30 17:03:02 -07:00
peter klausler
d5a084c43a [flang] Debugging after testing. Take care of a TODO in the prescanner.
Original-commit: flang-compiler/f18@4c8181e106
Reviewed-on: https://github.com/flang-compiler/f18/pull/37
Tree-same-pre-rewrite: false
2018-03-30 16:21:12 -07:00
peter klausler
4e354d85ae [flang] Debugging, and resolve another TODO in unparse.cc.
Original-commit: flang-compiler/f18@edeb283cd5
Reviewed-on: https://github.com/flang-compiler/f18/pull/37
Tree-same-pre-rewrite: false
2018-03-30 15:23:37 -07:00
peter klausler
f8c7fde5c2 [flang] Look for declared STRUCTURE component names after a . rather than defined operator names.
Original-commit: flang-compiler/f18@cf64809551
Reviewed-on: https://github.com/flang-compiler/f18/pull/37
Tree-same-pre-rewrite: false
2018-03-30 14:10:00 -07:00
peter klausler
fdae1bfc4a [flang] Remove some needless checks for mandatory spaces before keywords and names that could not be present anyway, they were slowing things down.
Original-commit: flang-compiler/f18@a07b78d2d7
Reviewed-on: https://github.com/flang-compiler/f18/pull/35
2018-03-30 11:32:37 -07:00
peter klausler
59e3955ea9 [flang] Use "..."_sptok rather than ~ in tokens to denote mandatory spaces.
Original-commit: flang-compiler/f18@1b22874a9d
Reviewed-on: https://github.com/flang-compiler/f18/pull/35
Tree-same-pre-rewrite: false
2018-03-30 11:11:48 -07:00
peter klausler
fc1b7685ad [flang] "free from" -> "free form" in comment.
Original-commit: flang-compiler/f18@3923166673
Reviewed-on: https://github.com/flang-compiler/f18/pull/35
Tree-same-pre-rewrite: false
2018-03-29 17:07:19 -07:00
peter klausler
d2d155f9a2 [flang] Make functions inline to recoup performance.
Original-commit: flang-compiler/f18@7f8705304d
Reviewed-on: https://github.com/flang-compiler/f18/pull/35
Tree-same-pre-rewrite: false
2018-03-29 16:49:25 -07:00
peter klausler
d836e7156b [flang] Debugging.
Original-commit: flang-compiler/f18@84e0cc7549
Reviewed-on: https://github.com/flang-compiler/f18/pull/35
Tree-same-pre-rewrite: false
2018-03-29 16:34:03 -07:00
peter klausler
1f3c41b521 [flang] Emit warnings in free form when a required space is missing.
Original-commit: flang-compiler/f18@e41917d144
Reviewed-on: https://github.com/flang-compiler/f18/pull/35
Tree-same-pre-rewrite: false
2018-03-29 16:06:31 -07:00
peter klausler
e286e6c302 [flang] Begin work on missing space warnings in free form. Reformat C++.
Original-commit: flang-compiler/f18@1bcbf0eb7b
Reviewed-on: https://github.com/flang-compiler/f18/pull/34
2018-03-29 12:16:10 -07:00
peter klausler
e0482bb778 [flang] Simplify test-type and test-sema to use parser::Parsing wrapper class.
Original-commit: flang-compiler/f18@3741a652ed
Reviewed-on: https://github.com/flang-compiler/f18/pull/34
Tree-same-pre-rewrite: false
2018-03-28 17:15:00 -07:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
peter klausler
601e0acdeb [flang] Improvements suggested by Tim.
Original-commit: flang-compiler/f18@c3d2e3e745
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
Tree-same-pre-rewrite: false
2018-02-28 14:51:45 -08:00
peter klausler
07a028098f [flang] Trait-based parse tree traversal.
Add a CLASS_TRAIT macro to idioms.h to define template metaprogramming
based on definable traits of user-defined classes.  Tweak the boilerplate
macros in parse-tree.h to add traits to the empty, wrapper, union, and
tuple classes in the parse tree.  Replace the macros in parse-tree-visitor.h
with trait-driven templates.

Original-commit: flang-compiler/f18@02400146fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
Tree-same-pre-rewrite: false
2018-02-28 13:24:01 -08:00
Tim Keith
de65ddbae0 [flang] Use macros to reduce boilerplate.
The common cases of wrapper, tuple, and union classes can be further
reduced by using macros to define the Walk functions.

Original-commit: flang-compiler/f18@29e02c4886
Reviewed-on: https://github.com/flang-compiler/f18/pull/18
2018-02-27 16:52:29 -08:00
peter klausler
48f7c6f0fd [flang] Fix test: do not allow & as continuation marker in fixed form if in a character literal.
Original-commit: flang-compiler/f18@26c07eb2e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/19
2018-02-27 16:33:10 -08:00
peter klausler
f4a85288db [flang] Fix some bugs that I noticed while running regression tests.
Add characters.h to consolidate all per-character functions
and reduce dependence on <cctype>.
Add omitted DIRECT= and UNFORMATTED= specifiers to INQUIRE statement.
Add Interval<>, rebase ProvenanceRange upon it, rebase CharPointerWithLength
and rename it ContiguousChars.
Reformat C++.

Original-commit: flang-compiler/f18@78c73c62ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/19
Tree-same-pre-rewrite: false
2018-02-27 15:55:10 -08:00
peter klausler
03aecfc336 [flang] Preserve some minor changes that accumulated as I was implementing
an unparsing feature.

Enum classes in parse tree node class types are now defined with
a macro so that the names of the enumerations can be captured for
formatting purposes.

Add a TODO comment.

Rebase to new master with parse tree traversal code.

Original-commit: flang-compiler/f18@d6bfcfd526
Reviewed-on: https://github.com/flang-compiler/f18/pull/16
2018-02-26 15:31:46 -08:00
Tim Keith
66c9a69a61 [flang] Fix classes with variant and other fields
Fortran::FormatItem and UseStmt have both normal fields and a variant
named 'u'. The Walk calls for the normal fields were missing.
These were the only two classes I found where this occurs.

Original-commit: flang-compiler/f18@23b8695a74
Reviewed-on: https://github.com/flang-compiler/f18/pull/17
2018-02-26 15:07:24 -08:00
Tim Keith
2af29bc1e2 [flang] Add Unparse function.
Unparse takes a parse tree and converts it back to Fortran.
class UnparseVisitor implements a parse tree visitor that emits
the appropriate Fortran source for each node that it visits.
It is only partially implemented so far.

Change f18 to dump the parse tree using Unparse.

Original-commit: flang-compiler/f18@e80c13ec88
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
2018-02-26 14:52:27 -08:00
Tim Keith
0406170acb [flang] Reorder the Walk functions.
Group the Walk functions that call WalkTupleClass, WalkUnionClass,
WalkWrapperClass all together, after the ones that don't follow a
simple pattern like that.

Fix the name of the include guard macro.

Original-commit: flang-compiler/f18@711613a4ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
Tree-same-pre-rewrite: false
2018-02-26 14:52:27 -08:00
Tim Keith
686529a59a [flang] Add some missing Walk functions.
The classes in parse-tree.h that used WRAPPER_CLASS_BOILERPLATE were
accidentally omitted.

Also remove the anonymous namespace around utilities like
WalkWrapperClass as they can be useful outside this file too.

Original-commit: flang-compiler/f18@d47c505441
Reviewed-on: https://github.com/flang-compiler/f18/pull/15
Tree-same-pre-rewrite: false
2018-02-26 14:52:27 -08:00