From a000eb5918e09d28838ef572f4eea924d32db09b Mon Sep 17 00:00:00 2001 From: Martin Uecker Date: Mon, 4 Jan 2021 22:53:58 +0100 Subject: [PATCH] C: Add test for incorrect warning for assignment of certain volatile expressions fixed by commit 58a45ce [PR98029] 2021-01-04 Martin Uecker gcc/testsuite/ PR c/98029 * gcc.dg/pr98029.c: New test. --- gcc/testsuite/gcc.dg/pr98029.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr98029.c diff --git a/gcc/testsuite/gcc.dg/pr98029.c b/gcc/testsuite/gcc.dg/pr98029.c new file mode 100644 index 00000000000..148f23ce5e0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98029.c @@ -0,0 +1,21 @@ +/* pr98029 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +double f2 (void) +{ + volatile double d; + int i; + + for (d = 2.0, i = 0; i < 5; i++, d *= d) /* { dg-bogus "right-hand operand of comma expression has no effect" } */ + ; + + return d; +} + +int g(void) +{ + volatile int x; + (x = 1, (void)1); /* { dg-bogus "right-hand operand of comma expression has no effect" } */ + return x; +} -- 2.30.2