C: Add test for incorrect warning for assignment of certain volatile expressions...
authorMartin Uecker <muecker@gwdg.de>
Mon, 4 Jan 2021 21:53:58 +0000 (22:53 +0100)
committerMartin Uecker <muecker@gwdg.de>
Mon, 4 Jan 2021 21:53:58 +0000 (22:53 +0100)
2021-01-04  Martin Uecker  <muecker@gwdg.de>

gcc/testsuite/
PR c/98029
* gcc.dg/pr98029.c: New test.

gcc/testsuite/gcc.dg/pr98029.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/pr98029.c b/gcc/testsuite/gcc.dg/pr98029.c
new file mode 100644 (file)
index 0000000..148f23c
--- /dev/null
@@ -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;
+}