Commit graph

451 commits

Author SHA1 Message Date
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
6d23ceb7bd [flang] Merge pull request flang-compiler/f18#42 from ThePortlandGroup/pmk1
Generalize Attrs for arbitrary enums, implement with std::bitset<>.

Original-commit: flang-compiler/f18@28a9fc0b9e
Reviewed-on: https://github.com/flang-compiler/f18/pull/42
2018-04-06 11:21:28 -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
d8dfa408b5 [flang] Correct order of steps in idealized preprocessor description.
Original-commit: flang-compiler/f18@3107999501
Reviewed-on: https://github.com/flang-compiler/f18/pull/42
Tree-same-pre-rewrite: false
2018-04-04 14:32:17 -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
52fe1aa994 [flang] Merge pull request flang-compiler/f18#39 from ThePortlandGroup/pmk-recovery2
Error recovery in specification parts

Original-commit: flang-compiler/f18@074ce568ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/39
2018-04-03 14:34:58 -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
f84cbb067b [flang] Merge pull request flang-compiler/f18#38 from ThePortlandGroup/pmk-recovery
Messaging and error recovery work

Original-commit: flang-compiler/f18@073210bf91
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
2018-04-03 10:30:16 -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
eab946db74 [flang] Add documentation.
Original-commit: flang-compiler/f18@4114c9e695
Reviewed-on: https://github.com/flang-compiler/f18/pull/38
Tree-same-pre-rewrite: false
2018-04-02 17:00:28 -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
432ffe829c [flang] Merge pull request flang-compiler/f18#36 from ThePortlandGroup/tsk6
Continue work on name resolution

Original-commit: flang-compiler/f18@acaee7b44f
Reviewed-on: https://github.com/flang-compiler/f18/pull/36
2018-04-02 10:49:22 -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
4ad322aa9d [flang] Merge pull request flang-compiler/f18#37 from ThePortlandGroup/pmk-minor
Roll up some small changes to resolve TODOs

Original-commit: flang-compiler/f18@e3d5b7256c
Reviewed-on: https://github.com/flang-compiler/f18/pull/37
2018-04-02 09:46:19 -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
3a0351e43c [flang] Merge pull request flang-compiler/f18#35 from ThePortlandGroup/pmk-spaces
Warn about missing spaces in free form

Original-commit: flang-compiler/f18@2cf8391737
Reviewed-on: https://github.com/flang-compiler/f18/pull/35
2018-03-30 11:33:24 -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
522d345f12 [flang] Update documentation.
Original-commit: flang-compiler/f18@7045fbcd0c
Reviewed-on: https://github.com/flang-compiler/f18/pull/35
Tree-same-pre-rewrite: false
2018-03-29 16:53:10 -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
9e6c284b2d [flang] Merge pull request flang-compiler/f18#34 from ThePortlandGroup/pmk-cdir
Support compiler directives in the prescanner and parser.

Original-commit: flang-compiler/f18@bc625a6cdd
Reviewed-on: https://github.com/flang-compiler/f18/pull/34
2018-03-29 12:18:54 -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
43d8f80d27 [flang] Add MinSizeRel to .gitignore.
Original-commit: flang-compiler/f18@068e2e4465
Reviewed-on: https://github.com/flang-compiler/f18/pull/34
Tree-same-pre-rewrite: false
2018-03-29 11:19:37 -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
448e3e4cca [flang] Resolve merge with code pushed to master.
Original-commit: flang-compiler/f18@d75d86f28e
Reviewed-on: https://github.com/flang-compiler/f18/pull/34
Tree-same-pre-rewrite: false
2018-03-28 15:11:12 -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
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