Commit graph

2990 commits

Author SHA1 Message Date
Peter Klausler 2dfeffa696 [flang] Merge pull request flang-compiler/f18#949 from flang-compiler/pmk-file
OpenFile class: API and implementation wrappers for open external files

Original-commit: flang-compiler/f18@edd60ae828
Reviewed-on: https://github.com/flang-compiler/f18/pull/949
2020-01-27 10:01:32 -08:00
peter klausler fae12a08bd [flang] Basic file operation wrapper
Asynchronous interfaces and locking

Original-commit: flang-compiler/f18@3ba77a0c20
Reviewed-on: https://github.com/flang-compiler/f18/pull/949
2020-01-27 09:50:25 -08:00
Peter Klausler 7f98a070b0 [flang] Merge pull request flang-compiler/f18#946 from flang-compiler/pmk-hello
12HHELLO, WORLD

Original-commit: flang-compiler/f18@3087aa8284
Reviewed-on: https://github.com/flang-compiler/f18/pull/946
2020-01-24 12:35:43 -08:00
peter klausler 491122d1cd [flang] Drill down to a working implementation of the APIs for an
internal formatted WRITE with no data list items.

Improve argument names in io-api.h

Bump up error number to not conflict with errno values

Use Fortran::runtime::io namespace

Add wrapper around malloc/free, allow use of unique_ptr with wrapper

IoErrorHandler

Revamp FormatContext, use virtual member functions

Update comment syntax, allow for old C

12HHELLO, WORLD

Remove files not yet ready for review

Use std::forward

Fix gcc build warnings

Fix redundant filename in license boilerplate

Reduce runtime dependence on compiler binary libraries, fixing shared lib builds

Original-commit: flang-compiler/f18@839a91f1d6
Reviewed-on: https://github.com/flang-compiler/f18/pull/946
2020-01-24 12:33:47 -08:00
Tim Keith 6149ff9bc9 [flang] Merge pull request flang-compiler/f18#944 from flang-compiler/tsk-pointer
Check bounds on pointer assignment

Original-commit: flang-compiler/f18@5e331c1a5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/944
2020-01-22 13:50:42 -08:00
Tim Keith d1337ba3ee [flang] Check bounds on pointer assignment
Perform checks on bounds-spec and bounds-remapping in a pointer
assignment statement:
- check that the rank of the bounds specified matches the rank of the
  pointer
- for bounds-spec, check that the pointer rank matches the target rank
- for bounds-remapping:
  - check that the target is rank 1 or simply contiguous
  - check that there are sufficient elements on the RHS for the bounds
    specified, when it can be determined at compile time

Move more of the pointer-specific checking from `assignment.cc`
to `pointer-assignment.cc`.

Original-commit: flang-compiler/f18@7489b35392
Reviewed-on: https://github.com/flang-compiler/f18/pull/944
2020-01-22 13:50:02 -08:00
Tim Keith d4a1bd7c9a [flang] Refactor Analyze(PointerAssignmentStmt)
Use early returns to reduce the indentation.
Check LHS is a pointer as early as possible.
A PointerAssignmentStmt can only have a typedAssignment that
represents a PointerAssignment. So assert that is the case and
don't worry about the other cases.

Original-commit: flang-compiler/f18@bdf3d3a292
Reviewed-on: https://github.com/flang-compiler/f18/pull/944
Tree-same-pre-rewrite: false
2020-01-22 13:50:02 -08:00
Tim Keith 0ac2761f2c [flang] Make GenericAssignmentWrapper more like GenericExprWrapper
Have it wrap an optional Assignment so that we can distinguish between
unanalyzed and analyzed with error.

Change analysis of PointerAssignmentStmt to proceed with bounds even
if the DataRef or Expr has an error. Otherwise any bounds expressions
won't be analyzed in that case.

In GetExpr() and GetAssignment() if we get an internal error due to an
unanalyzed expression, dump the parse tree for the expression so we have
some context for the error. They should only be called after the
expression analysis phase. At that point, every expression and assignment
should be analyzed, though some may have resulted in errors(indicated by
returning `nullptr`).

Original-commit: flang-compiler/f18@3b865d7703
Reviewed-on: https://github.com/flang-compiler/f18/pull/944
Tree-same-pre-rewrite: false
2020-01-22 13:50:02 -08:00
Tim Keith 8ad8bfb2a8 [flang] Add std::string ExpressionBase::AsFortran()
This is easier to use when including an expression in an error message
and also useful when debugging for dumping expressions.

Fix up several places that no longer need to use a temporary
std::stringstream.

Also change some references to `operator<<` in `formatting.cc` and
`symbol.cc` that became ambiguous with this change.

Original-commit: flang-compiler/f18@25dc49b6e9
Reviewed-on: https://github.com/flang-compiler/f18/pull/944
Tree-same-pre-rewrite: false
2020-01-22 13:50:02 -08:00
psteinfeld 44e1433855 [flang] Merge pull request flang-compiler/f18#936 from flang-compiler/ps-checklist
Checklist to precede pull requests

Original-commit: flang-compiler/f18@b1e67c4a40
Reviewed-on: https://github.com/flang-compiler/f18/pull/936
2020-01-22 09:43:44 -08:00
Pete Steinfeld fa10045bd7 [flang] Checklist to precede pull requests
I added a checklist to the C++ Style document for things to check before
submitting a pull request or when responding to a request for comments
on a pull request.

Original-commit: flang-compiler/f18@903420268a
Reviewed-on: https://github.com/flang-compiler/f18/pull/936
2020-01-22 09:34:02 -08:00
Peter Klausler 8fdcd7f430 [flang] Merge pull request flang-compiler/f18#938 from flang-compiler/pmk-fix-rank
Fix shape analysis of RHS designators of pointer assignments

Original-commit: flang-compiler/f18@0423347d69
Reviewed-on: https://github.com/flang-compiler/f18/pull/938
2020-01-15 15:58:00 -08:00
peter klausler ee60c9a553 [flang] Fix shape analysis of RHS designators of pointer assignments
Original-commit: flang-compiler/f18@bf26a36ef4
Reviewed-on: https://github.com/flang-compiler/f18/pull/938
2020-01-15 15:14:20 -08:00
Tim Keith 2b5eb76cd2 [flang] Merge pull request flang-compiler/f18#937 from flang-compiler/tsk-pointer
Fix checking of pointer target with association

Original-commit: flang-compiler/f18@6b3dc6d5ec
Reviewed-on: https://github.com/flang-compiler/f18/pull/937
2020-01-15 15:01:01 -08:00
Tim Keith 628a359071 [flang] Fix checking of pointer target with association
When checking if the target of a pointer assignment is valid, we
weren't following associations. E.g. we complained about the assignment
below if `b` had the TARGET attribute but `c` did not:
```
associate(a => b%c)
  p => a
end associate
```

The fix is to change `GetSymbolVector()` to follow associations in
creating the chain of symbols from a designator.

Add tests for this, and also some other cases where TARGET is on the
derived type variable rather than the component (which worked but didn't
have tests).

Original-commit: flang-compiler/f18@c81c6baedd
Reviewed-on: https://github.com/flang-compiler/f18/pull/937
2020-01-15 13:43:05 -08:00
Peter Klausler f4e8eb5d41 [flang] Merge pull request flang-compiler/f18#927 from flang-compiler/pmk-format
Runtime FORMAT scanning

Original-commit: flang-compiler/f18@538d4a1dea
Reviewed-on: https://github.com/flang-compiler/f18/pull/927
2020-01-15 14:08:24 -08:00
peter klausler c3df14c30a [flang] begin processing format strings
Move RoundingMode to Fortran.h

Always skip blanks outside character literals & Hollerith

Templatize

optimize repeat counts somewhat

Fix license punctuation, remove patch

Original-commit: flang-compiler/f18@4a0d39b039
Reviewed-on: https://github.com/flang-compiler/f18/pull/927
2020-01-15 11:27:55 -08:00
Peter Klausler 2236f2bb7e [flang] Merge pull request flang-compiler/f18#926 from flang-compiler/pmk-bd
BLOCK DATA semantics

Original-commit: flang-compiler/f18@4954b95527
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
2020-01-15 11:14:53 -08:00
peter klausler 68f021b8ac [flang] Comments
Original-commit: flang-compiler/f18@0c12188e84
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
2020-01-14 16:16:32 -08:00
peter klausler 210992e526 [flang] Better EQUIVALENCE handling
Original-commit: flang-compiler/f18@7c55097e81
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-14 15:59:29 -08:00
peter klausler a3f4eedea7 [flang] Better fix; clean up redundant utilities
Original-commit: flang-compiler/f18@531db49321
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-14 15:08:37 -08:00
peter klausler 294cae1bcd [flang] Fix unrelated build error found in testing
Original-commit: flang-compiler/f18@5a00d77827
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-14 14:19:42 -08:00
peter klausler 26481ef2bb [flang] Update a test
Original-commit: flang-compiler/f18@5f32183eed
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-14 11:38:09 -08:00
peter klausler c1a710d772 [flang] Address review comments
Original-commit: flang-compiler/f18@d179c796bd
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-14 11:24:49 -08:00
peter klausler b07a4b2474 [flang] Better check for variables in DATA
Original-commit: flang-compiler/f18@92e20baaa8
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-14 11:11:15 -08:00
peter klausler 7010fff8de [flang] Fix bug
Original-commit: flang-compiler/f18@662b8139b5
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-13 15:39:18 -08:00
peter klausler c2bdc144c5 [flang] More comments addressed
Original-commit: flang-compiler/f18@9c863a572b
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-13 15:13:09 -08:00
peter klausler efa2ec7670 [flang] Address review comments
Original-commit: flang-compiler/f18@59e5565cb8
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-13 14:30:31 -08:00
peter klausler 15c89acb18 [flang] BLOCK DATA
add test

Original-commit: flang-compiler/f18@91c084b698
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false
2020-01-13 12:23:14 -08:00
Tim Keith b4eade7f88 [flang] Merge pull request flang-compiler/f18#928 from flang-compiler/tsk-assignment3
Pointer assignment semantic checks

Original-commit: flang-compiler/f18@fc600af81e
Reviewed-on: https://github.com/flang-compiler/f18/pull/928
2020-01-14 13:09:08 -08:00
Tim Keith cb37808058 [flang] Pointer assignment semantic checks
Call `CheckPointerAssignment()` when analyzing a pointer assignment
statement. NOTE: the cases with bounds-spec and bounds-remapping are
still to be done.

Perform checks on pointer symbols in `check-declarations.cc`.

Check for pointer to generic intrinsic in `semantics/expression.cc`.

Add the other required pointer assignment checks to `pointer-assignment.cc`.

Original-commit: flang-compiler/f18@3dc5fd6d9e
Reviewed-on: https://github.com/flang-compiler/f18/pull/928
2020-01-14 13:02:56 -08:00
Tim Keith cfedf1dac9 [flang] C1027: procedure pointer may not be coindexed object
Original-commit: flang-compiler/f18@4261daf352
Reviewed-on: https://github.com/flang-compiler/f18/pull/928
Tree-same-pre-rewrite: false
2020-01-14 13:02:56 -08:00
Tim Keith a5db74b614 [flang] Add IntrinsicProcTable::IsSpecificIntrinsicFunction
This replaces IsUnrestrictedSpecificIntrinsicFunction and returns
information that allows the caller to distinguish between restricted
and unrestricted intrinsics.

The new case in `resolve46.f90` used to get an internal error.

Original-commit: flang-compiler/f18@4cb1ee10b9
Reviewed-on: https://github.com/flang-compiler/f18/pull/928
Tree-same-pre-rewrite: false
2020-01-14 13:02:56 -08:00
Tim Keith 355ab9bb82 [flang] Make Fortran form of intrinsic types uppercase
`DynamicType::AsFortran` was using mixed case for intrinic type names.
Make it upper case for consistency with TYPE(...) and CHARACTER when a
length is present and other error messages.

Original-commit: flang-compiler/f18@e16909d67f
Reviewed-on: https://github.com/flang-compiler/f18/pull/928
Tree-same-pre-rewrite: false
2020-01-14 13:02:56 -08:00
Tim Keith c42a22091f [flang] Move pointer assignment checking to its own file
Create `pointer-assignment.{h,cc}` for pointer assignment checking.
It doesn't share with assignment checking so it should be its own file.
Move the code into semantics namespace.

Original-commit: flang-compiler/f18@1658aba81f
Reviewed-on: https://github.com/flang-compiler/f18/pull/928
Tree-same-pre-rewrite: false
2020-01-14 13:02:56 -08:00
Tim Keith ce3d838bc6 [flang] Clean up AssignmentContext
Eliminate `at_` and use location from `SemanticsContext` instead.

Add and use Analyze functions for `std::optional` and `std::list`.

Original-commit: flang-compiler/f18@e171029ccd
Reviewed-on: https://github.com/flang-compiler/f18/pull/928
Tree-same-pre-rewrite: false
2020-01-14 13:02:55 -08:00
Tim Keith 18e37a7adf [flang] Merge pull request flang-compiler/f18#933 from flang-compiler/tsk-issues
Move checks for valid array-spec to check-declarations.cc

Original-commit: flang-compiler/f18@7cf6f6137d
Reviewed-on: https://github.com/flang-compiler/f18/pull/933
2020-01-14 13:06:06 -08:00
Tim Keith 889c81eae7 [flang] Move checks for valid array-spec to check-declarations.cc
At the time we finish processing an array-spec in `resolve-names.cc`,
we don't know if the entity is going to be declared ALLOCATABLE later
so we can't check for validity there. In the new test in `resolve58.f90`
(based on issue flang-compiler/f18#930) we were reporting an error on `b` and not on `a`
when it should be the reverse.

The fix is to move array-spec checking to `check-declarations.cc`,
after name resolution is complete.

Fixes flang-compiler/f18#930.

Original-commit: flang-compiler/f18@c596d2fef7
Reviewed-on: https://github.com/flang-compiler/f18/pull/933
2020-01-14 12:06:52 -08:00
Peter Klausler 605d79eaeb [flang] Merge pull request flang-compiler/f18#932 from flang-compiler/pmk-fix-931
Fix bug flang-compiler/f18#931: spurious error reported on CSHIFT

Original-commit: flang-compiler/f18@6adae0b7f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/932
2020-01-14 11:37:20 -08:00
peter klausler 1fe6297cab [flang] Fix bug flang-compiler/f18#931: spurious error reported on CSHIFT
Original-commit: flang-compiler/f18@bd9bd78865
Reviewed-on: https://github.com/flang-compiler/f18/pull/932
2020-01-14 10:53:36 -08:00
CarolineConcatto 0d9dd49ed4 [flang] Regression tests configuration for f18 repository (flang-compiler/f18#861)
The configuration for the tests are in lit.* files.
The lit tests rely on the presence of llvm-lit,FileCheck, not and  count.
When building LLVM add:
-DLLVM_INSTALL_UTILS=On at the cmake command.
LLVM_LIT is found by setting LLVM_EXTERNAL_LIT in f18 CMakeLists.txt.

This patch:
  * Uses LLVM_EXTERNAL_LIT
  * Adds regression tests configurations
  * Adds a proof of concept regression test

The regression test needs to have the Utils build in LLVM.
This is done by adding:
  -DLLVM_INSTALL_UTILS=On
to the LLVM build cmake.

Signed-off-by: Caroline Concatto <caroline.concatto@arm.com>

Original-commit: flang-compiler/f18@a58c6067a1
Reviewed-on: https://github.com/flang-compiler/f18/pull/861
2020-01-14 08:20:49 -08:00
David Truby 05bdb54a49 [flang] Outline operator<< for CharBlock. (flang-compiler/f18#916)
This fixes an issue where the Dump function definitions in dump.cc
were relying on the forward declaration of operator<< for CharBlock
which was marked inline and only present in char-block.h.

This is not allowed under section 6.2.10 of the C++17 standard, and
caused a compilation failure when building with clang 9 as this was
inlining every use of the function and therefore not generating an
outlined definition for linking.

Original-commit: flang-compiler/f18@3ad75d123b
Reviewed-on: https://github.com/flang-compiler/f18/pull/916
2020-01-13 22:08:56 -08:00
psteinfeld d731aeffac [flang] Merge pull request flang-compiler/f18#924 from flang-compiler/ps-cleanup-do-check
Removed an unnecessary check after Tim fixed issue flang-compiler/f18#915.

Original-commit: flang-compiler/f18@538a6dd5e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/924
2020-01-12 09:08:17 -08:00
Pete Steinfeld 5f7a9504ae [flang] Removed an unnecessary check after Tim fixed issue flang-compiler/f18#915.
Original-commit: flang-compiler/f18@348b04bc1c
Reviewed-on: https://github.com/flang-compiler/f18/pull/924
2020-01-12 08:31:54 -08:00
psteinfeld 6e9673e91e [flang] Merge pull request flang-compiler/f18#918 from flang-compiler/ps-do-func
Checks for DO variables passed to INTENT(OUT) dummies in functions

Original-commit: flang-compiler/f18@ab8fd34a71
Reviewed-on: https://github.com/flang-compiler/f18/pull/918
2020-01-10 15:43:33 -08:00
Pete Steinfeld ec45bc26d3 [flang] Checks for DO variables passed to INTENT(OUT) dummies in functions
I added a traveral framework to find actual arguments in expressions.
For arguments that are DO variables being passed to dummy arguments with
INTENT(OUT), I emit an error message.  For INTENT(INOUT), I emit a
warning.

Original-commit: flang-compiler/f18@815dbed75c
Reviewed-on: https://github.com/flang-compiler/f18/pull/918
2020-01-10 15:08:54 -08:00
Tim Keith 30088b77d9 [flang] Merge pull request flang-compiler/f18#923 from flang-compiler/tsk-expr2
Detect incorrect use of assumed-type dummy arguments

Original-commit: flang-compiler/f18@b29f284325
Reviewed-on: https://github.com/flang-compiler/f18/pull/923
2020-01-10 14:52:36 -08:00
Tim Keith 1243a0d175 [flang] Detect incorrect use of assumed-type dummy arguments
Assumed-type dummy arguments can only be used as actual arguments. If
they are used in other contexts it is an error. Change argument analysis
to handle these differently depending on the context. `allowAssumedType`
is set when the argument can be assumed-type. These expressions now all
get `typedExpr` set to `nullopt`.

Change `AnalyzeSectionSubscripts` to analyze all of the subscripts
even if one has an error. This ensures they all get analyzed expressions
(or `nullopt` in case of error).

Fix a bug analyzing `BoundsRemapping`: the lower bound was analyzed
twice and the upper bound not at all.

These change mean that `typedExpr` is set in all known cases.
Fixes flang-compiler/f18#915.

Original-commit: flang-compiler/f18@679ef69905
Reviewed-on: https://github.com/flang-compiler/f18/pull/923
2020-01-10 14:51:40 -08:00
Gary Klimowicz b37ba4d3e3 [flang] Merge pull request flang-compiler/f18#922 from flang-compiler/gak-fix-comments
Minor format change to LLVM license lines

Original-commit: flang-compiler/f18@9c7406324d
Reviewed-on: https://github.com/flang-compiler/f18/pull/922
2020-01-10 13:05:23 -08:00
Gary Klimowicz cea1040d51 [flang] Minor format change to LLVM license lines
Replace comment lines containing all dashes with the
proper ===-----....----=== markers.

Original-commit: flang-compiler/f18@a8936b0d41
Reviewed-on: https://github.com/flang-compiler/f18/pull/922
2020-01-10 12:12:03 -08:00