aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-01-25 21:51:10 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-01-25 21:51:10 +0100
commit0e3438689a6ffc4851ba8162306e5a1709b3b905 (patch)
treef2650b34e22820c5d245ad9ef44382fa36501c9e /gcc
parent0d098f4ba1e41740223fe0b5f79462c42703c30b (diff)
downloadgcc-0e3438689a6ffc4851ba8162306e5a1709b3b905.zip
gcc-0e3438689a6ffc4851ba8162306e5a1709b3b905.tar.gz
gcc-0e3438689a6ffc4851ba8162306e5a1709b3b905.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c3
-rw-r--r--gcc/testsuite/ChangeLog12
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-77914.C9
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C3
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C1
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C9
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/pr59636.C1
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/pr60190.C1
9 files changed, 40 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 47eaa55..dc098b2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4ab0b69..372a01e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9deb57d..e82fb4c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-77914.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-77914.C
new file mode 100644
index 0000000..d069c33
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-77914.C
@@ -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> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C
index dbf8b70..c66d393 100644
--- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-dep.C
@@ -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 ();
};
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C
index 59b5cca..aa96824 100644
--- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-mixed.C
@@ -1,5 +1,6 @@
// Mixed explicit and implicit generic lambda test.
// { dg-do compile { target c++14 } }
+// { dg-options "" }
int main()
{
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C
index 5334091..b37a614 100644
--- a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-x.C
@@ -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; } );
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59636.C b/gcc/testsuite/g++.dg/cpp1y/pr59636.C
index 847cecd..271491e 100644
--- a/gcc/testsuite/g++.dg/cpp1y/pr59636.C
+++ b/gcc/testsuite/g++.dg/cpp1y/pr59636.C
@@ -1,4 +1,5 @@
// PR c++/59636
// { dg-do compile { target c++14 } }
+// { dg-options "" }
auto f = []() { return []<>() {}; }; // { dg-error "expected identifier" }
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60190.C b/gcc/testsuite/g++.dg/cpp1y/pr60190.C
index 9e439ce..f2d1bbf 100644
--- a/gcc/testsuite/g++.dg/cpp1y/pr60190.C
+++ b/gcc/testsuite/g++.dg/cpp1y/pr60190.C
@@ -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" }