Commit graph

503 commits

Author SHA1 Message Date
peter klausler
f100d8b192 [flang] Issue 98, better error recovery for specification-part
Original-commit: flang-compiler/f18@0b0812a82b
Reviewed-on: https://github.com/flang-compiler/f18/pull/103
2018-06-14 10:17:54 -07:00
Peter Klausler
e3a3517762 [flang] Merge pull request flang-compiler/f18#102 from ThePortlandGroup/pmk-omp-fix
Allow tab in fixed form compiler directives.  Reformat C++.

Original-commit: flang-compiler/f18@1b7519b5a8
Reviewed-on: https://github.com/flang-compiler/f18/pull/102
2018-06-14 10:17:04 -07:00
peter klausler
efed300483 [flang] Allow tab in fixed form compiler directives. Reformat C++.
Original-commit: flang-compiler/f18@59ba17cb24
Reviewed-on: https://github.com/flang-compiler/f18/pull/102
2018-06-14 09:35:38 -07:00
Tim Keith
b6bad1f878 [flang] Merge pull request flang-compiler/f18#100 from ThePortlandGroup/tsk5
Remove extraneous Pre/Post for ProcedureDeclarationStmt

Original-commit: flang-compiler/f18@c7cf8c09b9
Reviewed-on: https://github.com/flang-compiler/f18/pull/100
2018-06-13 09:58:34 -07:00
Tim Keith
5fcec63769 [flang] Remove extraneous Pre/Post for ProcedureDeclarationStmt
clang give a compilation error on resolve-names.cc because there are
two overloadings of Pre(ProcedureDeclarationStmt) available in
ResolveNamesVisitor. One is defined in DeclTypeSpecVisitor and the other
in DeclarationVisitor. They are both brought in to ResolveNamesVisitor
via `using` statements.

The one in DeclarationVisitor is the one that is supposed to be called.
The other should have been removed when this one was added. This is the
one that gcc chooses to call, so this doesn't change any behavior.

The same applies to the Post method as well.

Original-commit: flang-compiler/f18@872f8faf96
Reviewed-on: https://github.com/flang-compiler/f18/pull/100
2018-06-12 17:46:41 -07:00
Tim Keith
3bccd5f0f5 [flang] Merge pull request flang-compiler/f18#99 from ThePortlandGroup/tsk7
Add Dump() routines for debugging.

Original-commit: flang-compiler/f18@cf7d2785aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/99
2018-06-12 07:06:11 -07:00
Tim Keith
fe1691d21c [flang] Add Dump() routines for debugging.
Add Dump() routines based on operator<< for the type so that they are
easy to call from the debugger. Overload for both pointer and reference
types and for dumping to std::cerr or a specific ostream.

Original-commit: flang-compiler/f18@ec6676eff0
Reviewed-on: https://github.com/flang-compiler/f18/pull/99
2018-06-11 15:40:31 -07:00
Tim Keith
5b4e9325d7 [flang] Merge pull request flang-compiler/f18#97 from ThePortlandGroup/tsk5
Process procedure declarations and derived types.

Original-commit: flang-compiler/f18@d356b3b7c4
Reviewed-on: https://github.com/flang-compiler/f18/pull/97
2018-06-06 11:43:12 -07:00
Tim Keith
5c27c9ea3f [flang] Address review comments.
Replace operator=(Symbol) and operator=(DeclTypeSpec) with set_symbol()
and set_type() to make it clearer. Eliminate the move constructor as it
is not needed. Make all but the accessor functions out-of-line.

Change HasExplicitType() to NeedsExplicitType(), reversing its sense.
HasExplicitType() returned true for symbols that didn't have or need an
explicit type, which was confusing.

Original-commit: flang-compiler/f18@ada13ac6a3
Reviewed-on: https://github.com/flang-compiler/f18/pull/97
2018-06-06 11:41:42 -07:00
Tim Keith
348ccb784e [flang] Process procedure declarations and derived types.
Add ObjectEntityDetails and ProcEntityDetails to distinguish between an
entity from an object-decl and one from a proc-decl. When we don't know,
it stays as EntityDetails until it is resolved. DeclareEntity() in
DeclarationVisitor creates this kind of symbol.

Add flags to Symbol as a convenient place for boolean flags common to
many kinds of symbols. Use it to mark symbols known to be functions or
subroutines so that we can report errors when they are used incorrectly.
Improve handling of EXTERNAL statement.

Handle ProcDecl nodes and add symbols for them.

Partial processing of derived types. Data component declarations are
processed and added to the derived type. Define TypeBoundProc and
TypeBoundGeneric in type.h. Procedure components, type-bound procedures,
etc. are not handled yet and nothing is done with the derived type once
it is created. Eliminate DerivedTypeDefBuilder in favor of just setting
fields in derivedTypeData_.

Add GetDeclTypeSpec to go with BeginDeclTypeSpec and EndDeclTypeSpec, to
avoid directly access the private variable.

Add tests in resolve20.f90 for errors related to procedure declarations.
Add missing copyrights to other tests.

Original-commit: flang-compiler/f18@40e65c1465
Reviewed-on: https://github.com/flang-compiler/f18/pull/97
Tree-same-pre-rewrite: false
2018-06-05 12:18:35 -07:00
Tim Keith
e820c545d7 [flang] Add MessageHandler::Say2.
This handles the common case of an error message referring to
a name, and an attached message referring to another name.
For example, reporting an error where a name is already declared
and mentioning the previous declaration.

Original-commit: flang-compiler/f18@901b50dcf2
Reviewed-on: https://github.com/flang-compiler/f18/pull/97
Tree-same-pre-rewrite: false
2018-05-30 14:49:40 -07:00
Tim Keith
06440bc34d [flang] Extract DeclarationVisitor from ResolveNamesVisitor
The is a refactoring to move all handling of declarations from
ResolveNamesVisitor to a new class. No function change.

Original-commit: flang-compiler/f18@2a5589ab96
Reviewed-on: https://github.com/flang-compiler/f18/pull/97
Tree-same-pre-rewrite: false
2018-05-30 14:11:45 -07:00
hsuauthai
c263c68b2f [flang] Merge pull request flang-compiler/f18#96 from ThePortlandGroup/omppar
Omppar

Original-commit: flang-compiler/f18@8c259b9300
Reviewed-on: https://github.com/flang-compiler/f18/pull/96
2018-06-01 15:08:09 -07:00
Hongyon Suauthai
90aca33d88 [flang] Fix comment in openmp-grammar.h. Fix unparse of reduction operator.
Original-commit: flang-compiler/f18@f6a7a03492
Reviewed-on: https://github.com/flang-compiler/f18/pull/96
2018-06-01 14:36:51 -07:00
Hongyon Suauthai
ed465b9918 [flang] Remove unintended change.
Original-commit: flang-compiler/f18@a545cd5de4
Reviewed-on: https://github.com/flang-compiler/f18/pull/96
Tree-same-pre-rewrite: false
2018-06-01 11:54:43 -07:00
Hongyon Suauthai
e2c8c21390 [flang] Fix space in issue unparse.cc between directive and its first clause.
Original-commit: flang-compiler/f18@d9478c1a59
Reviewed-on: https://github.com/flang-compiler/f18/pull/96
Tree-same-pre-rewrite: false
2018-06-01 11:47:24 -07:00
Hongyon Suauthai
9914f221bd [flang] update unparsing openmp directives and clauses.
Original-commit: flang-compiler/f18@76121cda6c
Reviewed-on: https://github.com/flang-compiler/f18/pull/96
Tree-same-pre-rewrite: false
2018-06-01 11:15:32 -07:00
Hongyon Suauthai
1bfb843a29 [flang] Update unparse.cc and move declarative directives for now.
Original-commit: flang-compiler/f18@d79503f98f
Reviewed-on: https://github.com/flang-compiler/f18/pull/96
Tree-same-pre-rewrite: false
2018-06-01 10:40:13 -07:00
Hongyon Suauthai
db9bfab89d [flang] add more clauses, declarative directives, standalone directives, and directives enclosing do loop.
Original-commit: flang-compiler/f18@483a54b0c8
Reviewed-on: https://github.com/flang-compiler/f18/pull/96
Tree-same-pre-rewrite: false
2018-05-31 07:38:15 -07:00
Tim Keith
7bbd05fefb [flang] Merge pull request flang-compiler/f18#95 from ThePortlandGroup/tsk3
Improvements to generics.

Original-commit: flang-compiler/f18@4d1664206f
Reviewed-on: https://github.com/flang-compiler/f18/pull/95
2018-05-22 17:00:10 -07:00
Tim Keith
b6d08173ee [flang] Improvements to generics.
When a generic or specific procedure is use-associated, make a copy of
it in the current scope (replacing the symbol that has UseDetails) so
that we can make changes to it. This permits a generic to be defined in
one module and extended with more specific procedures in another.

When a specific procedure has the same name as its generic, it can't be
stored directly in the scope because that is indexed by name and the
generic is already there. So instead we store the specific in the
GenericDetails of the generic symbol.

Enforce the rule that a generic and a procedure can only have the same
name if the procedure is one of the specifics of the generic.

Refactorings done is support of this change:
- Add FindSymbol() and EraseSymbol() as helpers to find or erase a
  symbol in the current scope. Make use of FindSymbol() where appropriate.
- Add SayAlreadyDeclared() to report a common error.

Original-commit: flang-compiler/f18@be479b9887
Reviewed-on: https://github.com/flang-compiler/f18/pull/95
2018-05-22 16:12:56 -07:00
Steve Scalpone
f92e44e217 [flang] Create LICENSE
We expect to adopt the llvm.org license in the near future.

Original-commit: flang-compiler/f18@a1a01e949b
2018-05-18 13:06:22 -07:00
Steve Scalpone
2a69600b60 [flang] Update build instructions (flang-compiler/f18#94)
* Update build instructions

Add an overview and update the build instructions for f18.

Original-commit: flang-compiler/f18@a60060cfe1
Reviewed-on: https://github.com/flang-compiler/f18/pull/94
2018-05-18 13:02:58 -07:00
Tim Keith
8952deb16e [flang] Merge pull request flang-compiler/f18#93 from ThePortlandGroup/tsk3
Clean up; fix assert and crashes

Original-commit: flang-compiler/f18@1e91e79292
Reviewed-on: https://github.com/flang-compiler/f18/pull/93
2018-05-17 14:17:11 -07:00
Tim Keith
c97d1b9742 [flang] Address review comments.
Original-commit: flang-compiler/f18@5361f3c810
Reviewed-on: https://github.com/flang-compiler/f18/pull/93
2018-05-17 14:16:15 -07:00
Tim Keith
2fb1c16e94 [flang] Clean up; fix assert and crashes
This is the result of running `f18 -fdebug-resolve-names` on a bunch of
Fortran source and fixing the resulting assertion errors and segmentation
faults.

Most of the problems were with encountering attributes, array specs, or
declaration type specs when we weren't prepared to handle them. Those
were fixed by adding calls to {Begin,End}DeclTypeSpec and {Begin,End}Decl
when encountering certain nodes, though the real work for those nodes is
still to be done.

Extract some common functionality into PostAttrSpec and CheckUseError.

Add missing XOR to GenericSpec.

Original-commit: flang-compiler/f18@3c0ff7ded4
Reviewed-on: https://github.com/flang-compiler/f18/pull/93
Tree-same-pre-rewrite: false
2018-05-17 13:06:38 -07:00
Peter Klausler
25bde93144 [flang] Merge pull request flang-compiler/f18#92 from ThePortlandGroup/pmk-runtime
Document and initiate development of run time descriptors.

Original-commit: flang-compiler/f18@8dd289d7f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
2018-05-17 11:41:12 -07:00
peter klausler
88e80408ae [flang] More descriptor work.
Original-commit: flang-compiler/f18@269cb52876
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
2018-05-17 11:32:23 -07:00
peter klausler
588d36b2c6 [flang] Refine type bound define assignment.
Original-commit: flang-compiler/f18@1552251c45
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 16:57:43 -07:00
peter klausler
7b542380a3 [flang] Separate generic from specialized parts of derived types and their components.
Original-commit: flang-compiler/f18@b578f607be
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 16:17:09 -07:00
peter klausler
46d16e8ab6 [flang] rearrange some TODO comments
Original-commit: flang-compiler/f18@64fc7fdf2c
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 14:25:45 -07:00
peter klausler
e37867de2e [flang] more review comments
Original-commit: flang-compiler/f18@d85e171b11
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 13:55:43 -07:00
peter klausler
13f88a1400 [flang] more thinking about requirements for defined assignment &c.
Original-commit: flang-compiler/f18@20fb1a4045
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 13:50:04 -07:00
peter klausler
284aa76bd3 [flang] review comments
Original-commit: flang-compiler/f18@87f158c68f
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 13:49:37 -07:00
peter klausler
004852fc23 [flang] Add a TODO.
Original-commit: flang-compiler/f18@b9b929384b
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 11:32:24 -07:00
peter klausler
64ea1ff79d [flang] Fix clang-only build warning, run clang-format.
Original-commit: flang-compiler/f18@bbc6b25346
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 10:31:35 -07:00
peter klausler
6261c0935c [flang] Document and initiate development of run time descriptors.
Original-commit: flang-compiler/f18@79edea528f
Reviewed-on: https://github.com/flang-compiler/f18/pull/92
Tree-same-pre-rewrite: false
2018-05-16 10:22:33 -07:00
Peter Klausler
73b2a8eb23 [flang] Merge pull request flang-compiler/f18#90 from ThePortlandGroup/pmk5
Fix issue flang-compiler/f18#89

Original-commit: flang-compiler/f18@119fa65b2c
Reviewed-on: https://github.com/flang-compiler/f18/pull/90
2018-05-16 10:09:46 -07:00
peter klausler
adcfd4a0f5 [flang] clang-format
Original-commit: flang-compiler/f18@acb149dc7c
Reviewed-on: https://github.com/flang-compiler/f18/pull/90
2018-05-16 10:00:14 -07:00
peter klausler
7e2d19d5da [flang] Fine tuning of space recognition.
Original-commit: flang-compiler/f18@622befa9ca
Reviewed-on: https://github.com/flang-compiler/f18/pull/90
Tree-same-pre-rewrite: false
2018-05-16 09:59:43 -07:00
peter klausler
b010047266 [flang] Dodge bogus warning about unused anonymous variable in refactored code.
Original-commit: flang-compiler/f18@1d3cfe0038
Reviewed-on: https://github.com/flang-compiler/f18/pull/90
Tree-same-pre-rewrite: false
2018-05-16 09:59:42 -07:00
peter klausler
454f909cbc [flang] Fix tokenization of signed-int-literal-constant, allow internal space.
Original-commit: flang-compiler/f18@afa6425b48
Reviewed-on: https://github.com/flang-compiler/f18/pull/90
Tree-same-pre-rewrite: false
2018-05-16 09:59:41 -07:00
hsuauthai
51e63799fd [flang] Merge pull request flang-compiler/f18#91 from ThePortlandGroup/omppar
Add OpenMP parallel directives and private/firstprivate clauses to pa…

Original-commit: flang-compiler/f18@ba4eeb5a97
Reviewed-on: https://github.com/flang-compiler/f18/pull/91
2018-05-16 09:53:43 -07:00
Hongyon Suauthai
afac6ff43d [flang] Modified directive names and clauses to reflect in OpenMP Spec.
Original-commit: flang-compiler/f18@c2f756f478
Reviewed-on: https://github.com/flang-compiler/f18/pull/91
2018-05-16 09:49:35 -07:00
Hongyon Suauthai
6f7b4fa691 [flang] Add OpenMP parallel directives and private/firstprivate clauses to parser.
Original-commit: flang-compiler/f18@ea8abe45cc
Reviewed-on: https://github.com/flang-compiler/f18/pull/91
Tree-same-pre-rewrite: false
2018-05-16 07:28:54 -07:00
Tim Keith
4fdf2ff21f [flang] Merge pull request flang-compiler/f18#88 from ThePortlandGroup/tsk3
Name resolution on interface blocks.

Original-commit: flang-compiler/f18@a902406caa
Reviewed-on: https://github.com/flang-compiler/f18/pull/88
2018-05-14 14:32:22 -07:00
Tim Keith
5978ac9c40 [flang] Refactor: make some methods out-of-line.
Original-commit: flang-compiler/f18@d2d5457e46
Reviewed-on: https://github.com/flang-compiler/f18/pull/88
2018-05-14 14:26:39 -07:00
Tim Keith
4c99dc2a94 [flang] Support interface blocks.
Add subprogram symbols for each interface-body and set isInterface on
them. Create a symbol with GenericDetails for each generic interface
block and add interface specifications to the specific procedures of
the generic. InterfaceVisitor takes care of this.

Before processing the specification part of modules and subprograms,
collect the names of module subprograms and internal subprograms and add
them to the symbol table with SubprogramNameDetails. This allows us to
reference them from interface blocks in the specification part.
SubprogramNameDetails is converted to SubprogramDetails when the real
subprogram is visited.

This is achieved by setting subpNamesOnly_ and then walking the
ModuleSubprogramPart or InternalSubprogramPart. Creating the symbol and
scope for a module or subprogram now happens when the Module,
SubroutineSubprogram, or FunctionSubprogram node is encountered so
this can happen in the right order.

Add BeginSubprogram and EndSubprogram to handle the parts in common
between subprograms and interface specifications.

Add GenericSpec to type.h to represent all possible generic specs.
Only generic names are resolved so far.

Add tests for new error messages. Change resolve02.f90 to reflect the
new errors reported.

Original-commit: flang-compiler/f18@03148b49dd
Reviewed-on: https://github.com/flang-compiler/f18/pull/88
Tree-same-pre-rewrite: false
2018-05-14 13:53:02 -07:00
Tim Keith
19507b91ce [flang] Separate const and non-const operator* in Indirection
Without this, Walk(const Indirection<T>...) can call a Walk function
with non-const T.

Original-commit: flang-compiler/f18@8c98b0a9b9
Reviewed-on: https://github.com/flang-compiler/f18/pull/88
Tree-same-pre-rewrite: false
2018-05-14 13:53:02 -07:00
Tim Keith
3c1f2b9670 [flang] Extract class SubprogramVisitor out of ResolveNamesVisitor.
This is just refactoring. SubprogramVisitor now contains the functionality
related to subprograms, including statement functions. This is preparation
for handling interface blocks.

Also, change MessageHandler to create the Messages object and return it
through an accessor rather than having it created outside and passed in.
This saves us from having to pass it up through the chain of constructors.

Original-commit: flang-compiler/f18@f73cfa2fe9
Reviewed-on: https://github.com/flang-compiler/f18/pull/88
Tree-same-pre-rewrite: false
2018-05-14 13:53:02 -07:00