Commit graph

735 commits

Author SHA1 Message Date
peter klausler
e1b584468c [flang] Even better program unit END statement error recovery.
Original-commit: flang-compiler/f18@31f456ebc5
Reviewed-on: https://github.com/flang-compiler/f18/pull/156
Tree-same-pre-rewrite: false
2018-07-30 16:33:55 -07:00
peter klausler
6135c20380 [flang] better program unit END statement error recovery
Original-commit: flang-compiler/f18@62799c88ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/156
Tree-same-pre-rewrite: false
2018-07-30 15:31:06 -07:00
peter klausler
7473cd711a [flang] issue#153
Original-commit: flang-compiler/f18@64272abddd
Reviewed-on: https://github.com/flang-compiler/f18/pull/155
2018-07-30 13:56:44 -07:00
peter klausler
5369b346c3 [flang] issue#152 and a little clean-up
Original-commit: flang-compiler/f18@54d74dc1e8
Reviewed-on: https://github.com/flang-compiler/f18/pull/154
2018-07-30 12:56:58 -07:00
peter klausler
56cc22fdfe [flang] Use std::nullopt rather than {}.
Original-commit: flang-compiler/f18@9a740acf83
Reviewed-on: https://github.com/flang-compiler/f18/pull/151
2018-07-30 11:08:22 -07:00
peter klausler
d90437bd91 [flang] address review comments
Original-commit: flang-compiler/f18@a18aba21fd
Reviewed-on: https://github.com/flang-compiler/f18/pull/151
Tree-same-pre-rewrite: false
2018-07-27 17:06:55 -07:00
peter klausler
851a5a00f9 [flang] add isModuleFile flag to parser::Options, use it
Original-commit: flang-compiler/f18@0727140f53
Reviewed-on: https://github.com/flang-compiler/f18/pull/151
Tree-same-pre-rewrite: false
2018-07-27 15:18:36 -07:00
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
Tim Keith
7400a287a1 [flang] Use brace initialization in lib/semantics
Syntax only, no functional changes.

Original-commit: flang-compiler/f18@8cc9743c9c
Reviewed-on: https://github.com/flang-compiler/f18/pull/127
Tree-same-pre-rewrite: false
2018-07-17 07:02:30 -07:00
Tim Keith
bfd0703234 [flang] Fix test script portability problems.
Allow for bash anywhere on path.

Allow for utilites to be in /bin as well as /usr/bin.

Don't count on sed understanding '\t'.

The options to mktemp aren't portable. Instead just create a per-test
temp directory in the working directory (i.e. <build-dir>/test/semantics).
Setting the KEEP environment variable causes them all to be kept to help
in investigating failures.

Fixes flang-compiler/f18#128.

Original-commit: flang-compiler/f18@3736ceeca8
Reviewed-on: https://github.com/flang-compiler/f18/pull/129
2018-07-17 16:48:50 -07:00
Tim Keith
3c77458b33 [flang] Handle VOLATILE or ASYNCHRONOUS added to use-associated entity
When a symbol is use-associated, the VOLATILE and ASYNCHRONOUS
attributes can be added. When that happens it must be recorded
in the .mod file.

Original-commit: flang-compiler/f18@44fa9e5ba4
Reviewed-on: https://github.com/flang-compiler/f18/pull/126
2018-07-17 06:39:38 -07:00
Tim Keith
5934a01c58 [flang] Fix typo
Original-commit: flang-compiler/f18@242ff9d229
Reviewed-on: https://github.com/flang-compiler/f18/pull/126
Tree-same-pre-rewrite: false
2018-07-16 16:45:58 -07:00
Tim Keith
f95c663c09 [flang] Add a .mod file test with subprograms
The .mod file just contains the API. Test that prefixes and suffixes
on the declaration get correctly persisted.

Original-commit: flang-compiler/f18@eb2a6deb4f
Reviewed-on: https://github.com/flang-compiler/f18/pull/126
Tree-same-pre-rewrite: false
2018-07-16 16:44:07 -07:00
Tim Keith
dda6fa8eba [flang] Initial documentation for .mod files
Original-commit: flang-compiler/f18@f1809b833f
Reviewed-on: https://github.com/flang-compiler/f18/pull/126
Tree-same-pre-rewrite: false
2018-07-16 16:26:14 -07:00
Tim Keith
43f2ce0739 [flang] Add tests for .mod file writing
The source files contain the expected contents of generated .mod files.
`test_modfile.sh` compiles the source file and verifies that the correct
.mod files are generated.

Original-commit: flang-compiler/f18@a23f53c1a7
Reviewed-on: https://github.com/flang-compiler/f18/pull/126
Tree-same-pre-rewrite: false
2018-07-16 16:24:14 -07:00
Tim Keith
0c575ed548 [flang] Implement writing of .mod files.
Module file writing is implemented in mod-file.cc. They need to be
written after all semantic checking. Until then, for testing, write
them out whenever names are resolved.

There is a header comment in the .mod files but it is mostly a
placeholder until we can read them in and do something with it.

Rename `Symbol::details<D>` to `Symbol::get<D>`. This asserts that the
details of the symbol match D and returns that type. But we need a way
to access the details as a variant as well (not just one of its types).
`details()` is the best name for that, especially as we already have
`set_details()`. Renaming the old `details` to `get` also better matches
`has` which is used to check which variant is present.

Original-commit: flang-compiler/f18@8d14be1a16
Reviewed-on: https://github.com/flang-compiler/f18/pull/126
Tree-same-pre-rewrite: false
2018-07-16 16:23:18 -07:00
peter klausler
296040aa96 [flang] Improve error recovery further, using a test case from Tim.
Original-commit: flang-compiler/f18@9ef79fa991
Reviewed-on: https://github.com/flang-compiler/f18/pull/123
2018-07-12 16:23:25 -07:00
peter klausler
2c1b7bfd14 [flang] Extend documentation on extensions.
Original-commit: flang-compiler/f18@672e468252
Reviewed-on: https://github.com/flang-compiler/f18/pull/122
2018-07-12 15:32:31 -07:00
peter klausler
18d58f9fb3 [flang] Tweak code for readability and maybe better performance.
Original-commit: flang-compiler/f18@e4d9b8587e
Reviewed-on: https://github.com/flang-compiler/f18/pull/122
Tree-same-pre-rewrite: false
2018-07-12 15:05:34 -07:00
peter klausler
3577ee5f5f [flang] More documentation. These changes fix two bugs noted in f18 issue#121.
Original-commit: flang-compiler/f18@f386472c5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/122
Tree-same-pre-rewrite: false
2018-07-12 14:58:06 -07:00
peter klausler
0b8d07cc42 [flang] Allow empty statements and improve error recovery error messages.
Original-commit: flang-compiler/f18@018e81e2c4
Reviewed-on: https://github.com/flang-compiler/f18/pull/122
Tree-same-pre-rewrite: false
2018-07-12 14:47:15 -07:00
Tim Keith
be886c18ac [flang] Sort enumerators in enum class Attr.
Original-commit: flang-compiler/f18@ce43e4e556
Reviewed-on: https://github.com/flang-compiler/f18/pull/120
2018-07-12 10:14:58 -07:00
Tim Keith
d42bb955a6 [flang] Support intent-stmt and resolve subprogram prefixes and suffixes.
Recognize `IntentStmt` and use `HandleAttributeStmt()` to implement it
as is done with other attribute statements. Add `Attr::INTENT_INOUT` as
a separate attribute for `INTENT(INOUT)`.

Collect attributes from the prefix and suffix of `FunctionStmt` and
`SubroutineStmt` (including `BIND(C)`) and set them on the subprogram
symbol.

Create a test for this using `test_symbol.sh`. It compiles with
`-funparse-with-symbols` and compares the output with the symbols in
comments in the input.

Change `test_errors.sh` to be similar to `test_symbol.sh`: check usage
and allow `F18` environment variable to override the path to the
compiler.

Original-commit: flang-compiler/f18@384828a22f
Reviewed-on: https://github.com/flang-compiler/f18/pull/120
Tree-same-pre-rewrite: false
2018-07-11 17:45:13 -07:00
peter klausler
bfc6c3b9ae [flang] Documentation
Original-commit: flang-compiler/f18@d2855c6474
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
2018-07-11 10:26:53 -07:00
peter klausler
148b7d1f4a [flang] merge and reformat
Original-commit: flang-compiler/f18@2e3d67aa79
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
Tree-same-pre-rewrite: false
2018-07-11 10:22:05 -07:00
peter klausler
a85fc58b93 [flang] correct typo in unparse.cc found in test
Original-commit: flang-compiler/f18@1aa60cccc4
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
Tree-same-pre-rewrite: false
2018-07-11 10:21:35 -07:00
peter klausler
d28adc2e7f [flang] Use braces for auto initialization in lib/common and lib/evaluate
Original-commit: flang-compiler/f18@b0d1dd434b
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
Tree-same-pre-rewrite: false
2018-07-11 10:21:34 -07:00
peter klausler
f147abdee2 [flang] Use braces in auto initializers.
Original-commit: flang-compiler/f18@b68fdff537
Reviewed-on: https://github.com/flang-compiler/f18/pull/119
Tree-same-pre-rewrite: false
2018-07-11 10:21:32 -07:00
peter klausler
8d0f44fb91 [flang] Better error recovery (for a case from Tim) and fix a problem where context is lost.
Original-commit: flang-compiler/f18@522822fd5a
Reviewed-on: https://github.com/flang-compiler/f18/pull/118
2018-07-10 16:09:21 -07:00
peter klausler
ea08e1bc72 [flang] Extend documentation
Original-commit: flang-compiler/f18@ac375a00ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
2018-07-10 10:56:55 -07:00
peter klausler
b081bc9d04 [flang] Address review comments
Original-commit: flang-compiler/f18@9e59b9b79d
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-10 10:18:34 -07:00
peter klausler
10d54a505a [flang] Resolve build issues with older compilers.
Original-commit: flang-compiler/f18@d8723284d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:01 -07:00
peter klausler
74b12f1a31 [flang] Refine variable structure definitions, add references to Standard.
Original-commit: flang-compiler/f18@dbc6d45e02
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:01 -07:00
peter klausler
d218ddcae4 [flang] Start cleaning up for merging.
Original-commit: flang-compiler/f18@7355bd5b42
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:01 -07:00
peter klausler
e6fc51c731 [flang] Use Indirection. Get variables to work in int expressions.
Original-commit: flang-compiler/f18@1000717da8
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:00 -07:00
peter klausler
f8f98ca3b6 [flang] More abstraction in expressions.
Original-commit: flang-compiler/f18@2dc425acf5
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:26:00 -07:00
peter klausler
d7b3accb32 [flang] tweaks
Original-commit: flang-compiler/f18@624c1d2ec8
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:59 -07:00
peter klausler
897e78defb [flang] clean up dumping code
Original-commit: flang-compiler/f18@2969888360
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:58 -07:00
peter klausler
22786d89e4 [flang] Fix issue flang-compiler/f18#113.
Original-commit: flang-compiler/f18@835e51b6e6
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:58 -07:00
peter klausler
06fe266998 [flang] work on variables and traversal
Original-commit: flang-compiler/f18@432779b221
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:57 -07:00
peter klausler
4795738c40 [flang] Commit work in progress to branch for f18 repository move.
Original-commit: flang-compiler/f18@e0db6903c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/117
Tree-same-pre-rewrite: false
2018-07-09 16:25:57 -07:00
Tim Keith
d7d69474c8 [flang] Fix bug recognizing derived type constructor call
A ProcedureDesignator is a derived type constructor call if the name
resolves to a derived type. We need to recognize it as such and not
report an error. It may be in another derived type so we have to call
FindSymbol() first to find the derived type.

Most of the diffs are due to `symbol` changing from a reference to a
pointer.

In this example we were reporting an error on the first `t1()` and
resolving the second as an external function call.
```
module m
  type :: t1
  end type
  type(t1) :: x = t1()
  type t2
    type(t1) :: y = t1()
  end type
end module
```

Original-commit: flang-compiler/f18@717b22ca2b
Reviewed-on: https://github.com/flang-compiler/f18/pull/116
2018-07-09 15:25:49 -07:00
Tim Keith
a39376c08b [flang] Add missing copyright.
Original-commit: flang-compiler/f18@cf7087b381
Reviewed-on: https://github.com/flang-compiler/f18/pull/114
2018-07-05 10:36:18 -07:00
Tim Keith
c0c19100be [flang] Check consistency of generic interfaces.
The specific procedures in a generic interface must be all functions or
all subroutines. If there is a derived type with the same name they can
only be functions.

Original-commit: flang-compiler/f18@e02cef047a
Reviewed-on: https://github.com/flang-compiler/f18/pull/114
Tree-same-pre-rewrite: false
2018-07-05 10:28:34 -07:00
Tim Keith
f77f9309fc [flang] Add -funparse-with-symbols to enable new behavior
Original-commit: flang-compiler/f18@7ad44e7e33
Reviewed-on: https://github.com/flang-compiler/f18/pull/112
2018-06-26 15:40:52 -07:00
Tim Keith
89840b5087 [flang] Support unparse with symbol annotations.
When `-fdebug-dump-symbols` is supplied with `-funparse`, include symbol
information in comments in the Fortran output. This will be used for
testing to verify that correct symbols are defined and references in
the right place.

In `UnparseWithSymbols()`, walk the parse tree and collect symbol
definitions and references, organized by statement. When a symbol is
defined across several statement it is associated with the first.
The definition of implicitly defined symbols is associated with the
first reference.

To write out the symbol information, a new optional argument is added to
`Unparse()`: it is a function that is called immediately before each
statement is unparsed. We pass in a function that prints out the symbol
information collected for that statement.

Add `Symbol::GetType()` to make it easier to write the symbol types
and add `Symbol::SetType()` for uniformity.

Original-commit: flang-compiler/f18@2e827de4ad
Reviewed-on: https://github.com/flang-compiler/f18/pull/112
Tree-same-pre-rewrite: false
2018-06-26 15:01:42 -07:00
peter klausler
97f0a05235 [flang] Incorporate suggestions from code review.
Original-commit: flang-compiler/f18@c66bd9ab15
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
2018-06-22 16:44:23 -07:00
peter klausler
cf410675cf [flang] Begin folding, with simple test, as sanity check on usability.
Original-commit: flang-compiler/f18@3839c65cd5
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:28 -07:00
peter klausler
efcbf1f7df [flang] clean up for push
Original-commit: flang-compiler/f18@8b5bbcedba
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:28 -07:00
peter klausler
4c11bc07d4 [flang] Prepare for check-in
Original-commit: flang-compiler/f18@2f5b2d5f40
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:28 -07:00
peter klausler
4da490882b [flang] Operator overloads for expression construction.
Original-commit: flang-compiler/f18@a4d3a736cf
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:27 -07:00
peter klausler
e5e5f6319f [flang] clean up clang warnings from master
Original-commit: flang-compiler/f18@1c9aa95f8d
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:59:25 -07:00
peter klausler
7a3f25ce8a [flang] More refinement, use const on subexpressions.
Original-commit: flang-compiler/f18@f484325c61
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:06 -07:00
peter klausler
953c667703 [flang] Simplification
Original-commit: flang-compiler/f18@a50ce6e499
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:06 -07:00
peter klausler
a55ea1b5d5 [flang] fix builds, all now clear
Original-commit: flang-compiler/f18@7c32a531a0
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:06 -07:00
peter klausler
4b3dea1d38 [flang] Dump complex expressions
Original-commit: flang-compiler/f18@da25b870d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:05 -07:00
peter klausler
32b2ce7282 [flang] More dumping code
Original-commit: flang-compiler/f18@43d147144a
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:05 -07:00
peter klausler
508ed8dd76 [flang] Use unique_ptr for operands. Refactor comparisons.
Original-commit: flang-compiler/f18@92e154e76e
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:05 -07:00
peter klausler
a88a55b500 [flang] Expression formatting
Original-commit: flang-compiler/f18@3d0977a57e
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:04 -07:00
peter klausler
dd5470b128 [flang] Change memcpy to memmove for overlap case.
Original-commit: flang-compiler/f18@cb400284e4
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:04 -07:00
peter klausler
9e1ba097f5 [flang] Numeric constant formatting and tests.
Original-commit: flang-compiler/f18@ade6442020
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:04 -07:00
peter klausler
3d867f3202 [flang] Character LEN, operator overloadings
Original-commit: flang-compiler/f18@08c32de24c
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:58:04 -07:00
peter klausler
229d6c413a [flang] Finish first cut at expression.h.
Original-commit: flang-compiler/f18@07142e7fad
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:18 -07:00
peter klausler
e03280c09c [flang] Expression work
Original-commit: flang-compiler/f18@b60c84fff4
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:17 -07:00
peter klausler
c2e06e25cd [flang] reformat c++
Original-commit: flang-compiler/f18@6c5c9b3165
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:17 -07:00
peter klausler
ca1b8d80f6 [flang] first cut at expressions
Original-commit: flang-compiler/f18@b06c5486e4
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:17 -07:00
peter klausler
cc13dbdde1 [flang] begin expression representation
Original-commit: flang-compiler/f18@627c057d5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:16 -07:00
peter klausler
dacbfeef32 [flang] Documentation
Original-commit: flang-compiler/f18@27f6927053
Reviewed-on: https://github.com/flang-compiler/f18/pull/111
Tree-same-pre-rewrite: false
2018-06-22 14:56:16 -07:00
Tim Keith
c7eb38530c [flang] Fix problems in PR 109 when compiling with clang.
This gets the code base back to compiling cleanly with clang after
pull request 109.

There were two overloadings of `Post(const parser::DeclarationTypeSpec::Type &)`.
The one in DeclarationVisitor needed to call the one in DeclTypeSpecVisitor.
This was fixed by introducing a new function, SetDerivedDeclTypeSpec, to do
the equivalent thing.

Original-commit: flang-compiler/f18@81e447bf4e
Reviewed-on: https://github.com/flang-compiler/f18/pull/110
2018-06-22 14:08:04 -07:00
Tim Keith
2541df532a [flang] Name resolution for derived types.
This consists of:
- a new kind of symbols to represent them with DerivedTypeDetails
- creating symbols for derived types when they are declared
- creating a new kind of scope for the type to hold component symbols
- resolving entity declarations of objects of derived type
- resolving references to objects of derived type and to components
- handling derived types with same name as generic

Type parameters are not yet implemented.

Refactor DeclTypeSpec to be a value class wrapping an IntrinsicTypeSpec
or a DerivedTypeSpec (or neither in the TypeStar and ClassStar cases).
Store DerivedTypeSpec objects in a new structure the current scope
MakeDerivedTypeSpec so that DeclTypeSpec can just contain a pointer to
them, as it currently does for intrinsic types.

In GenericDetails, add derivedType field to handle case where generic
and derived type have the same name. The generic is in the scope and the
derived type is referenced from the generic, similar to the case where a
generic and specific have the same name. When one of these names is
mis-recognized, we sometimes have to fix up the 'occurrences' lists
of the symbols.

Assign implicit types as soon as an entity is encountered that requires
one. Otherwise implicit derived types won't work. When we see 'x%y' we
have to know the type of x in order to resolve y. Add an Implicit flag
to mark symbols that were implicitly typed

For symbols that introduce a new scope, include a pointer back to that
scope.

Add CurrNonTypeScope() for the times when we want the current scope but
ignoring derived type scopes. For example, that happens when looking for
types or parameters, or creating implicit symbols.

Original-commit: flang-compiler/f18@9bd16da020
Reviewed-on: https://github.com/flang-compiler/f18/pull/109
2018-06-22 08:21:19 -07:00
Tim Keith
890b6d55e7 [flang] Refactor DeclTypeSpec and DerivedTypeSpec classes.
Make DerivedTypeSpec a simple wrapper around the name of the type.
Leave out type parameter values until we are ready to resolve them
as well.

Change DeclTypeSpec to be an old-fashioned union with an enum to
indicate what is in it. std::variant doesn't work well here because
we wanted the enum visible in the class' API and there is not a
1-to-1 mapping between enumerators and data stored.

Original-commit: flang-compiler/f18@03bdeef790
Reviewed-on: https://github.com/flang-compiler/f18/pull/109
Tree-same-pre-rewrite: false
2018-06-20 13:39:31 -07:00
Tim Keith
b40c9ee2b2 [flang] Change how memory for Symbol instances is managed.
With this change, all instances Symbol are stored in class Symbols.
Scope.symbols_, which used to own the symbol memory, now maps names to
Symbol* instead. This causes a bunch of reference-to-pointer changes
because of the change in type of key-value pairs. It also requires a
default constructor for Symbol, which means owner_ can't be a reference.

Symbols manages Symbol instances by allocating a block of them at a time
and returning the next one when needed. They are never freed.

The reason for the change is that there are a few cases where we need
to have a two symbols with the same name, so they can't both live in
the map in Scope. Those are:
1. When there is an erroneous redeclaration of a name we may delete the
   first symbol and replace it with a new one. If we have saved a pointer
   to the first one it is now dangling. This can be seen by running
   `f18 -fdebug-dump-symbols -fparse-only test/semantics/resolve19.f90`
   under valgrind. Subroutine s is declared twice: each results in a
   scope that contains a pointer back to the symbol for the subroutine.
   After the second symbol for s is created the first is gone so the
   pointer in the scope is invalid.
2. A generic and one of its specifics can have the same name. We currently
   handle that by moving the symbol for the specific into a unique_ptr
   in the generic. So in that case the symbol is owned by another symbol
   instead of by the scope. It is simpler if we only have to deal with
   moving the raw pointer around.
3. A generic and a derived type can have the same name. This case isn't
   handled yet, but it can be done like flang-compiler/f18#2 above. It's more complicated
   because the derived type and the generic can be declared in either
   order.

Original-commit: flang-compiler/f18@55a68cf023
Reviewed-on: https://github.com/flang-compiler/f18/pull/107
2018-06-19 16:06:41 -07:00
Tim Keith
0d701085e0 [flang] Fix bug in adding symbols to parse tree.
We were collecting symbols in a map of SourceName to Symbol*.
This is wrong because sometimes different occurrences of a name
map to different symbols (e.g. in different scopes).
SourceName::begin() is unique for each occurrence so use that
as the map key instead.

The problem can be reproduced by running:
`f18 -fdebug-resolve-names -fparse-only -fdebug-dump-parse-tree`
on the following source. The two symbols 'i' should have different
types and they were both coming out as INTEGER because they both
pointed to the first symbol for 'i'.

```
module m
  integer :: i
contains
  subroutine s
    real :: i
  end
end
```

Original-commit: flang-compiler/f18@a165c717ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/107
Tree-same-pre-rewrite: false
2018-06-19 14:59:41 -07:00
peter klausler
b23701f7d0 [flang] Rearrange some facilities into a new lib/common.
Original-commit: flang-compiler/f18@279af1e817
Reviewed-on: https://github.com/flang-compiler/f18/pull/106
2018-06-18 11:05:17 -07:00
Tim Keith
6178163bfd [flang] Add name resolution tests
The Fortran source files in test/semantics all contain expected
errors in comments. The script test_errors.sh compiles a file with
'f18 -fdebug-resolve-names -fparse-only' and compares the actual
errors produced against the expected ones.

The change to resolve15.f90 is necessary because test_errors.sh can't
handle two expected errors for the same source line.

A useful command to run these is 'ctest -R f90 --output-on-failure'.
-R means only run tests with f90 in the name
--output-on-failure prints the output of test_errors.sh when a test
fails, showing the expected and actual messages that differ.

Original-commit: flang-compiler/f18@df18ee7bc9
Reviewed-on: https://github.com/flang-compiler/f18/pull/105
2018-06-15 14:54:34 -07:00
peter klausler
adc3fc1777 [flang] Test 64-bit reals too.
Original-commit: flang-compiler/f18@67fd551441
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
2018-06-15 10:02:09 -07:00
peter klausler
57f4186ca2 [flang] Address review comments
Original-commit: flang-compiler/f18@d96917c701
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:53:09 -07:00
peter klausler
b19a9baba4 [flang] More rearrangement, and debug an edge case with Underflow flag.
Original-commit: flang-compiler/f18@57ef08433e
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:53:07 -07:00
peter klausler
7e7d97ed4c [flang] Move member functions complex.h -> complex.cc
Original-commit: flang-compiler/f18@445333b13e
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:53:06 -07:00
peter klausler
b0e644e708 [flang] Remove work-around in resolve-names.cc.
Original-commit: flang-compiler/f18@5dc0e037f5
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:53:05 -07:00
peter klausler
18d3312600 [flang] Cleaning up Real<> for review.
Original-commit: flang-compiler/f18@a87f324a7f
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:53:04 -07:00
peter klausler
fcf72703d2 [flang] Prepare for review.
Original-commit: flang-compiler/f18@266d25f630
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:53:03 -07:00
peter klausler
fbcf2920e1 [flang] Less exhaustive REAL testing by default.
Original-commit: flang-compiler/f18@d61ac7da9b
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:53:01 -07:00
peter klausler
2391eb8de9 [flang] COMPLEX
Original-commit: flang-compiler/f18@452d602fbb
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:53:00 -07:00
peter klausler
ed71134af7 [flang] LOGICAL
Original-commit: flang-compiler/f18@6ec49f6edc
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:59 -07:00
peter klausler
564292ccf7 [flang] Revamp type.h, add LOGICAL
Original-commit: flang-compiler/f18@f7d77887a2
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:58 -07:00
peter klausler
9e35c7e731 [flang] All operations now work and match x86, all modes and flags.
Original-commit: flang-compiler/f18@c69eef6524
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:57 -07:00
peter klausler
52ef92b513 [flang] More real work. All ops, rounding modes, and flags good except for division.
Original-commit: flang-compiler/f18@ea697295db
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:55 -07:00
peter klausler
fab448de59 [flang] Check flag bits.
Original-commit: flang-compiler/f18@b63e39aae7
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:54 -07:00
peter klausler
9ea409dd29 [flang] Multiplication, more tests.
Original-commit: flang-compiler/f18@e7ef16d216
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:53 -07:00
peter klausler
ae98068360 [flang] Refactor rounding code.
Original-commit: flang-compiler/f18@8ef2418791
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:53 -07:00
peter klausler
efa5de0080 [flang] Get real add/subtract working and tested.
Original-commit: flang-compiler/f18@c1b4389638
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:52 -07:00
peter klausler
518b2094b2 [flang] start negative number tests
Original-commit: flang-compiler/f18@1b52ec8d3b
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:49 -07:00
peter klausler
99c23c1a92 [flang] Get back to passing all tests.
Original-commit: flang-compiler/f18@d08dc86ede
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:47 -07:00
peter klausler
3fb4757cc7 [flang] Use EnumSet<> for real flags
Original-commit: flang-compiler/f18@a61f193036
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:46 -07:00
peter klausler
b940e3de3f [flang] some real debugging
Original-commit: flang-compiler/f18@9653814ed3
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:45 -07:00
peter klausler
eb9ad7ef07 [flang] begin testing reals
Original-commit: flang-compiler/f18@9d261b594b
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:44 -07:00
peter klausler
321056b53c [flang] Convert REAL code to use IEEE encodings.
Original-commit: flang-compiler/f18@b36e50f465
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:43 -07:00
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
5bc907602c [flang] unit testing for LZBC
Original-commit: flang-compiler/f18@c8541fb8fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false
2018-06-14 13:52:16 -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
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
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
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
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