From 036c9eb5d91e589ec10bb753ba2066963f9bcccc Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 29 Mar 2018 13:18:04 +0200 Subject: [PATCH] re PR c++/85108 (Incorrect warning for constexpr lambda with -Wunused-but-set-variable) PR c++/85108 * g++.dg/warn/Wunused-var-31.C: New test. From-SVN: r258952 --- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/warn/Wunused-var-31.C | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-var-31.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 89712e3f5b1..788dbaa48c2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-03-29 Jakub Jelinek + 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 index 00000000000..74c016ba230 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-var-31.C @@ -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; +} -- 2.30.2