Commit graph

330 commits

Author SHA1 Message Date
peter klausler
e850b8d90b [flang] real work
Original-commit: flang-compiler/f18@030347a906
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:42 -07:00
peter klausler
59f16575ee [flang] More work on reals.
Original-commit: flang-compiler/f18@3ba634a214
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:40 -07:00
peter klausler
96d560b84b [flang] more work on reals
Original-commit: flang-compiler/f18@3afe85bf15
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:39 -07:00
peter klausler
0fb4b25ac8 [flang] begin real.h
Original-commit: flang-compiler/f18@b0f0cd8961
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:37 -07:00
peter klausler
5ee73b23c1 [flang] bugfixing from clang build
Original-commit: flang-compiler/f18@a05e108288
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:36 -07:00
peter klausler
0bdde28cd7 [flang] Reading numbers from strings.
Original-commit: flang-compiler/f18@8cbadfe777
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:35 -07:00
peter klausler
ce91eae382 [flang] Template specializations and more automatic configuration
Original-commit: flang-compiler/f18@a230a53907
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:33 -07:00
peter klausler
d0c120b371 [flang] Rename fixed-point to integer.
Original-commit: flang-compiler/f18@3fe9c505a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:31 -07:00
peter klausler
e1ff93a4d9 [flang] More tests; full build and test cycle.
Original-commit: flang-compiler/f18@ac36364304
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:30 -07:00
peter klausler
9c51fbc36e [flang] More tests
Original-commit: flang-compiler/f18@e4371fca37
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:29 -07:00
peter klausler
04711726c9 [flang] More intrinsics
Original-commit: flang-compiler/f18@55f974be59
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:28 -07:00
peter klausler
0dc145c255 [flang] Add pop count and parity code and tests.
Original-commit: flang-compiler/f18@a77f283183
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:27 -07:00
peter klausler
6a902b374e [flang] Complete conversion to value semantics
Original-commit: flang-compiler/f18@e98206ca97
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:25 -07:00
peter klausler
9858682f15 [flang] Converted multiplication
Original-commit: flang-compiler/f18@7d4c318210
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:23 -07:00
peter klausler
ba065d3c75 [flang] Converted shift intrinsics.
Original-commit: flang-compiler/f18@2e9be8ad66
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:22 -07:00
peter klausler
7b15d8054b [flang] Continue conversion to value semantics
Original-commit: flang-compiler/f18@03fe266611
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:21 -07:00
peter klausler
c3daaf8e79 [flang] Begin conversion to value semantics.
Original-commit: flang-compiler/f18@9ea9dae7e7
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:20 -07:00
peter klausler
23ab6ffa10 [flang] Reformat
Original-commit: flang-compiler/f18@104ca5f4c6
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:19 -07:00
peter klausler
66107803fd [flang] Testing framework, debugging of fixed-point code.
Original-commit: flang-compiler/f18@a8fb2d75a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:18 -07:00
peter klausler
330a3a135d [flang] add fixed-point.h
Original-commit: flang-compiler/f18@21c85a5c21
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:14 -07:00
peter klausler
5f276884af [flang] begin work
Original-commit: flang-compiler/f18@82e434bf59
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:12 -07:00
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
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
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
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
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
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
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
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
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
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
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
peter klausler
653238cdef [flang] address review comment
Original-commit: flang-compiler/f18@bd8a96cf70
Reviewed-on: https://github.com/flang-compiler/f18/pull/87
2018-05-11 14:23:18 -07:00
peter klausler
f651e74244 [flang] a little more refinement
Original-commit: flang-compiler/f18@5754d426e8
Reviewed-on: https://github.com/flang-compiler/f18/pull/87
Tree-same-pre-rewrite: false
2018-05-11 12:54:49 -07:00