Commit graph

553 commits

Author SHA1 Message Date
Tim Keith
511af19d41 [flang] Create Message instances with provenance range.
This allows the message to point to the full name or statement
rather than just the first character.

Original-commit: flang-compiler/f18@9cf41b1335
Reviewed-on: https://github.com/flang-compiler/f18/pull/67
2018-04-23 16:18:48 -07:00
Peter Klausler
82fd470b91 [flang] Merge pull request flang-compiler/f18#68 from ThePortlandGroup/pmk-scrub2
Remove needless empty braces from construct<>() calls.

Original-commit: flang-compiler/f18@d7609befe6
Reviewed-on: https://github.com/flang-compiler/f18/pull/68
2018-04-24 10:45:23 -07:00
peter klausler
925cadcddc [flang] Remove needless empty braces from construct<>() calls.
Original-commit: flang-compiler/f18@f9c4a27034
Reviewed-on: https://github.com/flang-compiler/f18/pull/68
2018-04-23 16:53:16 -07:00
Peter Klausler
758fb308ef [flang] Merge pull request flang-compiler/f18#66 from ThePortlandGroup/pmk-scrub
Code clean-up & provenance ranges on messages

Original-commit: flang-compiler/f18@fd50389e44
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
2018-04-23 15:54:38 -07:00
peter klausler
64e64e6747 [flang] Delete more dead code.
Original-commit: flang-compiler/f18@e38e411ccf
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
2018-04-23 15:44:30 -07:00
peter klausler
e42168a903 [flang] Remove dead code.
Original-commit: flang-compiler/f18@a85e16c704
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:29 -07:00
peter klausler
e6b1f1f45e [flang] Use ranges of provenances in messages.
Original-commit: flang-compiler/f18@67d4f878a4
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:29 -07:00
peter klausler
d3c1a08e68 [flang] Extend Message representation to cover ranges.
Original-commit: flang-compiler/f18@314819c87f
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:28 -07:00
peter klausler
30f337a36d [flang] Finish cleaning up debug-parser.
Original-commit: flang-compiler/f18@0ef551025a
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:28 -07:00
peter klausler
cc589b2e8e [flang] Split debug-parser.h, put code into debug-parser.cc.
Original-commit: flang-compiler/f18@b34d15ef6d
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:27 -07:00
peter klausler
d2306759fc [flang] Finish moving user state action parsers into user-state.{h,cc}.
Original-commit: flang-compiler/f18@79c8a4cefe
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:27 -07:00
peter klausler
4412cb03c4 [flang] More clean-up.
Original-commit: flang-compiler/f18@96dda92286
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:26 -07:00
peter klausler
8800ae5e08 [flang] Begin moving UserState action parsers into user-state.{h,cc}.
Original-commit: flang-compiler/f18@5c31402146
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:25 -07:00
peter klausler
8c110e0af1 [flang] Fix header file name.
Original-commit: flang-compiler/f18@8abfeaed45
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:24 -07:00
peter klausler
48704ef940 [flang] Move Parser<> to its own header.
Original-commit: flang-compiler/f18@c43e8ba138
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:23 -07:00
peter klausler
c387b6d4e4 [flang] Use references for ParseState arguments to parsers. Other minor clean-up.
Original-commit: flang-compiler/f18@5b18b799e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
2018-04-23 15:44:23 -07:00
Tim Keith
9c840631e7 [flang] Merge pull request flang-compiler/f18#65 from ThePortlandGroup/tsk2
Rewrite function calls to array element references

Original-commit: flang-compiler/f18@1dc8d27250
Reviewed-on: https://github.com/flang-compiler/f18/pull/65
2018-04-23 15:38:21 -07:00
Tim Keith
dfd2bcbd3c [flang] Undo previous commit.
`name` depends on the template type, so we have to explicitly say
that `has` is a template with the `template` keyword.
Rather than do that I'm putting back the explicit type for name.

Original-commit: flang-compiler/f18@0cde87f2fe
Reviewed-on: https://github.com/flang-compiler/f18/pull/65
2018-04-23 15:33:59 -07:00
Tim Keith
30af7449d9 [flang] Address review comment.
Original-commit: flang-compiler/f18@cb3904761b
Reviewed-on: https://github.com/flang-compiler/f18/pull/65
Tree-same-pre-rewrite: false
2018-04-23 13:10:33 -07:00
Tim Keith
744427238c [flang] Rewrite function calls to array element references
parse-tree.h, parse-tree.cc:
Add FunctionReference::ConvertToArrayElementRef() to convert a function
reference to an array element reference.
Factor out MakeArrayElementRef() to use in ConvertToArrayElementRef()
and also in converting statement functions to array element assignments.

resolve-names.cc:
Recognize references to functions and subroutines and add symbols for them.
Detect declaration conflicts from these and check `IMPLICIT NONE(EXTERNAL)`.

rewrite-parse-tree.cc:
Find function references that need to be converted and rewrite them.

Original-commit: flang-compiler/f18@e5a1e0aaef
Reviewed-on: https://github.com/flang-compiler/f18/pull/65
2018-04-23 12:46:56 -07:00
Peter Klausler
fee104eac0 [flang] Merge pull request flang-compiler/f18#62 from ThePortlandGroup/pmk-instr
Parser instrumentation and caching of failed parse attempts

Original-commit: flang-compiler/f18@30040ed22e
Reviewed-on: https://github.com/flang-compiler/f18/pull/62
2018-04-20 10:42:03 -07:00
peter klausler
7335482d98 [flang] Complete parser instrumentation and caching of failures.
Original-commit: flang-compiler/f18@9843dbf211
Reviewed-on: https://github.com/flang-compiler/f18/pull/62
2018-04-19 17:02:12 -07:00
peter klausler
56b09e08eb [flang] Parser instrumentation and fail-fast experiment begun.
Original-commit: flang-compiler/f18@ab46163d6e
Reviewed-on: https://github.com/flang-compiler/f18/pull/62
Tree-same-pre-rewrite: false
2018-04-19 15:46:02 -07:00
peter klausler
2c06be3fb8 [flang] First cut at parser instrumentation with pass/fail counters.
Original-commit: flang-compiler/f18@21ed700afa
Reviewed-on: https://github.com/flang-compiler/f18/pull/62
Tree-same-pre-rewrite: false
2018-04-19 13:58:02 -07:00
Peter Klausler
f3d0f347a9 [flang] Merge pull request flang-compiler/f18#61 from ThePortlandGroup/pmk-cset
Define SetOfChars type, use it

Original-commit: flang-compiler/f18@1d563ba59f
Reviewed-on: https://github.com/flang-compiler/f18/pull/61
2018-04-19 13:51:46 -07:00
peter klausler
086a7f3596 [flang] Address review comments.
Original-commit: flang-compiler/f18@dbeba37322
Reviewed-on: https://github.com/flang-compiler/f18/pull/61
2018-04-19 13:51:25 -07:00
peter klausler
0acda77554 [flang] Finish repackaging SetOfChars
Original-commit: flang-compiler/f18@37085c0cdd
Reviewed-on: https://github.com/flang-compiler/f18/pull/61
Tree-same-pre-rewrite: false
2018-04-19 11:21:08 -07:00
peter klausler
107aa28930 [flang] More repackaging
Original-commit: flang-compiler/f18@55f4f0505e
Reviewed-on: https://github.com/flang-compiler/f18/pull/61
Tree-same-pre-rewrite: false
2018-04-19 11:21:07 -07:00
peter klausler
376d8f96d4 [flang] repackage SetOfChars as a class type
Original-commit: flang-compiler/f18@bae9199f62
Reviewed-on: https://github.com/flang-compiler/f18/pull/61
Tree-same-pre-rewrite: false
2018-04-19 11:21:06 -07:00
peter klausler
075fe789da [flang] Combine expected character sets of messages ending at same point from two alternatives.
Original-commit: flang-compiler/f18@a006ceef1d
Reviewed-on: https://github.com/flang-compiler/f18/pull/61
Tree-same-pre-rewrite: false
2018-04-19 11:21:04 -07:00
peter klausler
f6accb372b [flang] debugging
Original-commit: flang-compiler/f18@02718dd6ef
Reviewed-on: https://github.com/flang-compiler/f18/pull/61
Tree-same-pre-rewrite: false
2018-04-19 11:21:04 -07:00
peter klausler
1730085e1b [flang] Define sets of characters; use them in parsing and messages.
Original-commit: flang-compiler/f18@d3ca565b59
Reviewed-on: https://github.com/flang-compiler/f18/pull/61
Tree-same-pre-rewrite: false
2018-04-19 11:21:03 -07:00
Tim Keith
934ad66682 [flang] Merge pull request flang-compiler/f18#60 from ThePortlandGroup/tsk2
Implement parse tree rewriting.

Original-commit: flang-compiler/f18@ac0c8ca08e
Reviewed-on: https://github.com/flang-compiler/f18/pull/60
2018-04-19 10:47:48 -07:00
Tim Keith
3d2120989a [flang] Move ConvertToAssignment into class StmtFunctionStmt.
Original-commit: flang-compiler/f18@e3eaca38fd
Reviewed-on: https://github.com/flang-compiler/f18/pull/60
2018-04-19 07:07:47 -07:00
Tim Keith
06f9d7901a [flang] Merge parse-tree-mutator.h into parse-tree-visitor.h
Use the latter for visiting and mutating and delete the former.

Original-commit: flang-compiler/f18@ac5a098ca7
Reviewed-on: https://github.com/flang-compiler/f18/pull/60
Tree-same-pre-rewrite: false
2018-04-18 16:49:42 -07:00
Tim Keith
6746a18e6b [flang] Address review comments.
Original-commit: flang-compiler/f18@d3a363d6cb
Reviewed-on: https://github.com/flang-compiler/f18/pull/60
Tree-same-pre-rewrite: false
2018-04-18 15:50:36 -07:00
Tim Keith
1c291436f5 [flang] Implement parse tree rewriting.
Add parse-tree-mutator.h like parse-tree-visitor.h except that the Walk
functions take non-const references to parse tree nodes so the Pre and
Post methods of the mutator that are passed around can make changes to
the parse tree.

Change ExecutionPart to be a class that wraps a list so that it can be
identified during parse tree walking.

Add Symbol* field to parser::Name for the result of symbol resolution.
In parse tree dumper, dump symbol when it is there instead of just name.

Add RewriteParseTree to walk the parse tree, fill in resolved symbols in
Name nodes, and make necessary changes to the structure. Currently that
consists of rewriting statement functions as array assignments when
appropriate.

In ResolveNames, call RewriteParseTree if the resolution was successful.
Recognize a statement function that comes after a mis-identified
statement function and report an error. resolve08.f90 tests this case.

Add -fdebug-dump-symbols to dump the scope tree and symbols in each scope.
This is implemented by DumpSymbols in resolve-names.cc. Add an optional
symbol to scopes that correspond to symbols (e.g. subprograms). Remove
debug output from ResolveNamesVisitor as this option can be used instead.

Original-commit: flang-compiler/f18@9cd3372265
Reviewed-on: https://github.com/flang-compiler/f18/pull/60
Tree-same-pre-rewrite: false
2018-04-18 15:06:35 -07:00
Peter Klausler
bca1c7ed55 [flang] Merge pull request flang-compiler/f18#59 from ThePortlandGroup/pmk-messages
Messaging work

Original-commit: flang-compiler/f18@f6b879ab10
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
2018-04-17 17:09:43 -07:00
peter klausler
43c64d215a [flang] Defer message accumulation until it is known that messages will be produced.
Original-commit: flang-compiler/f18@8485d44efd
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
2018-04-17 16:58:18 -07:00
peter klausler
edd6822e00 [flang] Suppress messages in lookAhead and negated parsers.
Original-commit: flang-compiler/f18@6c00f10364
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
Tree-same-pre-rewrite: false
2018-04-17 16:58:17 -07:00
peter klausler
bdc1577188 [flang] reformat
Original-commit: flang-compiler/f18@4a4648facd
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
Tree-same-pre-rewrite: false
2018-04-17 16:58:16 -07:00
peter klausler
984db1b650 [flang] Remove questionable swap() routines in ParseState and Messages.
Original-commit: flang-compiler/f18@9a8155ebca
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
Tree-same-pre-rewrite: false
2018-04-17 16:58:14 -07:00
peter klausler
4a4ad8f323 [flang] Avoid a std::move() when emplacing new messages.
Original-commit: flang-compiler/f18@39c0e1fdba
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
Tree-same-pre-rewrite: false
2018-04-17 16:58:13 -07:00
peter klausler
8aa47941ee [flang] Remove obsolete #if 0 code.
Original-commit: flang-compiler/f18@0195cd5646
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
Tree-same-pre-rewrite: false
2018-04-17 16:58:12 -07:00
peter klausler
84ebba9e53 [flang] Avoid std::shared_ptr<> in favor of reference counting.
Original-commit: flang-compiler/f18@116c9881c9
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
Tree-same-pre-rewrite: false
2018-04-17 16:58:11 -07:00
peter klausler
f595462ea8 [flang] Message experiment: defer all message generation until non-speculative.
Original-commit: flang-compiler/f18@b6ce95ca3a
Reviewed-on: https://github.com/flang-compiler/f18/pull/59
Tree-same-pre-rewrite: false
2018-04-17 16:58:10 -07:00
Tim Keith
f39d1a1486 [flang] Merge pull request flang-compiler/f18#58 from ThePortlandGroup/tsk1
Add statement functions to symbol table

Original-commit: flang-compiler/f18@c69f975aee
Reviewed-on: https://github.com/flang-compiler/f18/pull/58
2018-04-17 16:55:57 -07:00
Tim Keith
b4f34ddf7d [flang] Address review comments.
Original-commit: flang-compiler/f18@f9a54f7171
Reviewed-on: https://github.com/flang-compiler/f18/pull/58
2018-04-17 15:04:08 -07:00
Tim Keith
7e34313ff7 [flang] Add statement functions to symbol table
SubprogramDetails: Store dummy args and result as symbols, not names.

Symbol: Save list of occurrences (i.e. SourceNames that map to the same
symbol). This is needed to map Names in the parse tree back to symbols,
and will probably be useful when reporting errors.
Improve dumping of symbols.

resolve-names.cc: Recognize statement functions. They are treated like
function subprograms but the result type and type of dummy arguments come
from the enclosing scope. The implicit rules from the enclosing scope need
to be copied in.

Original-commit: flang-compiler/f18@44e4fb4b6c
Reviewed-on: https://github.com/flang-compiler/f18/pull/58
Tree-same-pre-rewrite: false
2018-04-17 14:16:42 -07:00
Peter Klausler
90d476410d [flang] Merge pull request flang-compiler/f18#57 from ThePortlandGroup/pmk-bugfix
fix misrecogition of actual argument "a==b"

Original-commit: flang-compiler/f18@56ee8bf349
Reviewed-on: https://github.com/flang-compiler/f18/pull/57
2018-04-16 16:21:07 -07:00