Commit graph

249 commits

Author SHA1 Message Date
Stephane Chauveau 25ec87b25c [flang] Add missing accessors in 'type' classes
Original-commit: flang-compiler/f18@7b79fcfbc5
Reviewed-on: https://github.com/flang-compiler/f18/pull/56
Tree-same-pre-rewrite: false
2018-04-16 13:37:55 -07:00
peter klausler 058fa829fb [flang] fix misrecognition of a bounds-spec-list or bound-remapping-list in a pointer-assignment-stmt
Original-commit: flang-compiler/f18@32148441f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/56
2018-04-16 13:37:54 -07:00
peter klausler 2884b2ebbd [flang] Use DataRef as a better name for the data-ref production. Use DataRef instead of Variable for LHS of pointer assignment.
Original-commit: flang-compiler/f18@ed5aeb8e3c
Reviewed-on: https://github.com/flang-compiler/f18/pull/56
Tree-same-pre-rewrite: false
2018-04-16 13:37:54 -07:00
peter klausler 0f418c7c8d [flang] Simplify proc-component-ref and variable parsing, do not try to support function calls via components of function results.
Original-commit: flang-compiler/f18@05886ddb80
Reviewed-on: https://github.com/flang-compiler/f18/pull/56
Tree-same-pre-rewrite: false
2018-04-16 13:37:53 -07:00
Tim Keith c9d838e8a7 [flang] Add -fdebug-dump-parse-tree and -fdebug-resolve-names
"f18 -fdebug-resolve-names -fparse-only ..." is equivalent to what
test-type used to do, so the test-type executable can be eliminated.

-fdebug-dump-parse-tree does the parse-tree dumping that test-sema
does, but test-sema does more so I have left it alone.

Original-commit: flang-compiler/f18@8b3816528e
Reviewed-on: https://github.com/flang-compiler/f18/pull/55
2018-04-12 20:01:40 -07:00
Tim Keith 75f95ea1b7 [flang] Fix integration problem between PR flang-compiler/f18#51 and PR flang-compiler/f18#53.
Stephane added an access that returned ComponentArraySpec and meanwhile
I renamed it to ArraySpec.

Original-commit: flang-compiler/f18@b8e47bc7a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/54
2018-04-12 14:33:50 -07:00
Tim Keith 8ca01883bc [flang] Resolve array specifications of entities.
Add ArraySpecVisitor to recognize the various forms of array specifications.
They are tracked in arraySpec_ and attrArraySpec_. Both are needed because
a declaration like `integer, dimension(4) :: x(2,2), y` has two different
array-specs.

The method DeclareEntity was extracted out to handle the common part for
EntityDecl, ObjectDecl, and DimensionStmt. AllocatableStmt and TargetStmt
are now handled through their contained ObjectDecl.

The test resolve07 checks the interactions between these kinds of declarations.

Rename ComponentArraySpec to ArraySpec as it doesn't just occur in components.

Fix some 'begin' and 'end' methods to start with upper-case letters.

Original-commit: flang-compiler/f18@3d4d7430b5
Reviewed-on: https://github.com/flang-compiler/f18/pull/53
2018-04-12 12:59:42 -07:00
Tim Keith 6c772ac40b [flang] Improve include file sorting.
Includes like "../dir/file.h" should sort after local includes.
This change fixes that and applies the new formatting.

Now the order (in reverse) is:
- system includes
- includes from llvm or clang (this is from the default IncludeCategories)
- includes of ../something
- everything else

Original-commit: flang-compiler/f18@324643d63a
Reviewed-on: https://github.com/flang-compiler/f18/pull/52
2018-04-12 12:23:20 -07:00
Stephane Chauveau 0fc0c6bc6b [flang] run clang-format
Original-commit: flang-compiler/f18@f40a1dd9c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/51
2018-04-12 21:32:44 +02:00
Stephane Chauveau ccec5dde81 [flang] add accessor to derived type definition
Original-commit: flang-compiler/f18@d971f4f1ac
Reviewed-on: https://github.com/flang-compiler/f18/pull/51
Tree-same-pre-rewrite: false
2018-04-12 17:27:55 +02:00
Stephane Chauveau af25718ecd [flang] Add missing accessors in 'type' classes
Original-commit: flang-compiler/f18@42a46f35e8
Reviewed-on: https://github.com/flang-compiler/f18/pull/51
Tree-same-pre-rewrite: false
2018-04-12 17:11:31 +02:00
Tim Keith a9c82bd5a5 [flang] Use ENUM_CLASS macro for Scope::Kind.
Original-commit: flang-compiler/f18@3492e8d247
Reviewed-on: https://github.com/flang-compiler/f18/pull/49
2018-04-11 13:26:38 -07:00
Tim Keith af2940cfb6 [flang] Continue work on name resolution.
In Symbol and Scope, use SourceName (== parser::CharBlock) in place of
Name (== std::string) so that names in the symtab have provenance. We
may ultimately have multiple source locations associated with a symbol.

ImplicitRules: Add isImplicitNoneType and isImplicitNoneExternal flags.

MessageHandler: Add methods to emit messages associated with source
locations.

Detect conflicting declarations of symbols (e.g. as subprogram and
variable).

Handle attribute statements like ASYNCHRONOUS statement: make sure the
symbol is present and set the attribute on it. Check that these all have
a type declared by the end of the specification part if IMPLICIT NONE.

Find variables named in Variable and Expr nodes and check they have
types declared if IMPLICIT NONE. Otherwise, make sure they are in the
symtab and apply the implicit type rules at the end of the scope.

Push a scope for MainProgram nodes and add a symbol for the name if it
has one.

Rename Scope::map_type to Scope::mapType

Add tests for errors currently being detected. There is no framework for
running them yet, just source files with the expected errors in
comments.

Original-commit: flang-compiler/f18@39e6fa4169
Reviewed-on: https://github.com/flang-compiler/f18/pull/49
Tree-same-pre-rewrite: false
2018-04-11 13:13:14 -07:00
peter klausler 0ca0524142 [flang] Document support for CONVERT= extension.
Original-commit: flang-compiler/f18@a4674f0743
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
2018-04-09 15:39:39 -07:00
peter klausler 590afc60da [flang] Add length check so that memcmp() on source does not go past the end of input and make valgrind complain.
Original-commit: flang-compiler/f18@475e9db035
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 15:08:38 -07:00
peter klausler 8e7c0089a4 [flang] Fix unparsing of renamed operators in USE statements.
Original-commit: flang-compiler/f18@4152b604e3
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 14:52:15 -07:00
peter klausler bdd93dd995 [flang] Always put parens on unparsed ENTRY statement in case there is a suffix.
Original-commit: flang-compiler/f18@d0d1a5789b
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:52:06 -07:00
peter klausler 26b5f57876 [flang] Fix unparsing of pointer-decls with deferred shape.
Original-commit: flang-compiler/f18@3c7c7eced5
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:50:50 -07:00
peter klausler 4fc6a4505f [flang] Repair negative scale factors in formats.
Original-commit: flang-compiler/f18@0e90d2db3a
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:28 -07:00
peter klausler 070d908223 [flang] Tweak recent disambiguations after more testing.
Original-commit: flang-compiler/f18@82fb9838b9
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:28 -07:00
peter klausler 217e7ffed3 [flang] Remove a needless std::move() call, and be more careful about line continuation.
Original-commit: flang-compiler/f18@e26421513f
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
Tree-same-pre-rewrite: false
2018-04-09 13:49:28 -07:00
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
Steve Scalpone 11465b26fd [flang] Add snippet about trigraphs
Original-commit: flang-compiler/f18@551f2ccd06
Reviewed-on: https://github.com/flang-compiler/f18/pull/45
2018-04-08 21:31:49 -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 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 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 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