Patchwork [committed] Fix bogus warning on OpenMP collapsed loops (PR middle-end/58257)

login
register
mail settings
Submitter Jakub Jelinek
Date Aug. 28, 2013, 10:13 a.m.
Message ID <20130828101347.GR21876@tucnak.zalov.cz>
Download mbox | patch
Permalink /patch/270427/
State New
Headers show

Comments

Jakub Jelinek - Aug. 28, 2013, 10:13 a.m.
Hi!

The .count.NN vars have TREE_NO_WARNING set on them, because
they may be uninitialized if the loop body isn't executed at all
(zero trip count), but copy_var_decl wasn't propagating the flag over to
the parallel body ompfn function vars.

Fixed thusly, tested on x86_64-linux, committed to trunk/4.8.

2013-08-28  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/58257
	* omp-low.c (copy_var_decl): Copy over TREE_NO_WARNING flag.

	* c-c++-common/gomp/pr58257.c: New test.


	Jakub

Patch

--- gcc/omp-low.c.jj	2013-08-28 11:27:54.000000000 +0200
+++ gcc/omp-low.c	2013-08-28 11:39:07.578948737 +0200
@@ -850,6 +850,7 @@  copy_var_decl (tree var, tree name, tree
   DECL_ARTIFICIAL (copy) = DECL_ARTIFICIAL (var);
   DECL_IGNORED_P (copy) = DECL_IGNORED_P (var);
   DECL_CONTEXT (copy) = DECL_CONTEXT (var);
+  TREE_NO_WARNING (copy) = TREE_NO_WARNING (var);
   TREE_USED (copy) = 1;
   DECL_SEEN_IN_BIND_EXPR_P (copy) = 1;
 
--- gcc/testsuite/c-c++-common/gomp/pr58257.c.jj	2013-08-28 11:56:17.991343584 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr58257.c	2013-08-28 11:58:24.616648066 +0200
@@ -0,0 +1,15 @@ 
+/* PR middle-end/58257 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp -Wall" } */
+
+int
+foo (int n)
+{
+  int a[10][10];
+  int x, y;
+#pragma omp parallel for collapse(2)	/* { dg-bogus "may be used uninitialized in this function" } */
+  for (x = 0; x < n; x++)		/* { dg-bogus "may be used uninitialized in this function" } */
+    for (y = 0; y < n; y++)
+      a[x][y] = x + y * y;
+  return a[0][0];
+}