+2017-11-21 Jakub Jelinek <jakub@redhat.com>
+
+ P0428R2 - familiar template syntax for generic lambdas
+ * parser.c (cp_parser_lambda_declarator_opt): Don't pedwarn
+ for cxx2a and above, reword pedwarn for C++14/C++17.
+
2017-11-20 David Malcolm <dmalcolm@redhat.com>
PR c/81404
pedwarn (parser->lexer->next_token->location, 0,
"lambda templates are only available with "
"-std=c++14 or -std=gnu++14");
- else
+ else if (cxx_dialect < cxx2a)
pedwarn (parser->lexer->next_token->location, OPT_Wpedantic,
- "ISO C++ does not support lambda templates");
+ "lambda templates are only available with "
+ "-std=c++2a or -std=gnu++2a");
cp_lexer_consume_token (parser->lexer);
2017-11-21 Jakub Jelinek <jakub@redhat.com>
+ P0428R2 - familiar template syntax for generic lambdas
+ * g++.dg/cpp1y/lambda-generic-x.C: Adjust warnings and limit
+ to c++17_down target.
+ * g++.dg/cpp1y/lambda-generic-dep.C: Likewise.
+ * g++.dg/cpp1y/lambda-generic-77914.C: Adjust error and limit
+ to c++17_down target.
+ * g++.dg/cpp2a/lambda-generic1.C: New test.
+ * g++.dg/cpp2a/lambda-generic2.C: New test.
+ * g++.dg/cpp2a/lambda-generic3.C: New test.
+ * g++.dg/cpp2a/lambda-generic4.C: New test.
+ * g++.dg/cpp2a/lambda-generic5.C: New test.
+
PR c++/83059
* c-c++-common/pr83059.c: New test.
int
main ()
{
- auto l = [] <typename T> () {}; // { dg-error "does not support lambda templates" }
+ auto l = [] <typename T> () {}; // { dg-error "lambda templates are only available with" "" { target c++17_down } }
l.operator () <void> ();
}
int main()
{
- auto f = [] <typename T> (T const& s) mutable { // { dg-warning "does not support lambda templates" }
+ auto f = [] <typename T> (T const& s) mutable { // { dg-warning "lambda templates are only available with" "" { target c++17_down } }
typename T::N x;
return x.test ();
};
int main()
{
- auto glambda = [] <typename A, typename B> (A a, B&& b) { return a < b; }; // { dg-warning "does not support lambda templates" }
+ auto glambda = [] <typename A, typename B> (A a, B&& b) { return a < b; }; // { dg-warning "lambda templates are only available with" "" { target c++17_down } }
bool b = glambda(3, 3.14); // OK
- auto vglambda = [] <typename P> (P printer) { // { dg-warning "does not support lambda templates" }
+ auto vglambda = [] <typename P> (P printer) { // { dg-warning "lambda templates are only available with" "" { target c++17_down } }
return [=] <typename... T> (T&& ... ts) { // OK: ts is a function parameter pack
- printer(std::forward<decltype(ts)>(ts)...); // { dg-warning "does not support lambda templates" "" { target *-*-* } .-1 }
+ printer(std::forward<decltype(ts)>(ts)...); // { dg-warning "lambda templates are only available with" "" { target c++17_down } .-1 }
return [=]() {
printer(ts ...);
};
};
};
- auto p = vglambda( [] <typename A, // { dg-warning "does not support lambda templates" }
+ auto p = vglambda( [] <typename A, // { dg-warning "lambda templates are only available with" "" { target c++17_down } }
typename B,
typename C> (A v1, B v2, C v3)
{ std::cout << v1 << v2 << v3; } );
--- /dev/null
+// P0428R2
+// { dg-do compile { target c++14 } }
+
+int i = [](int i, auto a) { return i; }(3, 4);
+int j = []<class T>(T t, int i) { return i; }(3, 4); // { dg-error "lambda templates are only available with" "" { target c++17_down } }
+int k[2] = { 5, 6 };
+int l = []<typename T>(T *p) { return *p; }(k); // { dg-error "lambda templates are only available with" "" { target c++17_down } }
+int m = []<typename T, int N>(T (&a)[N]) { return a[N - 1]; }(k); // { dg-error "lambda templates are only available with" "" { target c++17_down } }
+int n = []<typename T>(T a, auto b) { return a + b; }(7, 8); // { dg-error "lambda templates are only available with" "" { target c++17_down } }
--- /dev/null
+// P0428R2
+// { dg-do compile }
+
+int j = []<class T>(T t, int i) { return i; }(3, 4);
+// { dg-error "lambda templates are only available with" "" { target c++17_down } .-1 }
+// { dg-error "lambda expressions only available with" "" { target c++98_only } .-2 }
+// { dg-error "invalid use of 'auto'" "" { target c++98_only } .-3 }
--- /dev/null
+// P0428R2
+// { dg-do compile }
+// { dg-options "-Wpedantic" }
+
+int j = []<class T>(T t, int i) { return i; }(3, 4);
+// { dg-warning "lambda templates are only available with" "" { target c++17_down } .-1 }
+// { dg-warning "lambda expressions only available with" "" { target c++98_only } .-2 }
+// { dg-error "invalid use of 'auto'" "" { target c++98_only } .-3 }
--- /dev/null
+// P0428R2
+// { dg-do compile }
+// { dg-options "-Wno-pedantic" }
+
+int j = []<class T>(T t, int i) { return i; }(3, 4);
+// { dg-warning "lambda templates are only available with" "" { target c++11_down } .-1 }
+// { dg-warning "lambda expressions only available with" "" { target c++98_only } .-2 }
+// { dg-error "invalid use of 'auto'" "" { target c++98_only } .-3 }
--- /dev/null
+// P0428R2
+// { dg-do compile }
+// { dg-options "-std=c++2a" }
+
+int j = []<class T>(T t, int i) { return i; }(3, 4);
+// { dg-bogus "lambda templates are only available with" "" { target c++2a } .-1 }