* [Patch] Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping
@ 2022-03-08 14:25 Tobias Burnus
2022-03-10 9:00 ` Thomas Schwinge
0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2022-03-08 14:25 UTC (permalink / raw)
To: gcc-patches, fortran, Thomas Schwinge, Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 1470 bytes --]
Hi Thomas & Jakub,
found when working on the deep-mapping patch* with OpenMP code
(and part of that patch) but it already shows up in an existing
OpenACC testcase. I think it makes sense to fix it already for GCC 12.
Problem: Also for unallocated allocatables, their size was
calculated - the 'if(desc.data == NULL)' check was only added
for pointers.
Result after the patch: When compiling with -O (which is the default
for goacc.exp), the warning now disappears. Thus, I now use '-O0'
and the previous "is uninitialized" is now "may be uninitialized".
Unrelated to the patch and the testcase, I added some
'allocate'**/'if(allocated())' to the testcase - as otherwise
uninit vars would be accessed. (Not relevant for the warning
or the patch - but I prefer no invalid code in testcases,
if it can be avoided.)
OK for mainline?
Tobias
* https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591144.html
** I am actually not sure whether 'acc update(b)' will/should map a
previous allocated variable - or whether it should. But that's
unrelated to this bug fix. See also: https://gcc.gnu.org/PR96668
for the re-mapping in OpenMP (works for arrays but not scalars).
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Attachment #2: uninit-map.diff --]
[-- Type: text/x-patch, Size: 3885 bytes --]
Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_trans_omp_clauses, gfc_omp_finish_clause):
Obtain size for mapping only if allocatable array is allocated.
gcc/testsuite/ChangeLog:
* gfortran.dg/goacc/array-with-dt-1.f90: Run with -O0 and
update dg-warning.
* gfortran.dg/goacc/pr93464.f90: Likewise.
gcc/fortran/trans-openmp.cc | 6 ++++--
gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 | 12 +++++++++---
gcc/testsuite/gfortran.dg/goacc/pr93464.f90 | 8 ++++----
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 4d56a771349..fad76a4791f 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -1597,7 +1597,8 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc)
tree size = create_tmp_var (gfc_array_index_type);
tree elemsz = TYPE_SIZE_UNIT (gfc_get_element_type (type));
elemsz = fold_convert (gfc_array_index_type, elemsz);
- if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
+ if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE
+ || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
|| GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT)
{
stmtblock_t cond_block;
@@ -3208,7 +3209,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
/* We have to check for n->sym->attr.dimension because
of scalar coarrays. */
- if (n->sym->attr.pointer && n->sym->attr.dimension)
+ if ((n->sym->attr.pointer || n->sym->attr.allocatable)
+ && n->sym->attr.dimension)
{
stmtblock_t cond_block;
tree size
diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
index 136e42acd59..f6880238c89 100644
--- a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
@@ -1,4 +1,4 @@
-! { dg-additional-options -Wuninitialized }
+! { dg-additional-options "-Wuninitialized -O0" }
type t
integer, allocatable :: A(:,:)
@@ -8,9 +8,15 @@ type(t), allocatable :: b(:)
! { dg-note {'b' declared here} {} { target *-*-* } .-1 }
!$acc update host(b)
-! { dg-warning {'b\.dim\[0\]\.ubound' is used uninitialized} {} { target *-*-* } .-1 }
-! { dg-warning {'b\.dim\[0\]\.lbound' is used uninitialized} {} { target *-*-* } .-2 }
+! { dg-warning {'b\.dim\[0\]\.ubound' may be used uninitialized} {} { target *-*-* } .-1 }
+! { dg-warning {'b\.dim\[0\]\.lbound' may be used uninitialized} {} { target *-*-* } .-2 }
+
+allocate(b(1))
+!$acc update host(b)
!$acc update host(b(:))
+
+!$acc update host(b(1)%A)
+allocate(b(1)%A(1,1))
!$acc update host(b(1)%A)
!$acc update host(b(1)%A(:,:))
end
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
index c92f1d3d8b2..18531abdf77 100644
--- a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
@@ -2,17 +2,17 @@
!
! Contributed by G. Steinmetz
-! { dg-additional-options -Wuninitialized }
+! { dg-additional-options "-Wuninitialized -O0" }
program p
character :: c(2) = 'a'
character, allocatable :: z(:)
! { dg-note {'z' declared here} {} { target *-*-* } .-1 }
!$acc parallel
- ! { dg-warning {'z\.dim\[0\]\.ubound' is used uninitialized} {} { target *-*-* } .-1 }
- ! { dg-warning {'z\.dim\[0\]\.lbound' is used uninitialized} {} { target *-*-* } .-2 }
+ ! { dg-warning {'z\.dim\[0\]\.ubound' may be used uninitialized} {} { target *-*-* } .-1 }
+ ! { dg-warning {'z\.dim\[0\]\.lbound' may be used uninitialized} {} { target *-*-* } .-2 }
!$omp target
- z = c
+ if (allocated(z)) z = c
!$acc end parallel
!$omp end target
print *, z
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping
2022-03-08 14:25 [Patch] Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping Tobias Burnus
@ 2022-03-10 9:00 ` Thomas Schwinge
2022-03-10 11:44 ` Tobias Burnus
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Schwinge @ 2022-03-10 9:00 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches, fortran, Jakub Jelinek
Hi Tobias!
On 2022-03-08T15:25:07+0100, Tobias Burnus <tobias@codesourcery.com> wrote:
> found when working on the deep-mapping patch* with OpenMP code
> (and part of that patch) but it already shows up in an existing
> OpenACC testcase. I think it makes sense to fix it already for GCC 12.
>
> Problem: Also for unallocated allocatables, their size was
> calculated - the 'if(desc.data == NULL)' check was only added
> for pointers.
>
> Result after the patch: When compiling with -O (which is the default
> for goacc.exp), the warning now disappears. Thus, I now use '-O0'
> and the previous "is uninitialized" is now "may be uninitialized".
I recently added that checking in
commit 4bd8b1e881f0c26a5103cd1919809b3d63b60ef2
"Document current '-Wuninitialized'/'-Wmaybe-uninitialized' diagnostics
for OpenACC test cases", to document the status quo.
I'll leave it to you to decide what is more appropriate: (1), as you have
proposed, add '-O0' (but with source code comment, please); something
like:
! { dg-additional-options -Wuninitialized }
+! Trigger "may be used uninitialized".
+! { dg-additional-options -O0 }
..., or (2): update the test cases to simply reflect diagnostics that are
now (no longer) seen with (default) '-O' (rationale: the test cases
haven't originally been written for the '-Wuninitialized' diagnostics;
that's just tested additionally, and using '-O0' instead of '-O' may be
disturbing what they originally meant to test?), or (3): duplicate the
test cases to account for both (1) and (2) (in other words: write
dedicated test cases for your GCC/Fortran front end changes (for example,
based on the ones you've modified here), and for the existing test cases
apply (2)). The latter, (3), would be my approach.
> Unrelated to the patch and the testcase, I added some
> 'allocate'**/'if(allocated())' to the testcase - as otherwise
> uninit vars would be accessed. (Not relevant for the warning
> or the patch - but I prefer no invalid code in testcases,
> if it can be avoided.)
Agreed in principle, but again: I don't know what these test cases
originally have been testing?
> OK for mainline?
I can't comment on the GCC/Fortran front end changes -- so unless
somebody else speaks up, that's an implicit approval for those, I
suppose. ;-)
> Tobias
> * https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591144.html
> ** I am actually not sure whether 'acc update(b)' will/should map a
> previous allocated variable - or whether it should.
(Are the typos here: in "will/should map": 's%map%update', and in
"or whether it should": 's%should%shouldn't'?)
> But that's
> unrelated to this bug fix. See also: https://gcc.gnu.org/PR96668
> for the re-mapping in OpenMP (works for arrays but not scalars).
I don't quickly dig that, sorry. Do we need to first clarify that with
OpenACC Technical Committee, or is this just a GCC/OpenACC implementation
issue?
Grüße
Thomas
> Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping
>
> gcc/fortran/ChangeLog:
>
> * trans-openmp.cc (gfc_trans_omp_clauses, gfc_omp_finish_clause):
> Obtain size for mapping only if allocatable array is allocated.
>
> gcc/testsuite/ChangeLog:
>
> * gfortran.dg/goacc/array-with-dt-1.f90: Run with -O0 and
> update dg-warning.
> * gfortran.dg/goacc/pr93464.f90: Likewise.
>
> gcc/fortran/trans-openmp.cc | 6 ++++--
> gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 | 12 +++++++++---
> gcc/testsuite/gfortran.dg/goacc/pr93464.f90 | 8 ++++----
> 3 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
> index 4d56a771349..fad76a4791f 100644
> --- a/gcc/fortran/trans-openmp.cc
> +++ b/gcc/fortran/trans-openmp.cc
> @@ -1597,7 +1597,8 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc)
> tree size = create_tmp_var (gfc_array_index_type);
> tree elemsz = TYPE_SIZE_UNIT (gfc_get_element_type (type));
> elemsz = fold_convert (gfc_array_index_type, elemsz);
> - if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
> + if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE
> + || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
> || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT)
> {
> stmtblock_t cond_block;
> @@ -3208,7 +3209,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
>
> /* We have to check for n->sym->attr.dimension because
> of scalar coarrays. */
> - if (n->sym->attr.pointer && n->sym->attr.dimension)
> + if ((n->sym->attr.pointer || n->sym->attr.allocatable)
> + && n->sym->attr.dimension)
> {
> stmtblock_t cond_block;
> tree size
> diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
> index 136e42acd59..f6880238c89 100644
> --- a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
> +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
> @@ -1,4 +1,4 @@
> -! { dg-additional-options -Wuninitialized }
> +! { dg-additional-options "-Wuninitialized -O0" }
>
> type t
> integer, allocatable :: A(:,:)
> @@ -8,9 +8,15 @@ type(t), allocatable :: b(:)
> ! { dg-note {'b' declared here} {} { target *-*-* } .-1 }
>
> !$acc update host(b)
> -! { dg-warning {'b\.dim\[0\]\.ubound' is used uninitialized} {} { target *-*-* } .-1 }
> -! { dg-warning {'b\.dim\[0\]\.lbound' is used uninitialized} {} { target *-*-* } .-2 }
> +! { dg-warning {'b\.dim\[0\]\.ubound' may be used uninitialized} {} { target *-*-* } .-1 }
> +! { dg-warning {'b\.dim\[0\]\.lbound' may be used uninitialized} {} { target *-*-* } .-2 }
> +
> +allocate(b(1))
> +!$acc update host(b)
> !$acc update host(b(:))
> +
> +!$acc update host(b(1)%A)
> +allocate(b(1)%A(1,1))
> !$acc update host(b(1)%A)
> !$acc update host(b(1)%A(:,:))
> end
> diff --git a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
> index c92f1d3d8b2..18531abdf77 100644
> --- a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
> +++ b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
> @@ -2,17 +2,17 @@
> !
> ! Contributed by G. Steinmetz
>
> -! { dg-additional-options -Wuninitialized }
> +! { dg-additional-options "-Wuninitialized -O0" }
>
> program p
> character :: c(2) = 'a'
> character, allocatable :: z(:)
> ! { dg-note {'z' declared here} {} { target *-*-* } .-1 }
> !$acc parallel
> - ! { dg-warning {'z\.dim\[0\]\.ubound' is used uninitialized} {} { target *-*-* } .-1 }
> - ! { dg-warning {'z\.dim\[0\]\.lbound' is used uninitialized} {} { target *-*-* } .-2 }
> + ! { dg-warning {'z\.dim\[0\]\.ubound' may be used uninitialized} {} { target *-*-* } .-1 }
> + ! { dg-warning {'z\.dim\[0\]\.lbound' may be used uninitialized} {} { target *-*-* } .-2 }
> !$omp target
> - z = c
> + if (allocated(z)) z = c
> !$acc end parallel
> !$omp end target
> print *, z
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping
2022-03-10 9:00 ` Thomas Schwinge
@ 2022-03-10 11:44 ` Tobias Burnus
0 siblings, 0 replies; 3+ messages in thread
From: Tobias Burnus @ 2022-03-10 11:44 UTC (permalink / raw)
To: Thomas Schwinge, Tobias Burnus; +Cc: Jakub Jelinek, gcc-patches, fortran
[-- Attachment #1: Type: text/plain, Size: 2980 bytes --]
Hi Thomas, hi all,
(Updated patch attached – only changes the goacc testcases.
I intent to commit the patch tomorrow, unless more comments come up.)
On 10.03.22 10:00, Thomas Schwinge wrote:
[OpenACC testcases:]
> I recently added that checking in ... [...] to document the status quo.
> (1), as you have proposed, add '-O0' (but with source code comment, please); [...]
> ..., or (2): update the test cases [...] (rationale: the test cases
> haven't originally been written for the '-Wuninitialized' diagnostics; [...]
> (3): duplicate the test cases to account for both (1) and (2)
> [...] (3), would be my approach.
Attached patch does (3). I also remove the code tweaking, added in previous
patch. - But added a bunch of comments.
And I have to admit that I did not realize that the -Wuninitialized was only
added later. (I did not expect that new flags get added to existing patches.)
>> ** I am actually not sure whether 'acc update(b)' will/should map a
>> previous allocated variable - or whether it should. [...]
>> testcases.
Should be: "previously *un*allocated" (+ Thomas s%...%.. comments).
> I don't quickly dig that, sorry. Do we need to first clarify that with
> OpenACC Technical Committee, or is this just a GCC/OpenACC implementation
> issue?
That's mostly an OpenACC spec question.
But I did not check what the spec says. Thus, I don't know
* whether the spec needs to be improved
* what the implications are on the implementation.
I assume that the implementation for OpenMP does also make sense for
OpenACC (i.e. either works as required or does more but in a sensible
way) - but I don't know.
I think either/both of us should check the OpenACC spec.
* * *
On the OpenMP side (clarified in 5.1 or 5.2):
* Map first an unallocated allocatable
=> That one is regarded as mapped/present
* Allocate it and map it again (e.g. implicit/explicit
mapping for a target region)
=> Spec: Implementation may or may not update the item.
However, (only) with 'always' the spec guarantees that it
will also show up as allocated on the device.
=> Sentiment: should also work without 'always' modifier
if previously unallocated. (Discussion postponed.)
* I have not checked 'update' but I think it behaves
like 'map(always,to/from:' (except for ref counting)
OpenMP GCC implementation: there is a known issue for
scalar allocatables (PR96668). It does work for arrays
(also without 'always') - and 'omp update' has not been
checked. (Ref counting issues?)
OpenACC GCC implementation: I think this code is shared
with OpenMP and, thus, works likewise. But I have have
also not checked this.
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Attachment #2: uninit-map-v2.diff --]
[-- Type: text/x-patch, Size: 6948 bytes --]
Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_trans_omp_clauses, gfc_omp_finish_clause):
Obtain size for mapping only if allocatable array is allocated.
gcc/testsuite/ChangeLog:
* gfortran.dg/goacc/array-with-dt-1.f90: Update/add comments;
remove dg-warning for 'is used uninitialized'.
* gfortran.dg/goacc/pr93464.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-1a.f90: New; copied from
gfortran.dg/goacc/array-with-dt-1.f90 but run with -O0. Update
dg-warning for 'may be used uninitialized'.
* gfortran.dg/goacc/pr93464-2.f90: Likewise; copied from
gfortran.dg/goacc/pr93464.f90.
gcc/fortran/trans-openmp.cc | 6 +++--
.../gfortran.dg/goacc/array-with-dt-1.f90 | 18 ++++++++++++---
.../gfortran.dg/goacc/array-with-dt-1a.f90 | 27 ++++++++++++++++++++++
gcc/testsuite/gfortran.dg/goacc/pr93464-2.f90 | 26 +++++++++++++++++++++
gcc/testsuite/gfortran.dg/goacc/pr93464.f90 | 12 ++++++----
5 files changed, 80 insertions(+), 9 deletions(-)
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 4d56a771349..fad76a4791f 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -1597,7 +1597,8 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc)
tree size = create_tmp_var (gfc_array_index_type);
tree elemsz = TYPE_SIZE_UNIT (gfc_get_element_type (type));
elemsz = fold_convert (gfc_array_index_type, elemsz);
- if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
+ if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE
+ || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
|| GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT)
{
stmtblock_t cond_block;
@@ -3208,7 +3209,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
/* We have to check for n->sym->attr.dimension because
of scalar coarrays. */
- if (n->sym->attr.pointer && n->sym->attr.dimension)
+ if ((n->sym->attr.pointer || n->sym->attr.allocatable)
+ && n->sym->attr.dimension)
{
stmtblock_t cond_block;
tree size
diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
index 136e42acd59..fb27f6e4058 100644
--- a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
@@ -1,15 +1,27 @@
! { dg-additional-options -Wuninitialized }
+! Purpose of this testcase (from the commit log):
+! This patch fixes lowering of derived-type mappings which select elements
+! of arrays of derived types, and similar. These would previously lead
+! to ICEs.
+
+! This testcase does not show any uninitialized warnings when compiled with -O
+! (as done). For -O0, see testcase file 'array-with-dt-1a.f90'.
+
type t
integer, allocatable :: A(:,:)
end type t
type(t), allocatable :: b(:)
-! { dg-note {'b' declared here} {} { target *-*-* } .-1 }
+
+! Remark: Semantically, the following line requires that 'b'
+! is already present on the device.
!$acc update host(b)
-! { dg-warning {'b\.dim\[0\]\.ubound' is used uninitialized} {} { target *-*-* } .-1 }
-! { dg-warning {'b\.dim\[0\]\.lbound' is used uninitialized} {} { target *-*-* } .-2 }
+
+! Remark: Semantically, the following lines require that b is allocated
+! and present on the device. The last line also requires the same for 'A'.
+
!$acc update host(b(:))
!$acc update host(b(1)%A)
!$acc update host(b(1)%A(:,:))
diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1a.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1a.f90
new file mode 100644
index 00000000000..8beaeb45e2e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1a.f90
@@ -0,0 +1,27 @@
+! { dg-additional-options "-Wuninitialized -O0" }
+!
+! With -O0 only, 'may be uninitalized' warnings show up.
+! For the original testcase, compiled with '-O',
+! see testcase file 'array-with-dt-1a.f90'
+
+type t
+ integer, allocatable :: A(:,:)
+end type t
+
+type(t), allocatable :: b(:)
+! { dg-note {'b' declared here} {} { target *-*-* } .-1 }
+
+! Remark: Semantically, the following line requires that 'b'
+! is already present on the device.
+
+!$acc update host(b)
+! { dg-warning {'b\.dim\[0\]\.ubound' may be used uninitialized} {} { target *-*-* } .-1 }
+! { dg-warning {'b\.dim\[0\]\.lbound' may be used uninitialized} {} { target *-*-* } .-2 }
+
+! Remark: Semantically, the following lines require that b is allocated
+! and present on the device. The last line also requires the same for 'A'.
+
+!$acc update host(b(:))
+!$acc update host(b(1)%A)
+!$acc update host(b(1)%A(:,:))
+end
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr93464-2.f90 b/gcc/testsuite/gfortran.dg/goacc/pr93464-2.f90
new file mode 100644
index 00000000000..5da6a4eb7b0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/pr93464-2.f90
@@ -0,0 +1,26 @@
+! { dg-additional-options "-Wuninitialized -O0" }
+!
+! PR fortran/93464
+!
+! Contributed by G. Steinmetz
+!
+! Did before ICE in gfc_omp_check_optional_argument
+
+! Additionally, check for uninitialized warnings. There are
+! none with -O (cf. original testcase file 'pr93464.f90').
+! For -O0, see below:
+
+program p
+ character :: c(2) = 'a'
+ character, allocatable :: z(:)
+ ! { dg-note {'z' declared here} {} { target *-*-* } .-1 }
+ !$acc parallel
+ ! { dg-warning {'z\.dim\[0\]\.ubound' may be used uninitialized} {} { target *-*-* } .-1 }
+ ! { dg-warning {'z\.dim\[0\]\.lbound' may be used uninitialized} {} { target *-*-* } .-2 }
+ !$omp target
+ ! Remark: As run-time check, required either 'c' being allocated or if(allocated(c)':
+ z = c
+ !$acc end parallel
+ !$omp end target
+ print *, z
+end
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
index c92f1d3d8b2..1b5ca7d1c76 100644
--- a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90
@@ -1,17 +1,21 @@
+! { dg-additional-options -Wuninitialized }
+!
! PR fortran/93464
!
! Contributed by G. Steinmetz
+!
+! Did before ICE in gfc_omp_check_optional_argument
-! { dg-additional-options -Wuninitialized }
+! Additionally, check for uninitialized warnings.
+! Compiled with -O (as done here), no show up;
+! for -O0, see testcase file 'pr93464-1.f90'.
program p
character :: c(2) = 'a'
character, allocatable :: z(:)
- ! { dg-note {'z' declared here} {} { target *-*-* } .-1 }
!$acc parallel
- ! { dg-warning {'z\.dim\[0\]\.ubound' is used uninitialized} {} { target *-*-* } .-1 }
- ! { dg-warning {'z\.dim\[0\]\.lbound' is used uninitialized} {} { target *-*-* } .-2 }
!$omp target
+ ! Remark: As run-time check, required either 'c' being allocated or if(allocated(c)':
z = c
!$acc end parallel
!$omp end target
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-10 11:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 14:25 [Patch] Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping Tobias Burnus
2022-03-10 9:00 ` Thomas Schwinge
2022-03-10 11:44 ` Tobias Burnus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).