Hi! As mentioned in the PR, lambda templates are something that in the end didn't end up in C++14 nor C++17 (only generic lambdas with auto arguments made it). This patch pedwarns on them if -pedantic{,-errors}.
Bootstrapped/regtested on x86_64-linux and i686-linux, acked by Jason in the PR, committed to trunk. 2017-01-25 Jakub Jelinek <ja...@redhat.com> PR c++/77914 * parser.c (cp_parser_lambda_declarator_opt): Pedwarn with OPT_Wpedantic on lambda templates for -std=c++14 and higher. * g++.dg/cpp1y/lambda-generic-77914.C: New test. * g++.dg/cpp1y/lambda-generic-dep.C: Add -pedantic to dg-options, expect a warning. * g++.dg/cpp1y/lambda-generic-x.C: Add -Wpedantic to dg-options, expect warnings. * g++.dg/cpp1y/lambda-generic-mixed.C: Add empty dg-options. * g++.dg/cpp1y/pr59636.C: Likewise. * g++.dg/cpp1y/pr60190.C: Likewise. --- gcc/cp/parser.c.jj 2017-01-25 19:23:46.240197073 +0100 +++ gcc/cp/parser.c 2017-01-25 19:26:17.397274647 +0100 @@ -10174,6 +10174,9 @@ cp_parser_lambda_declarator_opt (cp_pars pedwarn (parser->lexer->next_token->location, 0, "lambda templates are only available with " "-std=c++14 or -std=gnu++14"); + else + pedwarn (parser->lexer->next_token->location, OPT_Wpedantic, + "ISO C++ does not support lambda templates"); cp_lexer_consume_token (parser->lexer); --- gcc/testsuite/g++.dg/cpp1y/lambda-generic-77914.C.jj 2017-01-25 19:26:17.398274634 +0100 +++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-77914.C 2017-01-25 21:41:40.964310527 +0100 @@ -0,0 +1,9 @@ +// PR c++/77914 +// { dg-do compile { target c++14 } } + +int +main () +{ + auto l = [] <typename T> () {}; // { dg-error "does not support lambda templates" } + l.operator () <void> (); +} --- gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C.jj 2014-09-25 15:02:34.340817869 +0200 +++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C 2017-01-25 19:26:17.400274609 +0100 @@ -1,5 +1,6 @@ // Generic lambda type dependence test part from N3690 5.1.2.12 // { dg-do compile { target c++14 } } +// { dg-options "-pedantic" } void f(int, const int (&)[2] = {}) { } // #1 void f(const int&, const int (&)[1]) { } // #2 @@ -26,7 +27,7 @@ struct S { int main() { - auto f = [] <typename T> (T const& s) mutable { + auto f = [] <typename T> (T const& s) mutable { // { dg-warning "does not support lambda templates" } typename T::N x; return x.test (); }; --- gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C.jj 2014-09-25 15:02:34.352817644 +0200 +++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C 2017-01-25 19:26:17.400274609 +0100 @@ -1,21 +1,22 @@ // Explicit generic lambda test from N3690 5.1.2.5 // { dg-do compile { target c++14 } } +// { dg-options "-Wpedantic" } #include <iostream> int main() { - auto glambda = [] <typename A, typename B> (A a, B&& b) { return a < b; }; + auto glambda = [] <typename A, typename B> (A a, B&& b) { return a < b; }; // { dg-warning "does not support lambda templates" } bool b = glambda(3, 3.14); // OK - auto vglambda = [] <typename P> (P printer) { + auto vglambda = [] <typename P> (P printer) { // { dg-warning "does not support lambda templates" } return [=] <typename... T> (T&& ... ts) { // OK: ts is a function parameter pack - printer(std::forward<decltype(ts)>(ts)...); + printer(std::forward<decltype(ts)>(ts)...); // { dg-warning "does not support lambda templates" "" { target *-*-* } .-1 } return [=]() { printer(ts ...); }; }; }; - auto p = vglambda( [] <typename A, + auto p = vglambda( [] <typename A, // { dg-warning "does not support lambda templates" } typename B, typename C> (A v1, B v2, C v3) { std::cout << v1 << v2 << v3; } ); --- gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C.jj 2014-09-25 15:02:34.348817719 +0200 +++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C 2017-01-25 19:26:17.401274596 +0100 @@ -1,5 +1,6 @@ // Mixed explicit and implicit generic lambda test. // { dg-do compile { target c++14 } } +// { dg-options "" } int main() { --- gcc/testsuite/g++.dg/cpp1y/pr59636.C.jj 2014-09-25 15:02:34.000000000 +0200 +++ gcc/testsuite/g++.dg/cpp1y/pr59636.C 2017-01-25 21:42:29.946690283 +0100 @@ -1,4 +1,5 @@ // PR c++/59636 // { dg-do compile { target c++14 } } +// { dg-options "" } auto f = []() { return []<>() {}; }; // { dg-error "expected identifier" } --- gcc/testsuite/g++.dg/cpp1y/pr60190.C.jj 2014-09-25 15:02:34.000000000 +0200 +++ gcc/testsuite/g++.dg/cpp1y/pr60190.C 2017-01-25 21:42:54.058384967 +0100 @@ -1,4 +1,5 @@ // PR c++/60190 // { dg-do compile { target c++14 } } +// { dg-options "" } auto f = []<int>() -> int() {}; // { dg-error "returning a function|expected" } Jakub