From: Jakub Jelinek Date: Fri, 30 Aug 2019 12:15:50 +0000 (+0200) Subject: backport: re PR fortran/89651 (OpenMP private array uninitialized warning with -O... X-Git-Tag: releases/gcc-7.5.0~236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a9111961c44840cd1d58eed15d4e2418abd34ce;p=thirdparty%2Fgcc.git backport: re PR fortran/89651 (OpenMP private array uninitialized warning with -O flag) Backported from mainline 2019-03-11 Jakub Jelinek PR fortran/89651 * trans-openmp.c (gfc_omp_clause_default_ctor): Set TREE_NO_WARNING on decl if adding COND_EXPR for allocatable. (gfc_omp_clause_copy_ctor): Set TREE_NO_WARNING on dest. * gfortran.dg/gomp/pr89651.f90: New test. From-SVN: r275127 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b2b534a709fc..51d6a4ebbcfd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,6 +1,13 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 2019-03-11 Jakub Jelinek + + PR fortran/89651 + * trans-openmp.c (gfc_omp_clause_default_ctor): Set TREE_NO_WARNING + on decl if adding COND_EXPR for allocatable. + (gfc_omp_clause_copy_ctor): Set TREE_NO_WARNING on dest. + 2019-02-01 Jakub Jelinek PR fortran/83246 diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 7e24ec6706c5..d114884beaa7 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -547,6 +547,9 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree outer) build3_loc (input_location, COND_EXPR, void_type_node, cond, then_b, else_b)); + /* Avoid -W*uninitialized warnings. */ + if (DECL_P (decl)) + TREE_NO_WARNING (decl) = 1; } else gfc_add_expr_to_block (&block, then_b); @@ -653,6 +656,9 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src) gfc_add_expr_to_block (&block, build3_loc (input_location, COND_EXPR, void_type_node, cond, then_b, else_b)); + /* Avoid -W*uninitialized warnings. */ + if (DECL_P (dest)) + TREE_NO_WARNING (dest) = 1; return gfc_finish_block (&block); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e08f576ae456..c1b79b10abf6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 2019-03-11 Jakub Jelinek + + PR fortran/89651 + * gfortran.dg/gomp/pr89651.f90: New test. + 2019-03-09 Jakub Jelinek PR c/88568 diff --git a/gcc/testsuite/gfortran.dg/gomp/pr89651.f90 b/gcc/testsuite/gfortran.dg/gomp/pr89651.f90 new file mode 100644 index 000000000000..b5054fdb5d81 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr89651.f90 @@ -0,0 +1,21 @@ +! PR fortran/89651 +! { dg-do compile } +! { dg-additional-options "-Wuninitialized" } + +program pr89651 + integer :: n + real, allocatable :: t(:) + n = 10 + allocate (t(n), source = 0.0) +!$omp parallel firstprivate(t) + print *, sum (t) ! { dg-bogus "lbound' may be used uninitialized in this function" } + ! { dg-bogus "ubound' may be used uninitialized in this function" "" { target *-*-* } .-1 } + ! { dg-bogus "offset' may be used uninitialized in this function" "" { target *-*-* } .-2 } +!$omp end parallel +!$omp parallel private(t) + t = 0.0 + print *, sum (t) ! { dg-bogus "lbound' may be used uninitialized in this function" } + ! { dg-bogus "ubound' may be used uninitialized in this function" "" { target *-*-* } .-1 } + ! { dg-bogus "offset' may be used uninitialized in this function" "" { target *-*-* } .-2 } +!$omp end parallel +end program pr89651