From d90c0a5980ceedb40f9f7536c32f17856997435a Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 25 Sep 2014 08:47:43 +0200 Subject: [PATCH] =?utf8?q?re=20PR=20c++/63249=20([OpenMP]=20Spurious=20?= =?utf8?q?=C2=BBset=20but=20not=20used=C2=AB=20warnings=20when=20actually?= =?utf8?q?=20used=20in=20OpenMP=20target's=20array=20section's=20lower-bou?= =?utf8?q?nd=20and=20length)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit PR c++/63249 * semantics.c (handle_omp_array_sections_1): Call mark_rvalue_use on low_bound and length. * g++.dg/gomp/pr63249.C: New test. * c-c++-common/gomp/pr63249.c: New test. 2014-09-25 Thomas Schwinge PR c++/63249 * c-parser.c (c_parser_omp_variable_list): Call mark_exp_read on low_bound and length. From-SVN: r215580 --- gcc/c/ChangeLog | 6 ++++ gcc/c/c-parser.c | 10 +++++-- gcc/cp/ChangeLog | 6 ++++ gcc/cp/semantics.c | 4 +++ gcc/testsuite/ChangeLog | 6 ++++ gcc/testsuite/c-c++-common/gomp/pr63249.c | 16 +++++++++++ gcc/testsuite/g++.dg/gomp/pr63249.C | 35 +++++++++++++++++++++++ 7 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/gomp/pr63249.c create mode 100644 gcc/testsuite/g++.dg/gomp/pr63249.C diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 67099c1081a..cb69773247c 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-09-25 Jakub Jelinek + + PR c++/63249 + * c-parser.c (c_parser_omp_variable_list): Call mark_exp_read + on low_bound and length. + 2014-09-24 Marek Polacek PR c/61405 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 71f40b7deaf..0d159fd3bf3 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -9882,7 +9882,10 @@ c_parser_omp_variable_list (c_parser *parser, c_parser_consume_token (parser); if (!c_parser_next_token_is (parser, CPP_COLON)) - low_bound = c_parser_expression (parser).value; + { + low_bound = c_parser_expression (parser).value; + mark_exp_read (low_bound); + } if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) length = integer_one_node; else @@ -9895,7 +9898,10 @@ c_parser_omp_variable_list (c_parser *parser, break; } if (!c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) - length = c_parser_expression (parser).value; + { + length = c_parser_expression (parser).value; + mark_exp_read (length); + } } /* Look for the closing `]'. */ if (!c_parser_require (parser, CPP_CLOSE_SQUARE, diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ee5169f6c7c..2457ccdb734 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-09-25 Jakub Jelinek + + PR c++/63249 + * semantics.c (handle_omp_array_sections_1): Call mark_rvalue_use + on low_bound and length. + 2014-09-24 Aldy Hernandez * class.c, decl.c, optimize.c: Rename all instances of diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2728f5887f1..debd78562fb 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4291,6 +4291,10 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, length); return error_mark_node; } + if (low_bound) + low_bound = mark_rvalue_use (low_bound); + if (length) + length = mark_rvalue_use (length); if (low_bound && TREE_CODE (low_bound) == INTEGER_CST && TYPE_PRECISION (TREE_TYPE (low_bound)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ef8faa3deea..6a201b6b742 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-09-25 Jakub Jelinek + + PR c++/63249 + * g++.dg/gomp/pr63249.C: New test. + * c-c++-common/gomp/pr63249.c: New test. + 2014-09-25 Tobias Burnus * gfortran.dg/coarray/collectives_3.f90: New. diff --git a/gcc/testsuite/c-c++-common/gomp/pr63249.c b/gcc/testsuite/c-c++-common/gomp/pr63249.c new file mode 100644 index 00000000000..878788ad7ef --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr63249.c @@ -0,0 +1,16 @@ +/* PR c++/63249 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -W -fopenmp" } */ + +int +foo (int *v, int A, int B) /* { dg-bogus "set but not used" } */ +{ + int r = 0; + int a = 2; /* { dg-bogus "set but not used" } */ + int b = 4; /* { dg-bogus "set but not used" } */ +#pragma omp target map(to: v[a:b]) + r |= v[3]; +#pragma omp target map(to: v[A:B]) + r |= v[3]; + return r; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr63249.C b/gcc/testsuite/g++.dg/gomp/pr63249.C new file mode 100644 index 00000000000..80f763a4c5f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr63249.C @@ -0,0 +1,35 @@ +// PR c++/63249 +// { dg-do compile } +// { dg-options "-Wall -W -fopenmp" } + +template +int +foo (int *v, int A, int B) // { dg-bogus "set but not used" } +{ + int r = 0; + int a = 2; // { dg-bogus "set but not used" } + int b = 4; // { dg-bogus "set but not used" } +#pragma omp target map(to: v[a:b]) + r |= v[3]; +#pragma omp target map(to: v[A:B]) + r |= v[3]; + return r; +} + +template +int +bar (T *v, T A, T B) // { dg-bogus "set but not used" } +{ + T r = 0, a = 2, b = 4; // { dg-bogus "set but not used" } +#pragma omp target map(to: v[a:b]) + r |= v[3]; +#pragma omp target map(to: v[A:B]) + r |= v[3]; + return r; +} + +int +baz (int *v, int A, int B) +{ + return foo<0> (v, A, B) + bar (v, A, B); +} -- 2.30.2