Commit graph

2406 commits

Author SHA1 Message Date
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
peter klausler
2db73970bd [flang] fix misrecogition of actual argument "a==b" as keyword "a=" and value "=b"
Original-commit: flang-compiler/f18@52b1837419
Reviewed-on: https://github.com/flang-compiler/f18/pull/57
2018-04-16 15:41:37 -07:00
Peter Klausler
4692589215 [flang] Merge pull request flang-compiler/f18#56 from ThePortlandGroup/pmk-proc-component
Simplify grammar for "variable" as used in proc-component-ref and pointer ass't

Original-commit: flang-compiler/f18@3bbfe5656f
Reviewed-on: https://github.com/flang-compiler/f18/pull/56
2018-04-16 13:52:45 -07:00
Tim Keith
afe25498e3 [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@113bfc4fe7
Reviewed-on: https://github.com/flang-compiler/f18/pull/56
2018-04-16 13:37:59 -07:00
Stephane Chauveau
f45a354519 [flang] run clang-format
Original-commit: flang-compiler/f18@8639d566da
Reviewed-on: https://github.com/flang-compiler/f18/pull/56
Tree-same-pre-rewrite: false
2018-04-16 13:37:55 -07:00
Stephane Chauveau
b071d3bf0a [flang] add accessor to derived type definition
Original-commit: flang-compiler/f18@f73c70395e
Reviewed-on: https://github.com/flang-compiler/f18/pull/56
Tree-same-pre-rewrite: false
2018-04-16 13:37:55 -07:00
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
2eeb202518 [flang] Merge pull request flang-compiler/f18#55 from ThePortlandGroup/tsk8
Add -fdebug-dump-parse-tree and -fdebug-resolve-names

Original-commit: flang-compiler/f18@a62dceb218
Reviewed-on: https://github.com/flang-compiler/f18/pull/55
2018-04-13 10:00:52 -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
632855d02a [flang] Merge pull request flang-compiler/f18#54 from ThePortlandGroup/tsk6
Fix integration problem between PR flang-compiler/f18#51 and PR flang-compiler/f18#53.

Original-commit: flang-compiler/f18@1ec186ab77
Reviewed-on: https://github.com/flang-compiler/f18/pull/54
2018-04-12 14:36:43 -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
106a41ea5c [flang] Merge pull request flang-compiler/f18#53 from ThePortlandGroup/tsk6
Resolve array specifications of entities.

Original-commit: flang-compiler/f18@9abf24ab2f
Reviewed-on: https://github.com/flang-compiler/f18/pull/53
2018-04-12 14:25: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
d32620ac6d [flang] Merge pull request flang-compiler/f18#52 from ThePortlandGroup/tsk8
Improve include file sorting.

Original-commit: flang-compiler/f18@c36717a5e0
Reviewed-on: https://github.com/flang-compiler/f18/pull/52
2018-04-12 12:56:35 -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
11e278b83c [flang] Merge pull request flang-compiler/f18#51 from ThePortlandGroup/sch_types
add missing accessors to types

Original-commit: flang-compiler/f18@9b54154c63
Reviewed-on: https://github.com/flang-compiler/f18/pull/51
2018-04-12 21:34:03 +02: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
39d5565279 [flang] Merge pull request flang-compiler/f18#49 from ThePortlandGroup/tsk6
Continue work on name resolution.

Original-commit: flang-compiler/f18@7e271af1e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/49
2018-04-11 16:17:40 -07: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
917da9145c [flang] Merge pull request flang-compiler/f18#48 from ThePortlandGroup/pmk-nag-h
Parse NAG tests (no execution)

Original-commit: flang-compiler/f18@b18347b098
Reviewed-on: https://github.com/flang-compiler/f18/pull/48
2018-04-09 16:02:54 -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
0f2f6a3cf0 [flang] Merge pull request flang-compiler/f18#43 from ThePortlandGroup/pmk2
Avoid most uses of Boolean-valued Pre() callbacks in unparse.cc.

Original-commit: flang-compiler/f18@1b8ff5f07d
Reviewed-on: https://github.com/flang-compiler/f18/pull/43
2018-04-09 13:48:44 -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
af966cccc2 [flang] Merge pull request flang-compiler/f18#46 from ThePortlandGroup/tsk8
Change API of Scope to match std::map

Original-commit: flang-compiler/f18@e34e2ac0c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/46
2018-04-09 11:55:25 -07:00