Commit graph

565 commits

Author SHA1 Message Date
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