re PR c/51360 (spurious unused-but-set-variable warning for var used in OpenMP pragma)
authorJakub Jelinek <jakub@redhat.com>
Thu, 15 Dec 2011 17:29:25 +0000 (18:29 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 15 Dec 2011 17:29:25 +0000 (18:29 +0100)
PR c/51360
* c-parser.c (c_parser_omp_clause_num_threads,
c_parser_omp_clause_schedule): Call mark_exp_read.

* semantics.c (finish_omp_clauses): For OMP_CLAUSE_NUM_THREADS_EXPR
and OMP_CLAUSE_SCHEDULE_CHUNK_EXPR call mark_rvalue_use.

* c-c++-common/gomp/pr51360.c: New test.
* g++.dg/gomp/pr51360.C: New test.

From-SVN: r182381

gcc/ChangeLog
gcc/c-parser.c
gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr51360.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/pr51360.C [new file with mode: 0644]

index 9f1c952de25e661923be315a35d37be324aefab8..59f205a03ccfd9ea3ab580e24bf53eb7422401ad 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/51360
+       * c-parser.c (c_parser_omp_clause_num_threads,
+       c_parser_omp_clause_schedule): Call mark_exp_read.
+
 2011-12-15  Romain Geissler  <romain.geissler@gmail.com>
 
        * builtins.def (BUILT_IN_STPNCPY_CHK): New definition.
index e227137bfb09f28d0a0406ee18e613eb5186bf3f..0a268a691f5f7f28a33b8decca8f26dbffbd27c2 100644 (file)
@@ -9011,6 +9011,7 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list)
     {
       location_t expr_loc = c_parser_peek_token (parser)->location;
       tree c, t = c_parser_expression (parser).value;
+      mark_exp_read (t);
       t = c_fully_fold (t, false, NULL);
 
       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
@@ -9218,6 +9219,7 @@ c_parser_omp_clause_schedule (c_parser *parser, tree list)
 
       here = c_parser_peek_token (parser)->location;
       t = c_parser_expr_no_commas (parser, NULL).value;
+      mark_exp_read (t);
       t = c_fully_fold (t, false, NULL);
 
       if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_RUNTIME)
index 3e56008703c0c2fb19f21890beca43345d732b99..3975b6bfce4e87e748664f71b05254f30998dbde 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/51360
+       * semantics.c (finish_omp_clauses): For OMP_CLAUSE_NUM_THREADS_EXPR
+       and OMP_CLAUSE_SCHEDULE_CHUNK_EXPR call mark_rvalue_use.
+
 2011-12-15  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/51473
index 2f2a26a0d52acf24295ff3cf8a21c66735aa102d..ab9227fa9250f07cbcd6dbd81c99f5e20cf94c17 100644 (file)
@@ -4087,6 +4087,8 @@ finish_omp_clauses (tree clauses)
              error ("num_threads expression must be integral");
              remove = true;
            }
+         else
+           OMP_CLAUSE_NUM_THREADS_EXPR (c) = mark_rvalue_use (t);
          break;
 
        case OMP_CLAUSE_SCHEDULE:
@@ -4101,6 +4103,8 @@ finish_omp_clauses (tree clauses)
              error ("schedule chunk size expression must be integral");
              remove = true;
            }
+         else
+           OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = mark_rvalue_use (t);
          break;
 
        case OMP_CLAUSE_NOWAIT:
index 0691c8cadcf082ba0534a77016f60f2241410877..67d91ba8aab76b4e494632b4e5768786995cd6ea 100644 (file)
@@ -1,5 +1,9 @@
 2011-12-15  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/51360
+       * c-c++-common/gomp/pr51360.c: New test.
+       * g++.dg/gomp/pr51360.C: New test.
+
        PR middle-end/49806
        * gcc.dg/tree-ssa-vrp47.c: Add -fdump-tree-dom2 to dg-options.
        Check for x_? & y in dom2 dump and xfail the check in dom1 dump.
diff --git a/gcc/testsuite/c-c++-common/gomp/pr51360.c b/gcc/testsuite/c-c++-common/gomp/pr51360.c
new file mode 100644 (file)
index 0000000..c32242e
--- /dev/null
@@ -0,0 +1,27 @@
+/* PR c/51360 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused -W -fopenmp" } */
+
+void
+foo (int a, int b, int c, int d)
+{
+  int m, n, o, p, i;
+  m = 6;
+  n = 1;
+  o = 5;
+  p = 1;
+  a = 6;
+  b = 1;
+  c = 5;
+  d = 1;
+  #pragma omp parallel for num_threads (m) if (n) schedule (static, o)
+  for (i = 0; i < 10; i++)
+    ;
+  #pragma omp parallel for num_threads (a) if (b) schedule (static, c)
+  for (i = 0; i < 10; i++)
+    ;
+  #pragma omp task final (p)
+    ;
+  #pragma omp task final (d)
+    ;
+}
diff --git a/gcc/testsuite/g++.dg/gomp/pr51360.C b/gcc/testsuite/g++.dg/gomp/pr51360.C
new file mode 100644 (file)
index 0000000..2e63424
--- /dev/null
@@ -0,0 +1,34 @@
+// PR c/51360
+// { dg-do compile }
+// { dg-options "-Wunused -W -fopenmp" }
+
+template <typename T>
+void
+foo (T a, T b, T c, T d)
+{
+  T m, n, o, p, i;
+  m = 6;
+  n = 1;
+  o = 5;
+  p = 1;
+  a = 6;
+  b = 1;
+  c = 5;
+  d = 1;
+  #pragma omp parallel for num_threads (m) if (n) schedule (static, o)
+  for (i = 0; i < 10; i++)
+    ;
+  #pragma omp parallel for num_threads (a) if (b) schedule (static, c)
+  for (i = 0; i < 10; i++)
+    ;
+  #pragma omp task final (p)
+    ;
+  #pragma omp task final (d)
+    ;
+}
+
+void
+bar ()
+{
+  foo (0, 0, 0, 0);
+}