Commit a7b9de8b by Jakub Jelinek Committed by Jakub Jelinek

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
parent 4f150726
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-03-11 Martin Liska <mliska@suse.cz> 2019-03-11 Martin Liska <mliska@suse.cz>
* decl.c (match_record_decl): Wrap an option name * decl.c (match_record_decl): Wrap an option name
......
...@@ -558,6 +558,9 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree outer) ...@@ -558,6 +558,9 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree outer)
build3_loc (input_location, COND_EXPR, build3_loc (input_location, COND_EXPR,
void_type_node, cond, then_b, void_type_node, cond, then_b,
else_b)); else_b));
/* Avoid -W*uninitialized warnings. */
if (DECL_P (decl))
TREE_NO_WARNING (decl) = 1;
} }
else else
gfc_add_expr_to_block (&block, then_b); gfc_add_expr_to_block (&block, then_b);
...@@ -664,6 +667,9 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src) ...@@ -664,6 +667,9 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src)
gfc_add_expr_to_block (&block, gfc_add_expr_to_block (&block,
build3_loc (input_location, COND_EXPR, build3_loc (input_location, COND_EXPR,
void_type_node, cond, then_b, else_b)); 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); return gfc_finish_block (&block);
} }
......
2019-03-11 Jakub Jelinek <jakub@redhat.com> 2019-03-11 Jakub Jelinek <jakub@redhat.com>
PR fortran/89651
* gfortran.dg/gomp/pr89651.f90: New test.
PR middle-end/89655 PR middle-end/89655
PR bootstrap/89656 PR bootstrap/89656
* gcc.c-torture/compile/pr89655.c: New test. * gcc.c-torture/compile/pr89655.c: New test.
......
! 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment