re PR c++/85108 (Incorrect warning for constexpr lambda with -Wunused-but-set-variable)
authorJakub Jelinek <jakub@redhat.com>
Thu, 29 Mar 2018 11:18:04 +0000 (13:18 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 29 Mar 2018 11:18:04 +0000 (13:18 +0200)
PR c++/85108
* g++.dg/warn/Wunused-var-31.C: New test.

From-SVN: r258952

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

index 89712e3f5b15e6cff4789dcfaca12024fdaea49e..788dbaa48c2d624362e885f251756a402e518c7d 100644 (file)
@@ -1,5 +1,8 @@
 2018-03-29  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/85108
+       * g++.dg/warn/Wunused-var-31.C: New test.
+
        PR c/85094
        * c-c++-common/Wduplicated-branches-14.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-31.C b/gcc/testsuite/g++.dg/warn/Wunused-var-31.C
new file mode 100644 (file)
index 0000000..74c016b
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/85108
+// { dg-do compile { target c++17 } }
+// { dg-options "-Wunused-but-set-variable" }
+
+int
+main ()
+{
+  auto constexpr add = [] (auto a, auto b) { return a + b; };  // { dg-bogus "set but not used" }
+  auto test_lambda = [&] () { return add (2, 2); };
+  return test_lambda () - 4;
+}