The constraint says that a variable-name in a locality-spec shall be the name
of a variable in the innermost executable construct or scoping unit that
includes the DO CONCURRENT statement. This check was already being made in
resolve-names.cc for LOCAL and LOCAL_INIT locality specs but not for the
SHARED locality spec. Also, there was some code in check-do.cc that was
intended to be used to enforce this constraint at some time in the future.
I added code to resolve-names.cc to extend the checking to the SHARED locality
spec and removed the unused code from check-do.cc. I also extended the
existing tests in resolve35.f90 to exercise the new code.
Original-commit: flang-compiler/f18@b421923d94
Reviewed-on: https://github.com/flang-compiler/f18/pull/533
Tree-same-pre-rewrite: false
There are no Clause 12 constraints to check for PRINT, but PRINT does share
FMT specifier processing with READ and WRITE. To avoid interactions between
these I/O statements, reset IoChecker values for PRINT.
Original-commit: flang-compiler/f18@6a54766718
Reviewed-on: https://github.com/flang-compiler/f18/pull/528
Change the CMakeFile.txt in tools/f18 to build the predefined modules with the just-built compiler. The mod files are created in the new "include" subdirectory of the binary target directory. The mod files are installed to ${CMAKE_INSTALL_PREFIX}/include.
The f18 driver is already installed in ${CMAKE_INSTALL_PREFIX}/bin. This change change the location of the f18 binary build to a sibling directory of "include" called "bin" instead of at the top level of the binary destination directory. This change is in anticipation of changing the driver to find the include directory using a path relative to the location of f18.
Update the test scripts to find f18 in the bin subdirectory.
Remove the simple predefined module tests from test/semantics because they are compiled as part of the build and don't need to be recompiled as part of a test.
Original-commit: flang-compiler/f18@7811ccecdc
Reviewed-on: https://github.com/flang-compiler/f18/pull/526
This patch is to show the framework to do OpenMP structure related check and you may find missing/incomplete implementation, which will be added in the future.
1. Each encountering construct has its own context and the context info will be filled while walking the directive/clause nodes. In the `Leave`, the current OpenMP context will be popped out.
2. When entering the construct, necessary nesting check will be performed. Use std::vector to implement the context stack because certain nesting restrictions may need to trace back more than one level.
3. PARALLEL construct is used as an example for clause validity check.
4. `EnumSet` is used to represent the directive/clause sets and to show the error msg. All the error msgs are quoted from the specification.
5. Necessary `CharBlock` is added for error msgs.
Original-commit: flang-compiler/f18@620441c03e
Reviewed-on: https://github.com/flang-compiler/f18/pull/493
* Clause 13 (Input/output editing) syntax and semantic checking
Diagnose:
- all clause syntax errors (independent of normal parsing)
- all clause constraints
- use of non-standard extensions under -Mstandard
- obvious program requirement violations
The code:
- is invoked for both format statement and I/O statement constant formats
- should be useable by the runtime I/O library for runtime formats
- is able to recover from errors
- is able to diagnose multiple errors in a single format
- has accurate markers for errors
- can process (fixed character size) Hollerith strings
- generates reasonable error messages for known error scenarios
- should not require C++ run-time library support
The code is templatized for use with fixed size character kind={1,2,4} input,
but only the kind=1 variant is actually exercised.
* Review update.
* Review update.
* Review update.
* Improve error processing of unterminated formats.
Original-commit: flang-compiler/f18@c04b7518df
Reviewed-on: https://github.com/flang-compiler/f18/pull/498
The passed-object dummy argument cannot be checked until the
interfaces of contained subprograms are known. To accomplish this,
add `FinishSpecificationPart` pass to run after all specification
parts have been analyzed but before any of the execution parts.
This visits all derived types defined in each scope and performs
the checks on each procedure component and procedure binding.
Add a flag to `ParamValue` to distinguish kind from len parameters.
Fix some tests that had errors we now detect.
Original-commit: flang-compiler/f18@4789643c5b
Reviewed-on: https://github.com/flang-compiler/f18/pull/521
Add `passArg` to `ProcEntityDetails` and `ProcBindingDetails`.
The is the symbols that represents the passed-object dummy argument,
or nullptr if none.
As both of these classes need `passName` and `passArg`, create a mixin
class, `WithPassArg` for the shared content.
Change passName_ from optional to pointer because that makes it a little
easier to work with and there is no need to have a copy of the name.
Original-commit: flang-compiler/f18@1cdd1a5b87
Reviewed-on: https://github.com/flang-compiler/f18/pull/521
Tree-same-pre-rewrite: false
Add an `AsFortran()` member function to `DeclTypeSpec` and related
classes to convert types to a Fortran representation. This allows
error messages to mention types. It also fixes `.mod` file writing
where it previous used `operator<<` to convert types to Fortran.
Original-commit: flang-compiler/f18@eb16f8b5dd
Reviewed-on: https://github.com/flang-compiler/f18/pull/521
Tree-same-pre-rewrite: false
If a name is declared in a module with just `private :: x`,
we don't know if `x` is supposed to be an object or procedure,
so it ends up not getting an implicit type. This leads to an
internal error when writing the `.mod` file.
The fix requires two changes:
1. Cause all `EntityDetails` to be converted to `ObjectEntityDetails`
in `ResolveSpecificationParts`. This is done by calling `PopScope()`.
The reason for not calling it there no longer applies since the
addition of the `ExecutionPartSkimmer` pass.
2. In the same place, apply the implicit typing rules to every entity
in the scope.
Fixesflang-compiler/f18#514, fixesflang-compiler/f18#520.
Original-commit: flang-compiler/f18@7e4185e9ff
Reviewed-on: https://github.com/flang-compiler/f18/pull/524
I changed two things in the messages produced for DO semantic checks --
- I changed the source location to be specific to where conflicting names are
declared.
- I added the conflicting names to the message.
Original-commit: flang-compiler/f18@f39f9ceeae
Reviewed-on: https://github.com/flang-compiler/f18/pull/510
In the example below, the compiler gets an internal error when
processing the derived-type-spec for the declaration of `x`.
When the search for type parameter `k` fails it means an error
has already occurred and we should skip that parameter.
```
type :: t(k)
end type
type(t):: x
end
```
Original-commit: flang-compiler/f18@a4bf1922e5
Reviewed-on: https://github.com/flang-compiler/f18/pull/509
Here's a summary of the changes:
- I renamed a function to ResolveControlExpressions for clarity.
- I changed the interface to the function to ResolveIndexName for clarity.
- I simplified the code for walking the "step" and scalar mask expressions in
a DO CONCURRENT control statements to not check for the presence of optional
expressions.
- I added "const" to the declaration of a local variable.
- I removed some spurious comments from the test dosemantics04.f90.
- I added two new tests to dosemantics04.f90 to verify cases that were not
covered in my original test implementation.
Original-commit: flang-compiler/f18@fa5827061a
Reviewed-on: https://github.com/flang-compiler/f18/pull/504
Tree-same-pre-rewrite: false
CONCURRENT header not reference names declared in the same header. To
implement this, I changed the "Pre" function for ConcurrentHeader to walk the
subtree in an order that caused the variables associated with the declared
names to be created before any of the expressions were walked.
I added the test dosemantics04.f90 to test this.
Original-commit: flang-compiler/f18@9f3b552414
Reviewed-on: https://github.com/flang-compiler/f18/pull/504
Tree-same-pre-rewrite: false
test_symbols.sh and test_folding.sh were running the compiler in the
test directory (e.g. `<build>/test/semantics`). This meant that .mod
files were being left there because they weren't cleaned up.
Change to run the compiler in the temp directory created for each test.
It is deleted at the end so files aren't left behind.
Original-commit: flang-compiler/f18@4f9735ada7
Reviewed-on: https://github.com/flang-compiler/f18/pull/506
Interface blocks can be nested if one of the interface bodies
declares a subprogram with a dummy procedure that is specified
by an interface block. See the addition to `modfile07.f90` for
and example.
This didn't work because there was only one copy of each of
`inInterfaceBlock_`, `isAbstract_`, and `genericSymbol_`.
We need these for each active interface block, so replace these
with a stack. A new entry is pushed on the stack when we enter
an `InterfaceStmt` or `GenericStmt` and popped when we leave.
Also in the same example, when declaring the dummy procedure, the
dummy argument is initially an `EntityDetails` but it is replaced
by a `SubprogramDetails` when it is specified by the interface.
Original-commit: flang-compiler/f18@0c468b60b1
Reviewed-on: https://github.com/flang-compiler/f18/pull/502
A substring of an array element is legal as an equivalence object,
e.g. `a(2,3)[4:5]`. Extend `EquivalenceObject` to include the start
of the substring, if any. Split `CheckBound` into `CheckArrayBound`
and `CheckSubstringBound`.
When evaluating bounds in `AddToSet` we can assert they are constant
because all of the error cases should have been detected already.
Original-commit: flang-compiler/f18@0b4050b2d5
Reviewed-on: https://github.com/flang-compiler/f18/pull/494
Collect sets of `parser::EquivalenceObject` to process at the end of
the specification part. This is so that names mentioned in the
EQUIVALENCE statement don't trigger implicit declarations.
The `EquivalenceSets` class performs most of the numerous checks
on objects that can be in equivalence sets at all and objects that
can be in them together. It also merges sets when the same object
appears in more than one.
Once equivalence sets are checked they are added to the `Scope`.
Further checks will be necessary after the size and alignment of
variables are computed.
Add `FindUltimateComponent` to simplify checks on ultimate components
of derived types. Use it to implement `HasCoarrayUltimateComponent`
and checks on equivalence objects.
Make `ExpressionAnalyzer::Analyze(Designator)` public so that
`parser::EquivalenceObject` can be analyzed.
Add `GetDefaultKind`, `doublePrecisionKind`, and `quadPrecisionKind`
to `SemanticsContext` so that `defaultKinds_` does not need to be
accessed directly.
Original-commit: flang-compiler/f18@1cc898e5b8
Reviewed-on: https://github.com/flang-compiler/f18/pull/494
Tree-same-pre-rewrite: false
variable and initial, final, and step expressions.
Here's a summary of the changes since my original pull request:
- I've taken into account the possibility that the DO variable is declared in
a MODULE. This required a call to GetUltimate() on the Symbol for the DO
variable.
- The previous change exposed problems in the semantic checking for NULLIFY
and DEALLOCATE statements, so I've included fixes and tests for those. I
also added a test for the ALLOCATE statement, even though it was already
handling this case.
- I now handle the case where a procedure name is erroneously used as a DO variable.
- I now handle the case where a pointer to a procedure is erroneously used as
a DO variable.
- I now check that the DO expressions are not null.
- I added tests for all cases listed above.
Original-commit: flang-compiler/f18@219d856fdb
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
Specifically, that the conversion of warnings to errors will happen in a
single place in the compiler once we implement warnings as distinct from
errors. This change made on of the tests invalid.
Also, there's no need to check whether the extension to allow
REAL DO controls is enabled.
Original-commit: flang-compiler/f18@2fae9edd77
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
parse-tree.cc
- Cleaned up the use of "const" in several declarations.
check-do-stmt.cc
- Replaced uses of parser::Messages with SemanticsContext.
- Removed unused "==" operator from the DoStmtContext class.
- Reduced the size of the GetBounds function by calling GetLoopControl().
- Changed the warning message for REAL DO controls to not mention standard
extensions.
check-do-stmt.h
- Restored the forward reference to Fortran::parser::DoConstruct and removed
the include of parse-tree.h
dosemantics*.f90
- Removed extraneous references to the "RUN" command.
test_errors.sh
- Simplified and generalized the extraction of the OPTIONS specification.
Original-commit: flang-compiler/f18@04a0712766
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
and initial, final, and step expressions. As a new extension, we want to allow
REAL and DOUBLE PRECISION values for them by default.
Here's a summary of the changes:
- There already existed infrastructure for semantic checking of DO loops that
was partially specific to DO CONCURRENT loops. Because I re-used some of
this infrastructure, I renamed some files and classes from "concurrent" to
"stmt".
- I added some functions to distinguish among the different kinds of DO
statements.
- I added the functions to check-do-stmt.cc to produce the necessary warnins
and errors. Note that there are no tests for the warnings since the
necessary testing infrastructure does not yet exist.
- I changed test-errors.sh so that additional compilation options can be
specified in the test source.
- I added two new tests to test for the various kinds of values that can be
used for the DO variables and control expressions. The two tests are
identical except for the use of different compilation options.
dosemantics03.f90 specifies the options "-Mstandard -Werror" to produce
error messages for the use of REAL and DOUBLE PRECISION DO variables and
controls. dosemantics04.f90 uses the default options and only produces
error messages for contructs that are erroneous by default.
Original-commit: flang-compiler/f18@f484660c75
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
Tree-same-pre-rewrite: false
In a function without a function result specified, the name in the
`FunctionStmt` was resolved to the function result symbol rather than
the function symbol itself. That is inconsistent with subroutines and
other functions.
The fix is to explicitly set the function name symbol after the result
has been resolved.
Original-commit: flang-compiler/f18@b0172d3284
Reviewed-on: https://github.com/flang-compiler/f18/pull/487
There were a couple of small incompatibilities:
- There is no `ldd` on MacOS; instead use `otools -L`.
This has not been tested when libpgmath is linked in to f18.
- `wc` outputs spaces where on Linux it outputs tabs; change how
the number of lines is extracted to work on both.
Also, fix a bug: change `passed_warnings` to `$passed_warnings`.
Original-commit: flang-compiler/f18@5bede9e188
Reviewed-on: https://github.com/flang-compiler/f18/pull/475
more fixes
Access components of constant structures
Apply implicit typing to dummy args used in automatic array dimensions
SELECTED_INT_KIND and SELECTED_REAL_KIND
Finish SELECTED_{INT,REAL}_KIND and common cases of ALL()/ANY()
Original-commit: flang-compiler/f18@e9f8e53e55
Reviewed-on: https://github.com/flang-compiler/f18/pull/472
Tree-same-pre-rewrite: false
- Add location to non-fatal error message (context was not given
a location before folding in semantics).
- Avoid refolding expression from scratch several times (update GenericExprWrapper
after folding). So far, warning messages were generated twice per parametere init
expressions.
Original-commit: flang-compiler/f18@bf7f6cf9cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/468
Tree-same-pre-rewrite: false
checkpoint: changes build, tests all pass
many fixes, ready to test more
Further CLASS(*) support
More fixes for CLASS(*)
Hide data members of DynamicType
implement PRESENT() intrinsic
Original-commit: flang-compiler/f18@044ba12c20
Reviewed-on: https://github.com/flang-compiler/f18/pull/466
Tree-same-pre-rewrite: false
Use better names for template parameters of `LoopBounds`, and also
for the constructor arguments.
Use two overloadings of `loopBounds()` instead of `std::is_same_v<>`.
Original-commit: flang-compiler/f18@a2c0c75462
Reviewed-on: https://github.com/flang-compiler/f18/pull/455
Tree-same-pre-rewrite: false
It is a common extension to allow DO loops with REAL variable and
bounds. The parse tree currently parses those with the variable
as `scalar-int-variable-name` and the bounds as `scalar-int-expr`.
That causes the INTEGER constraint to be enforced automatically.
Change the grammar and parse tree to treat them as `scalar-variable-name`
and `scalar-expr`. This allows the name and expression to be REAL,
but we will have to verify that they aren't any other type (in a future
change).
To accomplish this, add a template parameter to `LoopBounds` for the type
of the variable name (always `Scalar<Name>` or `Scalar<Integer<Name>>`).
We sometimes need names for the instantiations of `LoopBounds` so add
type aliases like `LoopControl::Bounds` for each one.
Original-commit: flang-compiler/f18@d75aa03970
Reviewed-on: https://github.com/flang-compiler/f18/pull/455
Tree-same-pre-rewrite: false
1. typo and trailing spaces within OpenMP-4.5-grammar.txt
2. parse (openmp-grammar.h) and unparse(unparse.cc) for:
SCHEDULE ([modifier [, modifier]:]kind[, chunk_size])
Modifier -> MONITONIC | NONMONOTONIC | SIMD
where ":" is optional except at least one modifier is present.
Original-commit: flang-compiler/f18@5cebae5039
Reviewed-on: https://github.com/flang-compiler/f18/pull/453