Commit graph

131 commits

Author SHA1 Message Date
peter klausler
0f1fd64ae5 [flang] Other changes moved to their own branch.
Original-commit: flang-compiler/f18@6a922d085a
Reviewed-on: https://github.com/flang-compiler/f18/pull/485
2019-06-06 13:56:22 -07:00
peter klausler
d8f72a3105 [flang] Placeholder for standard module iso_fortran_env
Original-commit: flang-compiler/f18@386ebb0490
Reviewed-on: https://github.com/flang-compiler/f18/pull/485
Tree-same-pre-rewrite: false
2019-06-06 13:42:33 -07:00
peter klausler
f586ad5e56 [flang] Unparse the typedExpr from semantics, when present, rather than original parse tree expressions
Original-commit: flang-compiler/f18@4274cc8eaa
Reviewed-on: https://github.com/flang-compiler/f18/pull/479
2019-06-04 16:25:06 -07:00
peter klausler
0ddea8ae24 [flang] Rearrange references to AllSources singleton, fix FindScope for module files
Original-commit: flang-compiler/f18@50ccc1c819
Reviewed-on: https://github.com/flang-compiler/f18/pull/477
Tree-same-pre-rewrite: false
2019-06-04 13:37:09 -07:00
peter klausler
d29530e1c4 [flang] Defer conversions to objects; fix some intrinsic table entries
more fixes

Access components of constant structures

Apply implicit typing to dummy args used in automatic array dimensions

SELECTED_INT_KIND and SELECTED_REAL_KIND

Finish SELECTED_{INT,REAL}_KIND and common cases of ALL()/ANY()

Original-commit: flang-compiler/f18@e9f8e53e55
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
2019-05-28 13:29:29 -07:00
Jinxin Yang
80ccd20f3b [flang] Add -mp option for pgf90 in the presence of -fopenmp
Original-commit: flang-compiler/f18@a9d7287420
Reviewed-on: https://github.com/flang-compiler/f18/pull/450
2019-05-08 08:43:20 -07:00
Tim Keith
79826a73b2 [flang] Dump parse tree even if semantic error occurs
When -fdebug-dump-parse-tree is specified, dump the parse tree even
if semantic errors have occurred. This is necessary to see the parse
tree after it has been transformed.

Original-commit: flang-compiler/f18@bbdb0717da
Reviewed-on: https://github.com/flang-compiler/f18/pull/417
2019-04-17 07:44:58 -07:00
Steve Scalpone
1de9ecd251 [flang] Add CMake rules to install static and shared libraries in
the default install directory or in the directory specified
with CMAKE_INSTALL_PREFIX.  Fixes flang-compiler/f18#359.

Original-commit: flang-compiler/f18@35ce1628e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/364
2019-03-28 09:55:56 -07:00
peter klausler
ad057a42fa [flang] Remove OwningPointer, use unique_ptr better instead.
Original-commit: flang-compiler/f18@89aff868aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/346
Tree-same-pre-rewrite: false
2019-03-20 11:38:45 -07:00
Tim Keith
3ec5e102e2 [flang] Name resolution for defined operators
Instead of tracking just genericName_ while in a generic interface
block or generic statement, now we immediately create a symbol for it.
A parser::Name isn't good enough because a defined-operator or
defined-io-generic-spec doesn't have a name.

Change the parse tree to add a source field to GenericSpec. Use these
as names for symbols for defined-operator and defined-io-generic-spec
(e.g. "operator(+)" or "read(formatted)").

Change the source for defined-op-name to include the dots so that they
can be distinguished from normal symbols with the same name (e.g. you
can have both ".foo." and "foo"). These symbols have names in the symbol
table like ".foo.", not "operator(.foo.)", because references to them
have that form.

Add GenericKind enum to GenericDetails and GenericBindingDetails.
This allows us to know a symbol is "assignment(=)", for example,
without having to do a string comparison.

Add GenericSpecInfo to handle analyzing the various kinds of
generic-spec and generating symbol names and GenericKind for them.

Add reference to LanguageFeatureControl to SemanticsContext so that
they can be checked during semantics. For this change, if
LogicalAbbreviations is enabled, report an error if the user tries
to define an operator named ".T." or ".F.".

Add resolve-name-utils.cc to hold utility functions and classes that
don't have to be in the ResolveNamesVisitor class hierarchy. The goal
is to reduce the size of resolve-names.cc where possible.

Original-commit: flang-compiler/f18@3081f694e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/338
2019-03-18 11:48:02 -07:00
peter klausler
827407a86a [flang] more spec work, handle classic C comments
Original-commit: flang-compiler/f18@d901ee7f50
Reviewed-on: https://github.com/flang-compiler/f18/pull/335
Tree-same-pre-rewrite: false
2019-03-15 13:57:41 -07:00
peter klausler
4b26466375 [flang] Accomodate missing clock_gettime(); remove f18-parse-demo dependence on lib/evaluate; allow #ifdef with no name
Original-commit: flang-compiler/f18@330fd8116f
Reviewed-on: https://github.com/flang-compiler/f18/pull/335
Tree-same-pre-rewrite: false
2019-03-15 10:50:15 -07:00
peter klausler
d08de1a094 [flang] Add reference to libFortranEvaluate for destructor
Original-commit: flang-compiler/f18@db6fb0f8cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/330
2019-03-14 16:40:55 -07:00
peter klausler
615ba7754b [flang] Move dump-parse-tree.h from semantics into parser.
Original-commit: flang-compiler/f18@9075adfcdf
Reviewed-on: https://github.com/flang-compiler/f18/pull/330
Tree-same-pre-rewrite: false
2019-03-14 16:28:06 -07:00
peter klausler
ac55c6e4d2 [flang] address review comments
Original-commit: flang-compiler/f18@be7dbdab0a
Reviewed-on: https://github.com/flang-compiler/f18/pull/330
Tree-same-pre-rewrite: false
2019-03-14 16:18:20 -07:00
peter klausler
8492b7f2b9 [flang] f18-parse-demo
Original-commit: flang-compiler/f18@96d9aefc4f
Reviewed-on: https://github.com/flang-compiler/f18/pull/330
Tree-same-pre-rewrite: false
2019-03-14 16:18:20 -07:00
peter klausler
3348b1691d [flang] WRF preprocessing tweaks
Original-commit: flang-compiler/f18@53f76e1c93
Reviewed-on: https://github.com/flang-compiler/f18/pull/333
Tree-same-pre-rewrite: false
2019-03-14 14:53:25 -07:00
Tim Keith
1c9f8d408e [flang] Add cmake option to link with FIR and LLVM
The cmake option -DLINK_WITH_FIR=ON causes the f18 driver to be linked
against FIR and LLVM. When it is set to OFF (the default), the call into
FIR is #ifdef'd out.

The source in lib/FIR is always built; this option only affects linking.

Original-commit: flang-compiler/f18@69569edd4c
Reviewed-on: https://github.com/flang-compiler/f18/pull/329
2019-03-13 12:41:15 -07:00
peter klausler
d1c2c7b4b1 [flang] Temporarily disconnect FIR from f18.cc build
Original-commit: flang-compiler/f18@c610bc2744
Reviewed-on: https://github.com/flang-compiler/f18/pull/327
2019-03-11 15:01:27 -07:00
Eric Schweitz
dfa5010e47 [flang] Revisions for review comments.
Original-commit: flang-compiler/f18@1a03f7d5bb
Reviewed-on: https://github.com/flang-compiler/f18/pull/324
2019-03-11 09:38:45 -07:00
Eric Schweitz
cf18b7a6bd [flang] Fix build breakage
Original-commit: flang-compiler/f18@72d003f89d
Reviewed-on: https://github.com/flang-compiler/f18/pull/323
2019-03-11 09:16:01 -07:00
Eric Schweitz
a981cd5b9e [flang] Move over build recipes and rename the library
Original-commit: flang-compiler/f18@51476aa178
Reviewed-on: https://github.com/flang-compiler/f18/pull/319
Tree-same-pre-rewrite: false
2019-03-11 08:56:36 -07:00
Eric Schweitz
35cf9e4c40 [flang] Fortran Intermediate Representation: initial draft based on "CFG" note.
Original-commit: flang-compiler/f18@b7a7595394
Reviewed-on: https://github.com/flang-compiler/f18/pull/319
Tree-same-pre-rewrite: false
2019-03-11 08:56:12 -07:00
Tim Keith
f8995fcefa [flang] Remove build dependency on clang
For now all we need to depend on is LLVM.
Use llvm_map_components_to_libnames to find libraries to link against.

Original-commit: flang-compiler/f18@dff1402c2a
Reviewed-on: https://github.com/flang-compiler/f18/pull/321
2019-03-08 15:16:58 -08:00
peter klausler
4417443be9 [flang] Fix CHECK() on wa22 by implementing PGI language extension
Original-commit: flang-compiler/f18@03fcb58977
Reviewed-on: https://github.com/flang-compiler/f18/pull/287
Tree-same-pre-rewrite: false
2019-02-15 12:29:10 -08:00
peter klausler
0ae3d43d76 [flang] Run expression semantic analysis with rest of semantics.
checkpoint array constructor semantics work

checkpoint

array constructors of lengthless intrinsic types

checkpoint

Correct ambiguous substring refs misparsed as array elements

Original-commit: flang-compiler/f18@2232549efe
Reviewed-on: https://github.com/flang-compiler/f18/pull/271
Tree-same-pre-rewrite: false
2019-01-31 09:59:28 -08:00
peter klausler
e7b93436c3 [flang] Rearrange code to eliminate dependence cycles between f18 library binaries
Original-commit: flang-compiler/f18@88651eecae
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
2019-01-22 16:31:19 -08:00
peter klausler
f9d6c0a338 [flang] Move default intrinsic type kinds from lib/semantics to lib/common
Original-commit: flang-compiler/f18@887e72dd61
Reviewed-on: https://github.com/flang-compiler/f18/pull/265
Tree-same-pre-rewrite: false
2019-01-22 16:31:18 -08:00
peter klausler
972d2d52c5 [flang] bugfixing from regression testing
Original-commit: flang-compiler/f18@f1bcaa0292
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false
2018-11-14 11:12:09 -08:00
peter klausler
f50047f45c [flang] merge with master
Original-commit: flang-compiler/f18@53f15da06a
Reviewed-on: https://github.com/flang-compiler/f18/pull/219
Tree-same-pre-rewrite: false
2018-10-26 15:19:10 -07:00
Jean Perier
f7e7cb349b [flang] Changed .clang-format so that it will not add a comment after the closing brace of each namespace. Removed all such previous comments from all .cc and .h files
Original-commit: flang-compiler/f18@aa7f55e15f
Reviewed-on: https://github.com/flang-compiler/f18/pull/217
2018-10-25 05:55:23 -07:00
Tim Keith
16980c718a [flang] Refactoring: add SemanticsContext class
The new SemanticsContext holds the state of semantics whose lifetime
spans all of the compilations. It contains the scope tree (and so all
symbols), the intrinsics table, messages, and the state of options that
affect semantics (default kinds, search directories, etc.)

Original-commit: flang-compiler/f18@f04ceab81f
Reviewed-on: https://github.com/flang-compiler/f18/pull/215
Tree-same-pre-rewrite: false
2018-10-22 07:37:38 -07:00
peter klausler
7c402d9c50 [flang] Add -i8, -r8, &c. options to f18 development driver
Original-commit: flang-compiler/f18@ff7f338126
Reviewed-on: https://github.com/flang-compiler/f18/pull/213
2018-10-16 14:42:22 -07:00
peter klausler
d2f36b9d76 [flang] Eliminating old default type declarations
Original-commit: flang-compiler/f18@10e4a3385a
Reviewed-on: https://github.com/flang-compiler/f18/pull/213
Tree-same-pre-rewrite: false
2018-10-15 17:11:24 -07:00
peter klausler
bf339f8d47 [flang] Extract IntrinsicTypeDefaultKinds, move it into semantics
Original-commit: flang-compiler/f18@dd819b4727
Reviewed-on: https://github.com/flang-compiler/f18/pull/213
Tree-same-pre-rewrite: false
2018-10-15 15:28:47 -07:00
peter klausler
a62636f634 [flang] debug initial intrinsic table probes
Original-commit: flang-compiler/f18@dce9a1e173
Reviewed-on: https://github.com/flang-compiler/f18/pull/212
Tree-same-pre-rewrite: false
2018-10-12 16:02:34 -07:00
peter klausler
b64a39e1ea [flang] Prep for review
Original-commit: flang-compiler/f18@e86eae005e
Reviewed-on: https://github.com/flang-compiler/f18/pull/200
2018-10-04 13:55:51 -07:00
peter klausler
7e87d5a297 [flang] Parse nonlabel DO within label DO better; add -fdebug-semantics; more testing
Original-commit: flang-compiler/f18@2825a45956
Reviewed-on: https://github.com/flang-compiler/f18/pull/200
Tree-same-pre-rewrite: false
2018-10-04 13:54:07 -07:00
peter klausler
93a7f1f85c [flang] work on structure components
Original-commit: flang-compiler/f18@619b6957b4
Reviewed-on: https://github.com/flang-compiler/f18/pull/195
Tree-same-pre-rewrite: false
2018-09-25 15:23:58 -07:00
Tim Keith
7edb7ec69b [flang] Add top-level Semantics class
Refactor to create the Semantics class that is responsible for holding
state during semantics (the scope tree and messages) and managing the
logic of the various phases of semantic processing. Eliminate static
Scope::globalScope.

The messages generated during semantic processing are accumulated in a
Messages data member of Semantics so that individual phases don't need
to emit them to std::cerr. This is now done by the driver so that it has
control over where they go and eliminates other includes of iostream.
To do this, the messages object is passed in to the various semantics
operations.

Move DumpSymbols into semantics.cc: it doesn't belong in resolve-names.cc
and it depends on the global scope, so it's as good a place as any.
The call to RewriteParseTree is also moved to Semantics.

Original-commit: flang-compiler/f18@771d0e1293
Reviewed-on: https://github.com/flang-compiler/f18/pull/186
Tree-same-pre-rewrite: false
2018-09-14 15:04:50 -07:00
Eric Schweitz
43da7a187e [flang] Remove incorrect error message
Original-commit: flang-compiler/f18@9ef54520df
Reviewed-on: https://github.com/flang-compiler/f18/pull/184
Tree-same-pre-rewrite: false
2018-09-13 15:46:17 -07:00
Eric Schweitz
b1938138a7 [flang] Add semantics checking for END xxx statements.
Add a negative test for END xxx names.
Reverse the sequence of calls such that resolve-label is before
resolve-name.

Original-commit: flang-compiler/f18@5fe62f108c
Reviewed-on: https://github.com/flang-compiler/f18/pull/184
Tree-same-pre-rewrite: false
2018-09-13 15:46:17 -07:00
peter klausler
6c6234be9e [flang] clean up for review
Original-commit: flang-compiler/f18@d3d81b1e6f
Reviewed-on: https://github.com/flang-compiler/f18/pull/183
Tree-same-pre-rewrite: false
2018-09-12 16:29:20 -07:00
peter klausler
003c8329ba [flang] add left(), right(), and comments
Original-commit: flang-compiler/f18@372fd06508
Reviewed-on: https://github.com/flang-compiler/f18/pull/183
Tree-same-pre-rewrite: false
2018-09-12 16:29:16 -07:00
Tim Keith
ae3b96456f [flang] Simplify representation of intrinsic types
Intrinsic types are now just a TypeCategory and a int kind. If no kind
is specified the default is used so that every type has an explicit
kind. This caused changes in the expected results of some of the tests.

Add support for "double precision" and "double complex".

Intrinsic types are now stored as values in DeclTypeSpec so none of the
KindedTypeHelper machinery is needed any more.

Eliminate DerivedTypeDef, DataComponentDef, ProcComponentDef,
TypeBoundProc. The components and bindings of a derived type are now
represented by the corresponding Scope.

Original-commit: flang-compiler/f18@4ad8ffb187
Reviewed-on: https://github.com/flang-compiler/f18/pull/182
Tree-same-pre-rewrite: false
2018-09-11 17:33:42 -07:00
Eric Schweitz
df4575f6b9 [flang] Add label resolution design document, pass, and tests
Original-commit: flang-compiler/f18@e0d0df900c
Reviewed-on: https://github.com/flang-compiler/f18/pull/170
Tree-same-pre-rewrite: false
2018-09-11 14:01:25 -07:00
peter klausler
ce231b9559 [flang] Clean up messaging: make Say() member function templates more flexible, hide MessageFormattedText instances
Original-commit: flang-compiler/f18@59d774382f
Reviewed-on: https://github.com/flang-compiler/f18/pull/165
Tree-same-pre-rewrite: false
2018-08-09 10:17:40 -07:00
Tim Keith
96b187efdf [flang] Add support for submodules
Symbols for submodules have `ModuleDetails` with `isSubmodule` set.
Scopes for submodules have `Module` kind and have a parent scope that
is also `Module` kind.

Scopes for modules now contain a mapping of submodule name to scope
so that we can find them without having to search the scope tree or
re-read their `.mod` file.

The module file for submodule `s` with ancestor module `m` is named `m-s.mod`.
The tree structure of scopes means module file writing is now recursive.
Similarly, reading the module file for a submodule may require reading
the module files of its parent and ancestor. `ResolveNames` now requires
the parent scope to be passed in -- it is not always the global scope.

`test_modfiles.sh` now handles an argument that is a filename glob so
that the test can involve multiple files. This allows `modfile09` to
test reading of `.mod` files for modules and submodules.

Original-commit: flang-compiler/f18@2e4424dbc8
Reviewed-on: https://github.com/flang-compiler/f18/pull/160
Tree-same-pre-rewrite: false
2018-08-02 16:21:27 -07:00
Tim Keith
070073426a [flang] Add support for -module option
The `-module` option specifies where to write module files. It is also
the first place search for modules files. The current options name and
behavior match PGI compilers.

To support this, reorganize `ModFileWriter` to be more like `ModFileReader`.
The gives the client a way to set the output directory and fetch the
error messages. A bunch of static member functions in `ModFileWriter`
were changed to non-member functions so they didn't need to be exposed
in `mod-files.h`.

Original-commit: flang-compiler/f18@2717846e81
Reviewed-on: https://github.com/flang-compiler/f18/pull/147
2018-07-25 17:07:38 -07:00
Tim Keith
f62f8b655d [flang] Implement reading of module files
When a use-stmt is encountered for a module that isn't in the global
scope, search for and read the appropriate `.mod` file. To perform the
search, pass the search directories in to ResolveNames.

For modules that were read from `.mod` files, we have to keep the cooked
source from being deleted so that the names so that references to names
stay valid. So we store the cooked source in the Scope of the module as
a `unique_ptr`.

Add `Symbol::Flag::ModFile` to distinguish module symbols that were read
from a `.mod` file rather than from the current compilation. Use it to
prevent writing those back out.

Fix test_errors.sh to run the compiler in the temp subdirectory --
otherwise tests could be affected by `.mod` files left from previous
tests.

Original-commit: flang-compiler/f18@207065999c
Reviewed-on: https://github.com/flang-compiler/f18/pull/145
2018-07-25 10:11:38 -07:00