]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/89651 (OpenMP private array uninitialized warning with -O...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:15:50 +0000 (14:15 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:15:50 +0000 (14:15 +0200)
Backported from mainline
2019-03-11  Jakub Jelinek  <jakub@redhat.com>

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

gcc/fortran/ChangeLog
gcc/fortran/trans-openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/gomp/pr89651.f90 [new file with mode: 0644]

index b2b534a709fc2d604bbdc230e3a246ff5d15f31d..51d6a4ebbcfdc49d8d32279037bd9b0afbd632e6 100644 (file)
@@ -1,6 +1,13 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-03-11  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <jakub@redhat.com>
 
        PR fortran/83246
index 7e24ec6706c554ba673bda3e2b0fe67612e98822..d114884beaa7c6a84f333f6e8913cecc76f43a9b 100644 (file)
@@ -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);
 }
index e08f576ae4560eac5a6a7f6c99292c953d47d96e..c1b79b10abf6c4feb4fd18be73509c41073b0c9d 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-03-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/89651
+       * gfortran.dg/gomp/pr89651.f90: New test.
+
        2019-03-09  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..b5054fd
--- /dev/null
@@ -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