Commit graph

578 commits

Author SHA1 Message Date
peter klausler
4c5dfecb3e [flang] Let multiple CookedSource instances share a ref-counted AllSources.
Original-commit: flang-compiler/f18@98a170e3e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/151
Tree-same-pre-rewrite: false
2018-07-27 14:58:14 -07:00
peter klausler
108e9b4678 [flang] Support resolution of provenances in messages from CharBlocks to ProvenanceRanges
Original-commit: flang-compiler/f18@aa57287959
Reviewed-on: https://github.com/flang-compiler/f18/pull/151
Tree-same-pre-rewrite: false
2018-07-27 14:01:19 -07:00
peter klausler
28ed1390cd [flang] complete merge to current master
Original-commit: flang-compiler/f18@ca43f45616
Reviewed-on: https://github.com/flang-compiler/f18/pull/151
Tree-same-pre-rewrite: false
2018-07-27 13:38:24 -07:00
peter klausler
fa30061f09 [flang] fix double deallocation bug from previous commit
Original-commit: flang-compiler/f18@f216b6bb82
Reviewed-on: https://github.com/flang-compiler/f18/pull/151
Tree-same-pre-rewrite: false
2018-07-27 13:27:33 -07:00
peter klausler
544f9d5e74 [flang] Tweaks to provenance data structures, in preparation for better module file support.
Original-commit: flang-compiler/f18@a7b7b2b680
Reviewed-on: https://github.com/flang-compiler/f18/pull/151
Tree-same-pre-rewrite: false
2018-07-27 13:27:30 -07:00
Tim Keith
11225c978b [flang] Remove unnecessary unique_ptr.
The unique_ptr around the vector of char was unnecessary. We can just
move the vector itself and it still keeps the same stream of chars.

Original-commit: flang-compiler/f18@24672adba9
Reviewed-on: https://github.com/flang-compiler/f18/pull/149
2018-07-27 08:12:37 -07:00
Tim Keith
6f4f772685 [flang] Change how cooked source is saved
Rather than save the entire CookedSource object in the module scope,
all we need is the vector of characters that CharBlock has references
into. This avoids the problem that CookedSource object has a dangling
reference to an AllSources object (which shouldn't be needed by the
CharBlocks in the symbol table, but is there).

This also decouples Scope from parser classes other than CharBlock.

Original-commit: flang-compiler/f18@fdbf5c841e
Reviewed-on: https://github.com/flang-compiler/f18/pull/149
Tree-same-pre-rewrite: false
2018-07-26 16:03:31 -07:00
Tim Keith
9e48304374 [flang] Refactor ModFileReader to use parser::Parsing
parser::Parsing does most of the work needed to prescan and parse a file.
The only problem is that for module files we need to take ownership of
the cooked character stream so that it lives as long as the module scope
does.

To achieve this, change Parsing::cooked_ to be a unique_ptr and add a
member function to allow the caller to take ownership of it.

Original-commit: flang-compiler/f18@9088891ab2
Reviewed-on: https://github.com/flang-compiler/f18/pull/149
Tree-same-pre-rewrite: false
2018-07-26 10:57:51 -07:00
Austin Wells
fb8950ee93 [flang] Update README.md (flang-compiler/f18#150)
Corrected the URL  in README.md to point to the correct public URL for this repository.

Original-commit: flang-compiler/f18@7005e9ad7b
Reviewed-on: https://github.com/flang-compiler/f18/pull/150
2018-07-27 08:46:33 -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
peter klausler
594c554fa3 [flang] OpenMP conditional compilation lines
Original-commit: flang-compiler/f18@5602f7e041
Reviewed-on: https://github.com/flang-compiler/f18/pull/146
2018-07-25 11:44:20 -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
peter klausler
dda1d4c959 [flang] Fix typo
Original-commit: flang-compiler/f18@b9837c01da
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
2018-07-24 15:50:38 -07:00
peter klausler
7f484d7011 [flang] real expression folding
Original-commit: flang-compiler/f18@8757dc2c90
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:57 -07:00
peter klausler
35ad0036aa [flang] checkpoint
Original-commit: flang-compiler/f18@fc470dc851
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:57 -07:00
peter klausler
943b50289b [flang] Real->Integer conversion folding
Original-commit: flang-compiler/f18@5ad6505e78
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:55 -07:00
peter klausler
61c45394c0 [flang] Parameterize Expr on a type, not category+kind
Original-commit: flang-compiler/f18@f29b065d00
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:55 -07:00
peter klausler
2eac1d0475 [flang] Better folding infrastructure checkpoint
Original-commit: flang-compiler/f18@85d16ace6c
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:55 -07:00
peter klausler
e4f12b087c [flang] Be more clear that constants in expressions are scalars now.
Original-commit: flang-compiler/f18@3181b8d961
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:54 -07:00
peter klausler
9a503392b4 [flang] reformat
Original-commit: flang-compiler/f18@3c93a9edbc
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:53 -07:00
peter klausler
0aae9893a5 [flang] checkpoint
Original-commit: flang-compiler/f18@7fae33797a
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:53 -07:00
peter klausler
aa6c6f97a9 [flang] Begin semantic analysis of expressions.
Original-commit: flang-compiler/f18@34615fdc37
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:52 -07:00
peter klausler
557ba58708 [flang] Use const_cast instead of static_cast for clarity.
Original-commit: flang-compiler/f18@b76ba42af0
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:51 -07:00
peter klausler
efb0fd8753 [flang] More comments about 0**0.
Original-commit: flang-compiler/f18@3e9c0e8894
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:50 -07:00
peter klausler
ac01d216fb [flang] 0**0 case
Original-commit: flang-compiler/f18@fcba49ce6f
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:49 -07:00
peter klausler
ceaff4f498 [flang] Fold integer powers
Original-commit: flang-compiler/f18@6a9ec4d76b
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:48 -07:00
peter klausler
50480bc987 [flang] Better folding.
Original-commit: flang-compiler/f18@4a3117968a
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:47 -07:00
peter klausler
05f0e2f7ec [flang] Finish data hiding in variable.h.
Original-commit: flang-compiler/f18@5979330322
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:46 -07:00
peter klausler
006642f98a [flang] more data hiding
Original-commit: flang-compiler/f18@2dc0d046e3
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:45 -07:00
peter klausler
7dbc09357e [flang] Pull indirection into some constructors.
Original-commit: flang-compiler/f18@074e249499
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:44 -07:00
peter klausler
2f8baf1835 [flang] Data hiding
Original-commit: flang-compiler/f18@d33426637a
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:44 -07:00
peter klausler
f24cd7dd2d [flang] checkpoint once everything builds again
Original-commit: flang-compiler/f18@2075b88772
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:43 -07:00
peter klausler
6c4773012c [flang] issue#134
Original-commit: flang-compiler/f18@a40c38bdb5
Reviewed-on: https://github.com/flang-compiler/f18/pull/144
Tree-same-pre-rewrite: false
2018-07-24 14:33:42 -07:00
peter klausler
997e09bebd [flang] issue#142, some refactoring of common patterns in basic-parsers.h, and reformatting
Original-commit: flang-compiler/f18@1faad40678
Reviewed-on: https://github.com/flang-compiler/f18/pull/143
2018-07-24 13:51:27 -07:00
Hongyon Suauthai
9d24bf5f53 [flang] Add predefined macro _OPENMP to 201511 - yyyymm of the OpenMP Spec.
Original-commit: flang-compiler/f18@859912b54e
Reviewed-on: https://github.com/flang-compiler/f18/pull/140
2018-07-23 10:43:44 -07:00
hsuauthai
08b2684271 [flang] Merge pull request flang-compiler/f18#137 from flang-compiler/omppar
Omppar

Original-commit: flang-compiler/f18@d341464e7f
Reviewed-on: https://github.com/flang-compiler/f18/pull/137

Due to a conflicting rebase during the linearizing of flang-compiler/f18, this commit squashes a number of other commits:

flang-compiler/f18@cfbc8bd16b Add OpenMP Block directives and some declarative directive(TBD:declare reduction and declare target)
flang-compiler/f18@d198352f84 Removed extra code from resolveing conflict of the merge.
flang-compiler/f18@85911a0e80 fix some grammar and unparsing.
flang-compiler/f18@43bcfb7cd3 OpenMP declartive directive can be after function declaration line. OpenMP Loop construct will be treated as if statement instead of block because currently parser cannot construct the loop if loop end with Label [Continue] Use DefinedOperator and ProcedureDesignator instead of create a new Parser and postpone the validity of operator in semantic.
flang-compiler/f18@5d83b50ad3 Merge branch 'master' into omppar
flang-compiler/f18@8c666436a5 remove "HEAD" code and resolve conflict.
2018-07-20 15:49:19 -07:00
Tim Keith
dded0e4bb2 [flang] Correctly resolve generics with forward references
When a procedure is included by name in a generic (either with a
procedure statement in a generic interface or with a generic statement)
we can't immediately resolve it to a subprogram symbol. That is because
the subprogram may be defined later in the specification part. Instead,
collect the names (and whether they should be module procedures) and
resolve them to symbols at the end of the specification part. Also
detect duplicate names then.

This is needed for module file reading as these forward references can
occur there.

Write generics to module file using generic statements. This allows us to
include the access-spec.

Original-commit: flang-compiler/f18@d11d002084
Reviewed-on: https://github.com/flang-compiler/f18/pull/132
2018-07-20 10:46:11 -07:00
Tim Keith
759a405a43 [flang] Support writing interfaces in module files.
Write symbols for external subprogram interfaces as interface-stmts.
Those go in the decls part of the module file, as opposed to contained
subprograms which go in the contains part. See modfile06.f90.

Write symbols with GenericDetails to module files. The specific
procedures of a generic interface are always written as procedure-stmts.
If they also have specific interfaces those are written in a separate
interface-stmt. See modfile07.f90.

Fix a bug where `real, external :: f` was not written like
`real f; external f`. We have to notice the EXTERNAL attribute on the
type-declaration-stmt and convert the entity to a procedure entity.
See modfile08.f90.

Fix a bug where a use-associated symbol is referenced in a
procedure-designator. We were not resolving that correctly.

Change ModFileWriter::PutEntity to include the kind of Details when
it reports an internal error due to a kind it can't handle.
Make DetailsToString public to support that.

Change test_errors.sh to fail if the f18 command exits due to a signal.
We were missing bugs where the correct errors were written out but then
module file writing crashed (due to failure to handle generics mentioned
above). Non-zero exit status is okay because we are expecting
compilation errors.

Change test_modfile.sh to allow for the expected module file contents to
be indented so the tests are easier to read.

Original-commit: flang-compiler/f18@82a7931e51
Reviewed-on: https://github.com/flang-compiler/f18/pull/132
Tree-same-pre-rewrite: false
2018-07-19 13:28:24 -07:00
peter klausler
5bd2ac4952 [flang] Pass -Mnobackslash to pgf90 unless f18 -fbackslash is used.
Original-commit: flang-compiler/f18@df5058ff97
Reviewed-on: https://github.com/flang-compiler/f18/pull/133
2018-07-19 15:50:39 -07:00
peter klausler
d7f5aa55e8 [flang] prep for merge
Original-commit: flang-compiler/f18@fa72384520
Reviewed-on: https://github.com/flang-compiler/f18/pull/133
Tree-same-pre-rewrite: false
2018-07-19 15:42:00 -07:00
peter klausler
888786b346 [flang] Really fix backslash escapes.
Original-commit: flang-compiler/f18@a8c702c103
Reviewed-on: https://github.com/flang-compiler/f18/pull/133
Tree-same-pre-rewrite: false
2018-07-19 15:35:55 -07:00
peter klausler
8119fe881d [flang] Ready for merge.
Original-commit: flang-compiler/f18@f39949fc7d
Reviewed-on: https://github.com/flang-compiler/f18/pull/130
2018-07-19 09:54:24 -07:00
peter klausler
d100bcbc9f [flang] Do not enable OpenMP by default, oops.
Original-commit: flang-compiler/f18@7a627ac040
Reviewed-on: https://github.com/flang-compiler/f18/pull/130
Tree-same-pre-rewrite: false
2018-07-19 09:54:24 -07:00
peter klausler
80ece7418a [flang] Define LanguageFeatureControl, use it everywhere.
Original-commit: flang-compiler/f18@9a95107610
Reviewed-on: https://github.com/flang-compiler/f18/pull/130
Tree-same-pre-rewrite: false
2018-07-19 09:54:24 -07:00
peter klausler
f701b42920 [flang] Better language feature enablement and warnings.
Original-commit: flang-compiler/f18@359e4d2c60
Reviewed-on: https://github.com/flang-compiler/f18/pull/130
Tree-same-pre-rewrite: false
2018-07-19 09:54:23 -07:00
peter klausler
31cfbeab42 [flang] Another SUBMODULE unparsing tweak, and restore buildability with gcc < 8.1
Original-commit: flang-compiler/f18@86b5db4b23
Reviewed-on: https://github.com/flang-compiler/f18/pull/130
Tree-same-pre-rewrite: false
2018-07-19 09:54:22 -07:00
peter klausler
1732d043e2 [flang] Fix clang build warning in mod-file.cc
Original-commit: flang-compiler/f18@53ad3bd59c
Reviewed-on: https://github.com/flang-compiler/f18/pull/130
Tree-same-pre-rewrite: false
2018-07-19 09:54:22 -07:00
peter klausler
5b25aad67c [flang] Address issue#125, flang-compiler/f18#115, and improve error recovery on previous issues.
Original-commit: flang-compiler/f18@98e26d6245
Reviewed-on: https://github.com/flang-compiler/f18/pull/130
Tree-same-pre-rewrite: false
2018-07-19 09:54:21 -07:00
Tim Keith
6568929bf5 [flang] Update module file documentation
Address some review comments, add more information.

Original-commit: flang-compiler/f18@75c97b6f9b
Reviewed-on: https://github.com/flang-compiler/f18/pull/131
2018-07-18 12:39:34 -07:00
Tim Keith
cde0b5cc87 [flang] Use brace initialization in tools/f18
Also reformat dump.cc.

Original-commit: flang-compiler/f18@1cc4fe2788
Reviewed-on: https://github.com/flang-compiler/f18/pull/127
2018-07-17 07:05:35 -07:00