From: Jakub Jelinek Date: Mon, 11 Mar 2019 22:27:39 +0000 (+0100) Subject: re PR fortran/89651 (OpenMP private array uninitialized warning with -O flag) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a7b9de8b70a53cc6beb7d4cfee449a4cfc2dee20;p=gcc.git re PR fortran/89651 (OpenMP private array uninitialized warning with -O flag) 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: r269598 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1c738baedaa..a3b47ac4980 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +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-03-11 Martin Liska * decl.c (match_record_decl): Wrap an option name diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 1fdb70e9bd8..0eb5956cc53 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -558,6 +558,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); @@ -664,6 +667,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 fdc7c40e450..8c992a8ed42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-03-11 Jakub Jelinek + PR fortran/89651 + * gfortran.dg/gomp/pr89651.f90: New test. + PR middle-end/89655 PR bootstrap/89656 * gcc.c-torture/compile/pr89655.c: New test. diff --git a/gcc/testsuite/gfortran.dg/gomp/pr89651.f90 b/gcc/testsuite/gfortran.dg/gomp/pr89651.f90 new file mode 100644 index 00000000000..b5054fdb5d8 --- /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