aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-openmp.cc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-03-11 08:48:58 +0100
committerTobias Burnus <tobias@codesourcery.com>2022-03-11 08:48:58 +0100
commit41bda0036ce81e7ac513f325e7b0f41ccf11cbab (patch)
tree9add88c8a39abefc167dddc6117aa9d376d2d90b /gcc/fortran/trans-openmp.cc
parent5e28be89665f340368e399a1f2140c96a7a79ee8 (diff)
downloadgcc-41bda0036ce81e7ac513f325e7b0f41ccf11cbab.zip
gcc-41bda0036ce81e7ac513f325e7b0f41ccf11cbab.tar.gz
gcc-41bda0036ce81e7ac513f325e7b0f41ccf11cbab.tar.bz2
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.
Diffstat (limited to 'gcc/fortran/trans-openmp.cc')
-rw-r--r--gcc/fortran/trans-openmp.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 4d56a771..fad76a4 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