re PR c++/77914 (Wrong lambda definition accepted)
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. From-SVN: r244907
This commit is contained in:
parent
0d098f4ba1
commit
0e3438689a
@ -1,3 +1,9 @@
|
||||
2017-01-25 Jakub Jelinek <jakub@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.
|
||||
|
||||
2017-01-25 Maxim Ostapenko <m.ostapenko@samsung.com>
|
||||
|
||||
PR lto/79061
|
||||
|
@ -10174,6 +10174,9 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
|
||||
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);
|
||||
|
||||
|
@ -1,3 +1,15 @@
|
||||
2017-01-25 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/77914
|
||||
* 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.
|
||||
|
||||
2017-01-25 Bin Cheng <bin.cheng@arm.com>
|
||||
|
||||
* gcc.dg/vect/vect-24.c: Remove xfail on ARM targets.
|
||||
|
9
gcc/testsuite/g++.dg/cpp1y/lambda-generic-77914.C
Normal file
9
gcc/testsuite/g++.dg/cpp1y/lambda-generic-77914.C
Normal file
@ -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> ();
|
||||
}
|
@ -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 ();
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Mixed explicit and implicit generic lambda test.
|
||||
// { dg-do compile { target c++14 } }
|
||||
// { dg-options "" }
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -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; } );
|
||||
|
@ -1,4 +1,5 @@
|
||||
// PR c++/59636
|
||||
// { dg-do compile { target c++14 } }
|
||||
// { dg-options "" }
|
||||
|
||||
auto f = []() { return []<>() {}; }; // { dg-error "expected identifier" }
|
||||
|
@ -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" }
|
||||
|
Loading…
Reference in New Issue
Block a user