<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/flang/lib/Semantics/pointer-assignment.cpp, branch users/chapuni/cov/single/binop</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[flang] Better handling of weird pointer assignment case (#120628)</title>
<updated>2025-01-08T21:12:00+00:00</updated>
<author>
<name>Peter Klausler</name>
<email>pklausler@nvidia.com</email>
</author>
<published>2025-01-08T21:12:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b8513e439351b11a90b8aa69311cf57572405826'/>
<id>b8513e439351b11a90b8aa69311cf57572405826</id>
<content type='text'>
F'2023 C1017 permits the assignment of an unlimited polymorphic data
target to a monomorphic LHS pointer when the LHS pointer has a sequence
derived type (BIND(C) or SEQUENCE attribute). We allowed for this in
pointer assignments that don't have a function reference as their RHS.
Extend this support to function references, and also ensure that rank
compatibility is still checked.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
F'2023 C1017 permits the assignment of an unlimited polymorphic data
target to a monomorphic LHS pointer when the LHS pointer has a sequence
derived type (BIND(C) or SEQUENCE attribute). We allowed for this in
pointer assignments that don't have a function reference as their RHS.
Extend this support to function references, and also ensure that rank
compatibility is still checked.</pre>
</div>
</content>
</entry>
<entry>
<title>[flang] Tag warnings with LanguageFeature or UsageWarning (#110304)</title>
<updated>2024-10-02T15:54:49+00:00</updated>
<author>
<name>Peter Klausler</name>
<email>pklausler@nvidia.com</email>
</author>
<published>2024-10-02T15:54:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0f973ac783aa100cfbce1cd2c6e8a3a8f648fae7'/>
<id>0f973ac783aa100cfbce1cd2c6e8a3a8f648fae7</id>
<content type='text'>
(This is a big patch, but it's nearly an NFC. No test results have
changed and all Fortran tests in the LLVM test suites work as expected.)

Allow a parser::Message for a warning to be marked with the
common::LanguageFeature or common::UsageWarning that controls it. This
will allow a later patch to add hooks whereby a driver will be able to
decorate warning messages with the names of its options that enable each
particular warning, and to add hooks whereby a driver can map those
enumerators by name to command-line options that enable/disable the
language feature and enable/disable the messages.

The default settings in the constructor for LanguageFeatureControl were
moved from its header file into its C++ source file.

Hooks for a driver to use to map the name of a feature or warning to its
enumerator were also added.

To simplify the tagging of warnings with their corresponding language
feature or usage warning, to ensure that they are properly controlled by
ShouldWarn(), and to ensure that warnings never issue at code sites in
module files, two new Warn() member function templates were added to
SemanticsContext and other contextual frameworks. Warn() can't be used
before source locations can be mapped to scopes, but the bulk of
existing code blocks testing ShouldWarn() and FindModuleFile() before
calling Say() were convertible into calls to Warn(). The ones that were
not convertible were extended with explicit calls to
Message::set_languageFeature() and set_usageWarning().</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
(This is a big patch, but it's nearly an NFC. No test results have
changed and all Fortran tests in the LLVM test suites work as expected.)

Allow a parser::Message for a warning to be marked with the
common::LanguageFeature or common::UsageWarning that controls it. This
will allow a later patch to add hooks whereby a driver will be able to
decorate warning messages with the names of its options that enable each
particular warning, and to add hooks whereby a driver can map those
enumerators by name to command-line options that enable/disable the
language feature and enable/disable the messages.

The default settings in the constructor for LanguageFeatureControl were
moved from its header file into its C++ source file.

Hooks for a driver to use to map the name of a feature or warning to its
enumerator were also added.

To simplify the tagging of warnings with their corresponding language
feature or usage warning, to ensure that they are properly controlled by
ShouldWarn(), and to ensure that warnings never issue at code sites in
module files, two new Warn() member function templates were added to
SemanticsContext and other contextual frameworks. Warn() can't be used
before source locations can be mapped to scopes, but the bulk of
existing code blocks testing ShouldWarn() and FindModuleFile() before
calling Say() were convertible into calls to Warn(). The ones that were
not convertible were extended with explicit calls to
Message::set_languageFeature() and set_usageWarning().</pre>
</div>
</content>
</entry>
<entry>
<title>[flang] Tidy uses of raw_string_ostream (NFC)</title>
<updated>2024-09-17T17:20:21+00:00</updated>
<author>
<name>Youngsuk Kim</name>
<email>youngsuk.kim@hpe.com</email>
</author>
<published>2024-09-17T16:56:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d5dd7d230ecaf8242f4429a5e3653e16bf55bcd6'/>
<id>d5dd7d230ecaf8242f4429a5e3653e16bf55bcd6</id>
<content type='text'>
As specified in the docs,
1) raw_string_ostream is always unbuffered and
2) the underlying buffer may be used directly

( 65b13610a5226b84889b923bae884ba395ad084d for further reference )

Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As specified in the docs,
1) raw_string_ostream is always unbuffered and
2) the underlying buffer may be used directly

( 65b13610a5226b84889b923bae884ba395ad084d for further reference )

Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
</pre>
</div>
</content>
</entry>
<entry>
<title>[flang] Warn about undefined function results (#99533)</title>
<updated>2024-07-30T16:41:46+00:00</updated>
<author>
<name>Peter Klausler</name>
<email>35819229+klausler@users.noreply.github.com</email>
</author>
<published>2024-07-30T16:41:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=33c27f28d1cd05fd0a739498105927c1fba04666'/>
<id>33c27f28d1cd05fd0a739498105927c1fba04666</id>
<content type='text'>
When the result of a function never appears in a variable definition
context, emit a warning.

If the function has multiple result variables due to alternate ENTRY
statements, any definition will suffice.

The implementation of this check is tied to the general variable
definability checking utility in semantics. Every variable definition
context uses it to ensure that no undefinable variable is being defined.
A set of defined variables is maintained in the SemanticsContext and,
when the warning is enabled and no fatal error has been reported, the
scope tree is traversed and all the function subprograms' results are
tested for membership in that set.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When the result of a function never appears in a variable definition
context, emit a warning.

If the function has multiple result variables due to alternate ENTRY
statements, any definition will suffice.

The implementation of this check is tied to the general variable
definability checking utility in semantics. Every variable definition
context uses it to ensure that no undefinable variable is being defined.
A set of defined variables is maintained in the SemanticsContext and,
when the warning is enabled and no fatal error has been reported, the
scope tree is traversed and all the function subprograms' results are
tested for membership in that set.</pre>
</div>
</content>
</entry>
<entry>
<title>[flang] Downgrade error message to a portability warning (#98368)</title>
<updated>2024-07-11T20:12:00+00:00</updated>
<author>
<name>Peter Klausler</name>
<email>35819229+klausler@users.noreply.github.com</email>
</author>
<published>2024-07-11T20:12:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d5285fef00f6c5a725a515118192dd117fc3c665'/>
<id>d5285fef00f6c5a725a515118192dd117fc3c665</id>
<content type='text'>
f18 current emits an error when an assignment is made to an array
section with a vector subscript, and the array is finalized with a
non-elemental final subroutine. Some other compilers emit this error
because (I think) they want variables to only be finalized in place, not
by a subroutine call involving copy-in &amp; copy-out of the finalized
elements.

Since many other Fortran compilers can handle this case, and there's
nothing in the standards to preclude it, let's downgrade this error
message to a portability warning.

This patch got complicated because the API for the WhyNotDefinable()
utility routine was such that it would return a message only in error
cases, and there was no provision for returning non-fatal messages. It
now returns either nothing, a fatal message, or a non-fatal warning
message, and all of its call sites have been modified to cope.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
f18 current emits an error when an assignment is made to an array
section with a vector subscript, and the array is finalized with a
non-elemental final subroutine. Some other compilers emit this error
because (I think) they want variables to only be finalized in place, not
by a subroutine call involving copy-in &amp; copy-out of the finalized
elements.

Since many other Fortran compilers can handle this case, and there's
nothing in the standards to preclude it, let's downgrade this error
message to a portability warning.

This patch got complicated because the API for the WhyNotDefinable()
utility routine was such that it would return a message only in error
cases, and there was no provision for returning non-fatal messages. It
now returns either nothing, a fatal message, or a non-fatal warning
message, and all of its call sites have been modified to cope.</pre>
</div>
</content>
</entry>
<entry>
<title>[flang] Add/fix some semantic checks for assumed-rank (#96194)</title>
<updated>2024-06-24T16:57:30+00:00</updated>
<author>
<name>Peter Klausler</name>
<email>35819229+klausler@users.noreply.github.com</email>
</author>
<published>2024-06-24T16:57:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9ab292d72651c6dda098a653320f7fbb3624b778'/>
<id>9ab292d72651c6dda098a653320f7fbb3624b778</id>
<content type='text'>
Catch some cases where assumed rank dummy arguments are not allowed.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Catch some cases where assumed rank dummy arguments are not allowed.</pre>
</div>
</content>
</entry>
<entry>
<title>[flang] harden TypeAndShape for assumed-ranks (#96234)</title>
<updated>2024-06-24T08:21:04+00:00</updated>
<author>
<name>jeanPerier</name>
<email>jperier@nvidia.com</email>
</author>
<published>2024-06-24T08:21:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=73cf014223fed1947f725f7debcf19b8f54448b5'/>
<id>73cf014223fed1947f725f7debcf19b8f54448b5</id>
<content type='text'>
SIZEOF and C_SIZEOF were broken for assumed-ranks because
`TypeAndShape::MeasureSizeInBytes` behaved as a scalar because the
`TypeAndShape::shape_` member was the same for scalar and assumed-ranks.

The easy fix would have been to add special handling in
`MeasureSizeInBytes` for assumed-ranks using the TypeAndShape
attributes, but I think this solution would leave `TypeAndShape::shape_`
manipulation fragile to future developers. Hence, I went for the
solution that turn shape_ into a `std::optional&lt;Shape&gt;`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
SIZEOF and C_SIZEOF were broken for assumed-ranks because
`TypeAndShape::MeasureSizeInBytes` behaved as a scalar because the
`TypeAndShape::shape_` member was the same for scalar and assumed-ranks.

The easy fix would have been to add special handling in
`MeasureSizeInBytes` for assumed-ranks using the TypeAndShape
attributes, but I think this solution would leave `TypeAndShape::shape_`
manipulation fragile to future developers. Hence, I went for the
solution that turn shape_ into a `std::optional&lt;Shape&gt;`.</pre>
</div>
</content>
</entry>
<entry>
<title>[flang] Ensure all warning/portability messages are guarded by Should… (#90518)</title>
<updated>2024-05-01T21:33:14+00:00</updated>
<author>
<name>Peter Klausler</name>
<email>35819229+klausler@users.noreply.github.com</email>
</author>
<published>2024-05-01T21:33:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=505f6da1961ab55c601d7239648c53ce863b5d70'/>
<id>505f6da1961ab55c601d7239648c53ce863b5d70</id>
<content type='text'>
…Warn()

Many warning messages were being emitted unconditionally. Ensure that
all warnings are conditional on a true result from a call to
common::LanguageFeatureControl::ShouldWarn() so that it is easy for a
driver to disable them all, or, in the future, to provide per-warning
control over them.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
…Warn()

Many warning messages were being emitted unconditionally. Ensure that
all warnings are conditional on a true result from a call to
common::LanguageFeatureControl::ShouldWarn() so that it is easy for a
driver to disable them all, or, in the future, to provide per-warning
control over them.</pre>
</div>
</content>
</entry>
<entry>
<title>[flang] Make proc characterization error conditional for generics (#89429)</title>
<updated>2024-04-22T22:21:45+00:00</updated>
<author>
<name>Peter Klausler</name>
<email>35819229+klausler@users.noreply.github.com</email>
</author>
<published>2024-04-22T22:21:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=cb2639196842630c0a1d5f91e26261f1c42b49fb'/>
<id>cb2639196842630c0a1d5f91e26261f1c42b49fb</id>
<content type='text'>
When the characteristics of a procedure depend on a procedure that
hasn't yet been defined, the compiler currently emits an unconditional
error message. This includes the case of a procedure whose
characteristics depend, perhaps indirectly, on itself. However, in the
case where the characteristics of a procedure are needed to resolve a
generic, we should not emit an error for a hitherto undefined procedure
-- either the call will resolve to another specific procedure, in which
case the error is spurious, or it won't, and then an error will issue
anyway.

Fixes https://github.com/llvm/llvm-project/issues/88677.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When the characteristics of a procedure depend on a procedure that
hasn't yet been defined, the compiler currently emits an unconditional
error message. This includes the case of a procedure whose
characteristics depend, perhaps indirectly, on itself. However, in the
case where the characteristics of a procedure are needed to resolve a
generic, we should not emit an error for a hitherto undefined procedure
-- either the call will resolve to another specific procedure, in which
case the error is spurious, or it won't, and then an error will issue
anyway.

Fixes https://github.com/llvm/llvm-project/issues/88677.</pre>
</div>
</content>
</entry>
<entry>
<title>[Flang] Relaxing an error when contiguous pointer is assigned to a non-contig… (#86781)</title>
<updated>2024-04-01T11:43:22+00:00</updated>
<author>
<name>harishch4</name>
<email>harishcse44@gmail.com</email>
</author>
<published>2024-04-01T11:43:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f546b6ef3c15a156959dde16fa5f03a350a0a2be'/>
<id>f546b6ef3c15a156959dde16fa5f03a350a0a2be</id>
<content type='text'>
…uous function.

Fix from [thtsikas](https://github.com/thtsikas) based on a discussion
in
[slack](https://flang-compiler.slack.com/archives/C5C58TT32/p1711124374836079).

Example:
```
Program test
  Integer, Pointer, Contiguous :: cont(:)
  Interface
     Function f()
       Integer, Pointer :: f(:)
     End Function
  End Interface
  cont =&gt; f()
  Print *, cont(3)
End Program

Function f()
  Integer, Pointer :: f(:)
  Allocate (f(4),Source=[1,1,42,1])
  ! f =&gt; f(4:1:-1)        !! not contiguous, runtime error
End Function f
```

Understanding is that the standard intended to allow this pattern. The
restriction 10.2.2.3 p6 Data pointer assignment "If the pointer object
has the CONTIGUOUS attribute, the pointer target shall be contiguous."
is not associated with a numbered constraint. If there is a mechanism
for injecting runtime checks, this would be a place to do it. Absent
that, a warning is the best we can do.

No other compiler treats contigPtr =&gt; func() as an error when func() is
not CONTIGUOUS, so a warning would probably be better for consistency.
https://godbolt.org/z/5cM6roeEE</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
…uous function.

Fix from [thtsikas](https://github.com/thtsikas) based on a discussion
in
[slack](https://flang-compiler.slack.com/archives/C5C58TT32/p1711124374836079).

Example:
```
Program test
  Integer, Pointer, Contiguous :: cont(:)
  Interface
     Function f()
       Integer, Pointer :: f(:)
     End Function
  End Interface
  cont =&gt; f()
  Print *, cont(3)
End Program

Function f()
  Integer, Pointer :: f(:)
  Allocate (f(4),Source=[1,1,42,1])
  ! f =&gt; f(4:1:-1)        !! not contiguous, runtime error
End Function f
```

Understanding is that the standard intended to allow this pattern. The
restriction 10.2.2.3 p6 Data pointer assignment "If the pointer object
has the CONTIGUOUS attribute, the pointer target shall be contiguous."
is not associated with a numbered constraint. If there is a mechanism
for injecting runtime checks, this would be a place to do it. Absent
that, a warning is the best we can do.

No other compiler treats contigPtr =&gt; func() as an error when func() is
not CONTIGUOUS, so a warning would probably be better for consistency.
https://godbolt.org/z/5cM6roeEE</pre>
</div>
</content>
</entry>
</feed>
