back out -Mnolargearray default temporarily
Fix C_F_POINTER(SHAPE=) argument check, it can be any kind of integer
Revert default result kind of SIZE() & al. to standard by default
Remove needless usage of -fdebug-semantics
Original-commit: flang-compiler/f18@57058a5b16
Reviewed-on: https://github.com/flang-compiler/f18/pull/907
The commit includes the following,
-> The name field in DoConcurrent*Enforce classes are not used anymore.
Removing the field and its collection and retrieval from
DoConcurrentBodyEnforce and its usage in DoConcurrentLabelEnforce.
-> DoConcurrentLabelEnforce is useful for checking that there
are no branches escaping from other constructs also. For enabling
use in other constructs (like critical) moving this to tools.h
and renaming it as LabelEnforce.
-> Checks for the constraints.
-> Tests for the constaints.
Original-commit: flang-compiler/f18@4b7a007ff3
Reviewed-on: https://github.com/flang-compiler/f18/pull/897
Add `typedAssignment` to `PointerAssignmentStmt` parse tree node and
extend `evaluate::Assignment` to include pointer assignment, including
analyzed bounds. Analyze pointer assignments and fill those in.
Emit them in unparsed output and parse tree dump when present.
Change assignment checking to use analyzed expressions and assignments
rather than calling AnalyzeExpr. Check bounds in pointer assignments
for impure function calls in FORALL context.
Add `Fold` convenience function to `ExpressionAnalyzer`.
Original-commit: flang-compiler/f18@140c983423
Reviewed-on: https://github.com/flang-compiler/f18/pull/904
As it was implemented we weren't detecting non-constant kind parameters
in the integer-type-spec. The fix is just to walk the integer-type-spec
like was do any other one.
Also, there is not need for ResolveControlExpressions -- all it does is
walk that part of the parse tree.
Original-commit: flang-compiler/f18@8c0d890eb8
Reviewed-on: https://github.com/flang-compiler/f18/pull/904
Tree-same-pre-rewrite: false
I added code to save the INTENT of a dummy argument in the checked expression
of the actual argument. When processing a CallStmt, I then retrieve the
ProcedureRef, which contains a list of the checked ActualArguments. I then
traverse this list looking for actual arguments that are active DO variable
that are being passed to dummy arguments whose INTENT is either OUT or INOUT.
For OUT dummies, I put out an error message and warn for INOUT dummies.
Original-commit: flang-compiler/f18@0ff1d26428
Reviewed-on: https://github.com/flang-compiler/f18/pull/902
Make compilation of other predefined module files depend on
__fortran_builtins.mod. Currently only iso_c_binding.f90 and
iso_fortran_env.f90 depend on it but others could in the future.
Create the .f18.mod files by copying from the .mod files so that
we don't have to worry about dependencies for those.
Original-commit: flang-compiler/f18@8209ad3d32
Reviewed-on: https://github.com/flang-compiler/f18/pull/899
I added infrastructure to SemanticsContext to track active DO variables
and the source locations where they appear in DO statements. I also
added code to semantics.[h,cc] to check to see if a DO variable is
already defined, and, if so, to emit an error message along with a
reference to the relevant DO construct. I also added calls to several
places where variables are defined to determine if the definitions are
happening in the context of an active DO construct.
I have not yet added the checks for DO variables being redefined when passing
them as actual arguments to dummy arguments with INTENT(OUT) or INTENT(INOUT).
I wanted to get these changes merged first and catch up with the other changes
in master.
Original-commit: flang-compiler/f18@1bbfcca61b
Reviewed-on: https://github.com/flang-compiler/f18/pull/860
This changes the license information in many of the flang source files.
- Renamed LICENSE to LICENSE.txt.
- NVIDIA Copyright lines have been removed.
- Initial lines for files follow the LLVM coding convention (file name on the first line; Emacs mode information on the first line).
- License references have been replaced with the abridged LLVM text.
- License information was removed from the test files.
- No file header was placed on test files (these weren't in most LLVM test files).
- License information was added to documentation files where it was missing.
We did not add brief file summaries to the initial line.
See http://llvm.org/docs/DeveloperPolicy.html#new-llvm-project-license-framework
for a description of the new license.
See http://llvm.org/docs/CodingStandards.html#file-headers
for a description of the new LLVM standard file header.
Original-commit: flang-compiler/f18@add6cde724
Reviewed-on: https://github.com/flang-compiler/f18/pull/887
When `ExpressionAnalyzer::AnalyzeCall` processed a subroutine it was
always returning std::nullopt. Change it to return a `ProcedureRef`
wrapped in an `Expr` so that it can be saved in `CallStmt::typedCall`.
Original-commit: flang-compiler/f18@2cc226f66e
Reviewed-on: https://github.com/flang-compiler/f18/pull/879
When dumping the parse tree, if there are analyzed expressions,
assignments, or call statements, include the Fortran form of those
in the dump.
This uses the same `AnalyzedObjectsAsFortran` object that unparsing
does so it applies to the same nodes.
We already do something like this for `Name` nodes as well as some
predefined types, so abstract it into an `AsFortran` function which
returns the Fortran source for a node that is to be included in the
dump.
Original-commit: flang-compiler/f18@823b044d2a
Reviewed-on: https://github.com/flang-compiler/f18/pull/878
Tree-same-pre-rewrite: false
Add `ArgumentAnalyzer::FindBoundOp` to look for an operator or
assignment definition in the type of each operand. Then `TryBoundOp`
checks if it is actually applicable.
Change ResolveGeneric to handle type-bound operators: the `adjustActuals`
function passed in handles the difference between these and normal
type-bound procedures. For operators, either operand may be the passed-
object argument. For procedures we know which one it is.
Extract `GetDerivedTypeSpec`, `GetBindingResolution`, and
`OkLogicalIntegerAssignment` into separate functions to simplify the
logic of the calling functions.
Original-commit: flang-compiler/f18@1f7ff22145
Reviewed-on: https://github.com/flang-compiler/f18/pull/872
Tree-same-pre-rewrite: false
Add new license text to runtime/magic-numbers.h, which is unusual
in that it is the only .h file in flang that is intended to be
included in either C or Fortran files. This requires special
handling of the license text.
Original-commit: flang-compiler/f18@61bb9db531
Reviewed-on: https://github.com/flang-compiler/f18/pull/867
Extend `ResolveGeneric` to handle calls to procedure components by
passing in the data-ref that is used as the passed-object argument.
`AddPassArg` takes care of adding a placeholder for the passed object.
This is shared by the generic and non-generic cases of calls to
procedure components.
Original-commit: flang-compiler/f18@be83590183
Reviewed-on: https://github.com/flang-compiler/f18/pull/863
The real operand was always converted to the complex operand type.
The highest precison should be used instead. This fix converts the
real to a complex of the same kind before applying the promotion
rules for complex operands.
Reference to Fortran 2018 standard 10.9.1.3 that rules this added
in comments.
Original-commit: flang-compiler/f18@0d6b9c33aa
Reviewed-on: https://github.com/flang-compiler/f18/pull/858
identification of their index in the dummy argument list,
simplifying their representation, completing the representation
of their actual arguments, and (while I'm here) resolving
calls to type-bound procedures whose bindings are known at
compilation time.
Button up class ActualArgument by making remaining data
members private and adding accessors & mutators.
Original-commit: flang-compiler/f18@5eb60ec419
Reviewed-on: https://github.com/flang-compiler/f18/pull/855
1. Dump negative parts in complex constants without parentheses
(-1., 0.) was dumped as ((-1.), 0.) from f18 expression format.
The latter format is only valid with the complex constructor extension
that is not supported by all compilers.
This commit ensure the former fromat is used in dumps so that dumps can
be used by all fortran compilers. It turns out the parenthesis added
by REAL::AsFortran are not required because operation lowering is
already taking care of this.
2. Dump evaluate::ComplexComponent with REAL/IMAG instead of %RE/%IM
f18 was failing to reparse its own dump in some cases involving
complex expressions like `-z**i`.
The reason was %RE and %IM were used to dump ComplexComponents.
%RE and %IM can only be used on designators but ComplexComponent can
contain arbitrary complex expressions.
Hence, %RE and %IM cannot be used to dump ComplexComponent.
This commit replace them with call to intrinsic function
REAL/IMAG.
Note that this may unfortunatly be unsafe if the user
shadowed REAL or IMAG but I do not see an easy way to solve
this... The current dump is not correct.
Original-commit: flang-compiler/f18@4550a23d0b
Reviewed-on: https://github.com/flang-compiler/f18/pull/851
A symbol that represents a procedure binding is PURE if the procedure
it is bound to is PURE. Fix `IsPureProcedure` to check that.
Make use of `IsPureProcedure` in `CheckSpecificationExprHelper`.
Original-commit: flang-compiler/f18@c95f2eb4fb
Reviewed-on: https://github.com/flang-compiler/f18/pull/849
This is prohibited by Section 11.1.7.4.1, paragraph 1.
Note also that we allow for REAL step expressions. But the check I
added only works for INTEGER step expressions.
I added a function to tools.cc to test to see if an expression is zero,
and I added calls to check-do.cc for regular and CONCURRENT DO
statements to this function. I made the regular DO a warning and the DO
CONCURRENT message an error. I added tests for the DO CONCURRENT case,
including a test that uses an integer constant.
Original-commit: flang-compiler/f18@8c4fadfe00
Reviewed-on: https://github.com/flang-compiler/f18/pull/834
Section 15.4.3.4.2 specifies restrictions on functions that may be used
to implement an "extended-intrinsic-op". These checkw are implemented in
`CheckHelper::CheckDefinedOperator`.
Move `IsIntrinsicRelational` et al. to `semantics/tools.h` so that
the same logic is used to check both dummy and actual arguments.
Fix up tests that had errors that are now detected.
Original-commit: flang-compiler/f18@b900762eed
Reviewed-on: https://github.com/flang-compiler/f18/pull/846
Change expression analysis to do assignment statements as it currently
does call statements. Check there for defined assignment and set
`typedAssignment` in the `AssignmentStmt` node to contain the analyzed
assignment, either intrinsic or user-defined.
When `var = expr` is implemented by subroutine `sub`, the analyzed
assignment contains a procedure reference to `sub(var, (expr))`.
Add `IsDefinedAssignment` to decide based on types and ranks of lhs
and rhs whether is can be a defined assignment. The result is
tri-state because when they are both the same derived type it can
be either intrinsic or defined. Use this where a similar decision
is made in `check-declarations.cc`.
Change "Procedure referenced in PURE subprogram" error message to
contain the name of the procedure. If the reference is from a defined
assignment that name won't appear on the highlighted source line.
Original-commit: flang-compiler/f18@5c87071210
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Add `typedAssignment` to the `AssignmentStmt` node, analagous to
`typedExpr` in `Expr`. This represents the analyzed form of an assignment.
It may be a subroutine call in the case of a user-defined assignment.
Add `GetAssignment` function to get it from the parse tree node if present.
Original-commit: flang-compiler/f18@675b0b9bb7
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Move the code to parenthesize an expression from `ExpressionAnalyzer`
into `evaluate/tools.h` so that it can be used to parenthesize an
`ActualArgument`. This will be needed for defined assignment calls.
Original-commit: flang-compiler/f18@6180d1fb9b
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Perform the checks from 15.4.3.4.3 to determine what procedures are
valid to implement defined assignment. This requires characterizing
procedures, so share the result of that with
`CheckSpecificsAreDistinguishable`.
Original-commit: flang-compiler/f18@9e0d79f173
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
The check that specific procedures of a generic are distinguishable
doesn't need to be done in `resolve-names.cc`. It can be deferred until
`check-declarations.cc` because it only depends on the symbol table.
Make use of `AttachDeclaration` when reporting errors
Refactor checks for different symbol details into separate functions
as they are getting more numerous.
Original-commit: flang-compiler/f18@cd0d6930bb
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
AttachDeclaration (and so also SayWithDeclaration) don't do anything
when passed a null pointer for the symbol and in all but one place they
are called the symbol can't be null. So change both function to take
`const Symbol &` rather than `const Symbol *`. Change it to handle
procedure bindings as well.
Add `SayWithDeclaration` to `CheckHelper` to simplify calling the one in
`evaluate` and prevent attaching the declaration when it would point at
the same line.
Original-commit: flang-compiler/f18@5f1c2ff663
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
`GenericDetails` and `GenericBindingDetails` were almost identical:
the former has optional data members to handle the case when a specific
procedure or derived type has the same name as the generic symbol.
Most places they are handled the same way so it simplifies things to
have only one type. In the case where we want to know if it is a generic
binding (e.g. in `mod-file.cc`) we can check the kind of scope that owns
the symbol.
Save name from the generic binding for better location of error messages.
Original-commit: flang-compiler/f18@f65a9edca2
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
Change GenericKind from an enum class to a variant that includes the
`NumericOperator`, `LogicalOperator`, and `RelationalOperator` from `common`.
This allows for better tests like `IsIntrinsicOperator` (which used to
check for being in a range of the `GenericKind` enumeration) and
simplifies mapping the kind to a string representation.
Original-commit: flang-compiler/f18@c74327c393
Reviewed-on: https://github.com/flang-compiler/f18/pull/841
Tree-same-pre-rewrite: false
This constraint prohibits deallocation of polymorphic entities in a DO
CONCURRENT.
Section 9.7.3.2 specifies the situations that might cause deallocation
of a polymorphic entity. The ones that are applicable to a DO CONCURRENT
are exiting from a block that declares such variables, intrinsic
assignment, and an actual DEALLOCATE statement. This section also
specifies (paragraph 8) that deallocation of a derived type causes
deallocation of all of its allocatable subobjects.
Section 10.2.1.3 specifies what happens during intrinsic assignment.
Paragraph 3 states If the variable is an allocated allocatable variable,
it is deallocated if expr is an array of different shape, any
corresponding length type parameter values of the variable and expr
differ, or the variable is polymorphic and the dynamic type or any
corresponding kind type parameter values of the variable and expr
differ." Thus, an allocatable polymorphic variable on the left hand side
of an assignment statement gets deallocated. Paragraph 13 states that
"For a noncoarray allocatable component the following sequence of
operations is applied.
(1) If the component of the variable is allocated, it is deallocated."
Thus, a variable on the left-hand side of an assignment statement might have noncorray allocatable components. Such components will be deallocated.
Deallocation can be caused by exiting from a block where the entity is
declared, from an assignment, and from direct deallocation.
Original-commit: flang-compiler/f18@7d1932d344
Reviewed-on: https://github.com/flang-compiler/f18/pull/814
We weren't handling MainProgram with no ProgramStmt correctly in
ProgramTree. When building it we were dereferencing an empty optional.
And in ResolveSpecificationParts we were dereferencing a null pointer.
Original-commit: flang-compiler/f18@1bda90d005
Reviewed-on: https://github.com/flang-compiler/f18/pull/827
Using debug build of f18, `omp-resolve01.f90` sometimes crashed in
`OmpVisitor::ResolveOmpObject`. This was because when the designator was
analyzed it could be rewritten from an `ArrayElement` to a `Substring`.
That made the reference to the `Name` inside the designator no longer
valid so the crash happened when it was referenced later. The fix is to
return when the substring is detected so the name is not referenced.
Also, the name returned from `ResolveDesignator` can but null so it must
be checked.
The crash in `RewriteOpenMPLoopConstruct` happened intermittently on
`omp-loop-association.f90`. It happened when the DO construct was the
last element of the block. In that case `block.erase()` returns an
iterator pointing to `block.end()` which must not be dereferenced.
Original-commit: flang-compiler/f18@3299972d04
Reviewed-on: https://github.com/flang-compiler/f18/pull/824
Update the grammar to handle logical abbreviations (e.g. `.A.` for `.AND.`)
when the feature is enabled. Only support `.X.` when both XOR and
logical abbreviations are enabled.
Fix the driver to enable logical abbreviations with the
`-flogical-abbreviations` option. This was already documented in
`documentation/Extensions.md`.
Remove `parser::Expr::XOR` from the parse tree and immediately map
`.XOR.` to `.NEQV.` if that feature is enabled. This was already being
done during expression analysis anyway.
Add `LanguageFeatureControl::GetNames` to return all of the names of
a logical or relational operator, depending on which features are
enabled. Use these in both name resolution and expression analysis.
Add `Not` to `LogicalOperator` to help in those cases.
Fix handling of BOZ literals: A numeric operation with one real or
integer operand and the other a BOZ literal is intrinsic.
Also, unary plus with a BOZ literal operand is also intrinsic.
Original-commit: flang-compiler/f18@956bd50bc7
Reviewed-on: https://github.com/flang-compiler/f18/pull/815
* Use Extremum<T> FoldOperation to fold MIN and MAX
* Fix Extremum<T> FolOperation
* For character, the length is the one of the longest argument.
Define and use `CharacterUtils<Kind>::Resize` helper to do this.
* For array of all types, Extremum<T> with Ordering::Less was
behaving like Ordering::Greater. This is because the default
`ApplyElementwise` for `Operation` was selected and it then
called the Extremum<T> constructor without the ordering
argument (which was an optional defaulted to Greater).
Define a specific handler for Extremum<T> and make the ordering
argument mandatory to prevent this kind of bug to pass
f18 compilation in the futur.
* Fix intrinsic.cc for MIN and MAX
* When provided with two arguments, `Match` was adding an empty
3rd optional actual argument. Later code working on min and
max was not expecting this and failing. The fix prevent this
empty argument to be created by changing the initial size of
`actualForDummy` to actually be the number of dummies that do
not have `Optionality::Repeats`
This commit fixes issue flang-compiler/f18#677.
Original-commit: flang-compiler/f18@acb62f240b
Reviewed-on: https://github.com/flang-compiler/f18/pull/803
Change `AllFortranNames()` to return a `std::vector` rather than a
`std::initialization_list`. The latter doesn't own its underlying
storage and so can't be returned as a value. clang detects this and
issues a warning.
Two tests in `resolve63.f90` behave differently with clang and require
further investigation.
Original-commit: flang-compiler/f18@1ed3a3cfee
Reviewed-on: https://github.com/flang-compiler/f18/pull/810
Enhance `ArgumentAnalyzer` to do most of the work for this.
For each kind of operator that might have a user-defined form we follow
this process:
- analyze the arguments
- if the types and shapes match the intrinsic operator do the usual
processing
- otherwise attempt to interpret it as a user-defined operator with
`TryDefinedOp`
When we fail to resolve an operator, produce different errors depending
on whether there is a user-defined operator available or not.
If there is, report that neither user-defined nor intrinsic operator
worked. If there is not, describe the rules for the intrinsic operator.
In either case, include the type(s) of the operand(s).
Most of the uses of `ArgumentAnalyzer` are in helper functions that
apply to classes of operators.
For consistency, rename `BinaryOperationHelper` to `NumericBinaryOperator`
and `LogicalHelper` to `LogicalBinaryHelper` and introduce `NumericUnaryHelper`
for unary `+` and `-`. `.NOT.` and `//` are not implemented in helpers.
Replace `success_` with `fatalErrors_` in `ArgumentAnalyzer` for
consistency with `ExpressionAnalyzer`.
Add `NumericOperator` and `LogicalOperator` enums to `Fortran.h` to go
with `RelationalOperator`. Add `AddFortran` functions to each to convert
to a Fortran source string. `RelationalOperator` also has `AllFortranNames`
because there are multiple names for each operator. This replaces
`LogicalOperator` in `expression.h` and the string representation of
the operators in `formatting.cc`.
Original-commit: flang-compiler/f18@3bb9d664e8
Reviewed-on: https://github.com/flang-compiler/f18/pull/807
Relax checking when irrelevant due to INTENT(IN)
Add and pass call14.f90 test on VALUE
Allow ASYNCHRONOUS/VOLATILE to apply to host/USE associated entities, add tests
Pass call06
Check C827 & C828, fix tests
Original-commit: flang-compiler/f18@df6cb83794
Reviewed-on: https://github.com/flang-compiler/f18/pull/801
Convert some CharBlock references to values
Replace more pointers with reference wrappers
Restore object references that were converted to value semantics in an earlier commit
Use Reference<> in Scope
Fix new component iterator
Document pitfall that bit me
final tweaks before rebasing and merging
Rebasing
Original-commit: flang-compiler/f18@87874af934
Reviewed-on: https://github.com/flang-compiler/f18/pull/788
During the symbol tests, OpenMP directives (start with "!$omp")
line needs to be saved for 1.f90 and 2.f90. Also moved "OPTIONS:"
detection to common.sh as "$USER_OPTIONS"
Original-commit: flang-compiler/f18@7d4e8e8ad5
The major changes are:
1) changed the non-nullptr type to reference
2) changed ResolveOmpObject to use std::visit
3) the rest of the changes are about positions and naming
Original-commit: flang-compiler/f18@93debe59f3
PR#753 changed the `OmpObject` to be:
```
struct OmpObject {
UNION_CLASS_BOILERPLATE(OmpObject);
std::variant<Designator, /*common block*/ Name> u;
};
```
This commit adjust the logic flow for `ResolveOmpObject` based on
the above parse tree change.
For an `OmpObject`,
```
if (Designator) {
if (DataRef.Name) {
// Resolve Names
} else {
// ResolveDesignator
// AnalyzeExpr
if (Designator.Substring) {
// Error
}
// other checks like StructureComponent, ArrayElement, etc.
}
} else if (Name) {
// Resolve COMMON block
}
```
Original-commit: flang-compiler/f18@e5c1b92c15
DSA stands for Data-Sharing Attribute. This work is part of the
Name Resolution for OpenMP framework (data-refs on clauses part)
Based on 2.15.3: A list item that specifies a given variable may
not appear in more than one clause on the same directive, except that
a variable may be specified in both firstprivate and lastprivate clauses.
Through a temporary `std::set` of `const Symbol *` to keep track of
all the symbols on a certain OpenMP directive, we can determine whether
a variable `Name` (or `Symbol`, more accurately) has already appeared on
another DSA clause already, with the exception of FIRSTPRIVATE clause
and LASTPRIVATE clause. This rule applies to `/COMMON block/` also and
the source provenance shows on error message points to the `Name` between
slashes.
Added two more tests and changed some existing tests to accommodate
this commit. I intend to keep the `omp-clause-validity01.f90` test to
do the validity checks only.
Original-commit: flang-compiler/f18@0d7828c21e
This is a preliminary framework to do the name resolution for
data references on the OpenMP clauses. Unlike data references
in the OpenMP region, clauses determining the data-sharing or
data-mapping attributes are straightforward and the resolution
process could be extended to do the name resolution in the OpenMP
region. It is hard to determine what kind of checks can be done
in this visitor and what checks should be done later after name
resolution. But the guide line is that `After the completion of
this phase, every Name corresponds to a Symbol with proper OpenMP
attribute(s) determined unless an error occurred.`
1. Take data-sharing clauses as example, create new symbol for
variable that require private access within the OpenMP region.
Declare the entity implicitly if necessary. The new symbol has
`HostAssocDetails`, which is mentioned in the `OpenMP-semantics.md`.
2. For `Shared` or `ThreadPrivate`, no symbol needs to be created.
OpenMP attribute Flag `OmpThreadprivate` needs to be marked for
`Threadprivate` because the `threadprivate` attribute remains the
same whenever these variables are referenced in the program.
`Names` in `Shared` clause need to be resolved to associate the
symbols in the clause enclosing scope (contains the OpenMP directive)
but `OmpShared` does not need to be marked. Declare the entity
implicitly if necessary.
3. For `COMMON block`, when a named common block appears in a list,
it has the same meaning as if every explicit member of the common
block appeared in the list. Also, a common block name specified in
a data-sharing attribute clause must be declared to be a common
block in the same scoping unit in which the data-sharing attribute
clause appears. So, if a named common block appears on a `PRIVATE`
clause, all its members should have new symbols created within the
OpenMP region (scope). For later Semantic checks and CG, a new
symbol is also created for common block name with `HostAssocDetails`.
There are many things are still on the TODO list:
- Better error/warning messages with directive/clause source provenance
- Resolve variables referenced in the OpenMP region, for example,
`private(tt%a)` is not allowed but `tt%a = 1` is allowed in the
OpenMP region and a private version of `tt` maybe created for
the region. The functions created in the `OmpVisitor` should be
able to handle the name resolution on the statement too (more
data structures may be introduced). This is a big portion and may
require some interface changes to distinguish a reference is on
`OpenMP directive/clause` or `statements within OpenMP region`.
- Same data reference appears on multiple data-sharing clauses.
- Take association into consideration for example Pointer association,
`ASSOCIATE` construct, and etc.
- Handle `Array Sections` and `Array or Structure Element`.
- Handle all the name resolution for directives/clauses that have
`parser::Name`.
- More tests
Original-commit: flang-compiler/f18@b2ea520885
This addresses issue flang-compiler/f18#781. I changed my test to create a PURE procedure
component by using an interface as suggested by Peter and Jean. I then
enhanced the function IsPureProcedure() in tools.cc to cover this case
and updated the code in check-do.cc to perform the test.
Original-commit: flang-compiler/f18@5df56a217d
Reviewed-on: https://github.com/flang-compiler/f18/pull/789
# This is the 1st commit message:
Changes to disallow image control statements in DO CONCURRENT
Most of these changes were already implemented. The last remaining part was to check for calls to move_alloc with coarray arguments. This set of changes implements that. I also bundled other changes. Specifically:
All of the code to detect image control statements was moved from check-do.cc to tools.cc so that it could be used by other semantic checking functions.
I added location information to the error messages for all DO semantics checks to highlight either the DO loop associated with the error or other relevant source locations.
I cleaned up the error messages associated with DO semantics so that they have more consistent grammar and punctuation.
I eliminated redundant checks for IEEE_GET_FLAG and IEEE_HALTING_MODE.
I removed the redundant test doconcurrent08.f90.
Responses to pull request comments
I changed the interface to determine whether a statement is an image control
statement to use an ExecutableConstruct as its input. Since
ExecutableConstruct contains types that do not have source location information
(ChangeTeamConstruct and CriticalConstruct), I also created a function to get
the source location of an ExecutableConstruct. Also, some ExecutableConstructs
are image control statements because they reference coarrays. I wanted to tell
users that the reason that an ALLOCATE statement (for example) is an image
control statement because it references a coarray. To make this happen, I
added another function to return a message for image control statements that
reference coarrays.
I also cleaned up the references to the standard in comments in check-do.cc to
briefly describe the contents of those constraints.
I also added messages that refer to the enclosing DO CONCURRENT statement for
error messages where appropriate.
Responses to pull request comments
The biggest change was to redo the implementation of "IsImageControlStmt()" to
use a custom visitor that strips off the "common::Indirection<...>" prefix of
most of the image control statement types and also takes advantage of
"common::HasMember<...>" to determine if a variant contains a specific type.
Spelling error.
# This is the commit message flang-compiler/f18#2:
More refactoring in response to comments on the pull request.
Original-commit: flang-compiler/f18@3f0a0155b3
Reviewed-on: https://github.com/flang-compiler/f18/pull/780
Most of these changes involve moving code around so that it case be
used for `DefinedUnary` and `DefinedBinary`. The functional changes are
in the `Analyze` member functions for those cases where the arguments
are now analyzed, the generic is resolved, and a `FunctionRef` is
created.
Add `ArgumentAnalyzer` to handling building of the `ActualArguments`
of a call. This allows the code to be shared with the defined unary
and defined binary cases. Move `AnalyzeActualArgument` and
`AnalyzeActualArgument` into that class (renaming both to `Analyze`).
Create an overload of `GetCalleeAndArguments` for the `Name` case so it
can be used for defined ops where we don't have a `ProcedureDesignator`.
Move `IsGenericDefinedOp` to `tools.h` to make it available to the
new code.
We were using `semantics::CheckExplicitInterface` to resolve a generic
interface to a specific procedure based on actual arguments. The problem
with that is that it performs too many checks. We just want to get the
right specific; there may be errors reported later during call analysis.
To fix this, add a new function, `CheckInterfaceForGeneric`, to perform
this check. It shares code with `CheckExplicitInterface`, but it passes
in a null scope to indicate that the full set of checks aren't
necessary in `CheckExplicitInterfaceArg`. Instead we lift the call to
`TypeAndShape::IsCompatibleWith` out of `CheckExplicitDataArg`, and skip
the latter when there is no scope.
Original-commit: flang-compiler/f18@fff2d1580f
Reviewed-on: https://github.com/flang-compiler/f18/pull/786
Implement the basics of resolving generic names in expressions.
`ExpressionAnalyzer::ResolveGeneric` maps the symbol for a generic
name to the specific procedure appropriate for the actual arguments.
Extract `CheckExplicitInterface` out of `CheckArguments` so that it
can be tried for each specific procedure of the generic as part of
the test to see which is compatible.
Note that it may be there is an elemental and non-elemental specific
procedure that is compatible with the actual arguments. In that case
the generic is resolved to the non-elemental one.
Test this by using generic functions in specification expressions
that must be written to module files. Verify how the generics were
resolved by looking at the generated `.mod` files.
There is more work to be done in this area: the passed-object dummy
argument is not considered and in some cases generated module files
are not correct.
Original-commit: flang-compiler/f18@50e458045a
Reviewed-on: https://github.com/flang-compiler/f18/pull/778
Extend documentation on preprocessing
IsSimplyContiguous
basic skeleton
Apply suggested improvements to mod-file.cc
Checks for new call13.f90 (15.4.2.2 explicit interfaces)
Implement checking for procedures that can be called via an implicit interface
Argument checking, test fixing
Better argument checking
Better derived type compatibility checking
Treat externals as if implicitly interfaced
Extend IEEE_EXCEPTIONS module so tests still pass with argument checking
SAME_TYPE_AS and EXTENDS_TYPE_OF intrinsic inquiry functions
Define interfaces for most intrinsic subroutines
Better PASS arguments
More with PASS() argument
Prep for review
address comments
fix comment
Remove formatted expression from specification expression error message per review
more review comments
Original-commit: flang-compiler/f18@3cca775da9
Reviewed-on: https://github.com/flang-compiler/f18/pull/776
This time I'm adding to the checks for constraint C1137, which states
that image control statements cannot appear in a DO CONCURRENT. The
checks I added test to see if the DO CONCURRENT contains an ALLOCATE or
DEALLOCATE that references a coarray.
Original-commit: flang-compiler/f18@c16b883db3
Reviewed-on: https://github.com/flang-compiler/f18/pull/769
There was already code in check-do.cc to test for the presence of a
variety of different image control statements, but several of them did
not have associated tests. This change adds tests for most of them.
Also, I removed the check for the END PROGRAM statement, since its
presence causes a syntax error which prevents the semantic check from
ever being reached.
Original-commit: flang-compiler/f18@9cc6f5bd40
Reviewed-on: https://github.com/flang-compiler/f18/pull/764
The tests run by `test_any.sh` don't redirect their .mod files to
a different directory so they occasionally fail when the same file
is accessed by different tests at the same time. With locking of
module files implemented, this problem reproduces much more reliably
Work around it by changing the module names to be distinct. Also remove
some comments left over when copied from `test_symbols.sh` tests.
Original-commit: flang-compiler/f18@f7b5c5f0fc
Reviewed-on: https://github.com/flang-compiler/f18/pull/758
Fix problems with writing a mod file while another compilation is
reading or writing. Write to a temp and then rename it:
- compute the new contents of the .mod file
- if it already exists, check if it is already correct
- if not, write new contents to a temp file
- rename the temp to the final destination
`mkstemps()` seems to be the best way to create the temp file.
It returns a file descriptor, so change the rest of the mod file
writing to use POSIX open/read/write/close. This seems to set
errno more reliably too.
There is some extra work around creating the temp to make it have
the same directory and suffix as the final file (so that if one gets
left behind by a crash, "rm *.mod" still cleans it up).
`mkstemps()` creates file with 0600 permissions so try to change it
to what it would have been if we just wrote the file.
Change module file reading to only read the file once; we used to
read it to verify the checksum and then again to parse it.
Instead, change `Parsing` so that we can get the file contents
after `Prescan()` and use that to verify the checksum. Also, it has
a mechanism for searching directories for files, so make use of that
instead of duplicating that functionality in `ModFileReader`.
This requires some changes to how errors are returned so they can
be reported in the right place.
Original-commit: flang-compiler/f18@d0d54971a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/758
Tree-same-pre-rewrite: false