re PR c++/84488 (Incorrect "set but not used" warning for static_cast<Enum>(double))
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Feb 2018 17:00:23 +0000 (18:00 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 20 Feb 2018 17:00:23 +0000 (18:00 +0100)
PR c++/84488
* g++.dg/warn/Wunused-var-30.C: New test.

From-SVN: r257850

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wunused-var-30.C [new file with mode: 0644]

index 8eb50db74788ab2538429a641bb6d7425bb11e69..d6cedecf44ace889b3e4bdfee0190f2c5c366173 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84488
+       * g++.dg/warn/Wunused-var-30.C: New test.
+
 2018-02-20  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR tree-optimization/84419
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-30.C b/gcc/testsuite/g++.dg/warn/Wunused-var-30.C
new file mode 100644 (file)
index 0000000..e95e120
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/84488
+// { dg-do compile }
+// { dg-options "-Wunused-but-set-variable" }
+
+int
+foo ()
+{
+  enum E { A, B, C, D };
+  double r = 1.0;              // { dg-bogus "set but not used" }
+  return static_cast<E>(r);
+}