Commit 22a32ea0 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/89796 (Incorrect warning generated with OpenMP atomic capture)

	PR c++/89796
	* semantics.c (finish_omp_atomic): Add warning_sentinel for
	-Wunused-value around finish_expr_stmt call.

	* g++.dg/gomp/pr89796.C: New test.
	* gcc.dg/gomp/pr89796.c: New test.

From-SVN: r269933
parent 7a03cad7
2019-03-26 Jakub Jelinek <jakub@redhat.com>
PR c++/89796
* semantics.c (finish_omp_atomic): Add warning_sentinel for
-Wunused-value around finish_expr_stmt call.
2019-03-25 Paolo Carlini <paolo.carlini@oracle.com> 2019-03-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84661 PR c++/84661
......
...@@ -8997,6 +8997,11 @@ finish_omp_atomic (location_t loc, enum tree_code code, enum tree_code opcode, ...@@ -8997,6 +8997,11 @@ finish_omp_atomic (location_t loc, enum tree_code code, enum tree_code opcode,
OMP_ATOMIC_MEMORY_ORDER (stmt) = mo; OMP_ATOMIC_MEMORY_ORDER (stmt) = mo;
SET_EXPR_LOCATION (stmt, loc); SET_EXPR_LOCATION (stmt, loc);
} }
/* Avoid -Wunused-value warnings here, the whole construct has side-effects
and even if it might be wrapped from fold-const.c or c-omp.c wrapped
in some tree that appears to be unused, the value is not unused. */
warning_sentinel w (warn_unused_value);
finish_expr_stmt (stmt); finish_expr_stmt (stmt);
} }
......
2019-03-26 Jakub Jelinek <jakub@redhat.com>
PR c++/89796
* g++.dg/gomp/pr89796.C: New test.
* gcc.dg/gomp/pr89796.c: New test.
2019-03-25 David Malcolm <dmalcolm@redhat.com> 2019-03-25 David Malcolm <dmalcolm@redhat.com>
PR rtl-optimization/88347 PR rtl-optimization/88347
......
// PR c++/89796
// { dg-do compile }
// { dg-additional-options "-Wunused-value" }
int
f1 (int &c)
{
int r;
#pragma omp atomic capture // { dg-bogus "value computed is not used" }
{ r = c; c++; }
return r;
}
template <int N>
int
f2 (int &c)
{
int r;
#pragma omp atomic capture // { dg-bogus "value computed is not used" }
{ r = c; c++; }
return r;
}
int
f3 (int &c)
{
return f2 <0> (c);
}
int
f4 (int *p)
{
int r;
#pragma omp atomic capture // { dg-bogus "value computed is not used" }
{ r = *p; (*p)++; }
return r;
}
template <int N>
int
f5 (int *p)
{
int r;
#pragma omp atomic capture // { dg-bogus "value computed is not used" }
{ r = *p; (*p)++; }
return r;
}
int
f6 (int *p)
{
return f5 <0> (p);
}
/* PR c++/89796 */
/* { dg-do compile } */
/* { dg-additional-options "-Wunused-value" } */
int
f1 (int *p)
{
int r;
#pragma omp atomic capture /* { dg-bogus "value computed is not used" } */
{ r = *p; (*p)++; }
return r;
}
int
f2 (int *p)
{
int s
= ({ int r;
#pragma omp atomic capture /* { dg-bogus "value computed is not used" } */
{ r = *p; (*p)++; }
r; });
return s;
}
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