* C++ PATCH for c++/64105 (ICE on generic lambda with -std=c++11)
@ 2014-12-19 0:44 Jason Merrill
2014-12-19 17:54 ` Paolo Carlini
0 siblings, 1 reply; 2+ messages in thread
From: Jason Merrill @ 2014-12-19 0:44 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 153 bytes --]
Since generic lambdas don't seem to work properly in C++11 mode, let's
upgrade the pedwarn to an error.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 64105.patch --]
[-- Type: text/x-patch, Size: 2440 bytes --]
commit 6c7d0ebb35b4918be3200625ef0cbb1816ddd7e9
Author: Jason Merrill <jason@redhat.com>
Date: Thu Dec 18 16:56:33 2014 -0500
PR c++/64105
* parser.c (cp_parser_simple_type_specifier): Make auto parameter
before -std=c++14 an error.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 0e7ba7a..8ff16ed 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14862,23 +14862,26 @@ cp_parser_simple_type_specifier (cp_parser* parser,
maybe_warn_cpp0x (CPP0X_AUTO);
if (parser->auto_is_implicit_function_template_parm_p)
{
- type = synthesize_implicit_template_parm (parser);
+ if (cxx_dialect >= cxx14)
+ type = synthesize_implicit_template_parm (parser);
+ else
+ type = error_mark_node;
if (current_class_type && LAMBDA_TYPE_P (current_class_type))
{
if (cxx_dialect < cxx14)
- pedwarn (location_of (type), 0,
+ error_at (token->location,
"use of %<auto%> in lambda parameter declaration "
"only available with "
"-std=c++14 or -std=gnu++14");
}
else if (cxx_dialect < cxx14)
- pedwarn (location_of (type), 0,
+ error_at (token->location,
"use of %<auto%> in parameter declaration "
"only available with "
"-std=c++14 or -std=gnu++14");
else
- pedwarn (location_of (type), OPT_Wpedantic,
+ pedwarn (token->location, OPT_Wpedantic,
"ISO C++ forbids use of %<auto%> in parameter "
"declaration");
}
@@ -14971,6 +14974,9 @@ cp_parser_simple_type_specifier (cp_parser* parser,
/* Consume the token. */
cp_lexer_consume_token (parser->lexer);
+ if (type == error_mark_node)
+ return error_mark_node;
+
/* There is no valid C++ program where a non-template type is
followed by a "<". That usually indicates that the user thought
that the type was a template. */
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic2.C
new file mode 100644
index 0000000..2808aa6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic2.C
@@ -0,0 +1,22 @@
+// PR c++/64105
+// This test was ICEing on pre-C++14 mode.
+
+#include <functional>
+
+using F = std::function<void(void)>;
+
+struct X
+{
+ template <typename T>
+ static void f(T t)
+ {
+ g(t);
+ }
+
+ static void g(F) {}
+};
+
+int main()
+{
+ X::f([](auto... xs){}); // { dg-error "" "" { target { ! cxx14 } } }
+};
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++ PATCH for c++/64105 (ICE on generic lambda with -std=c++11)
2014-12-19 0:44 C++ PATCH for c++/64105 (ICE on generic lambda with -std=c++11) Jason Merrill
@ 2014-12-19 17:54 ` Paolo Carlini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Carlini @ 2014-12-19 17:54 UTC (permalink / raw)
To: Jason Merrill, gcc-patches List
Hi,
On 12/19/2014 12:52 AM, Jason Merrill wrote:
> + X::f([](auto... xs){}); // { dg-error "" "" { target { ! cxx14 } } }
I think you want to change the ! cxx14 bits, apparently don't work.
Thanks,
Paolo.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-19 17:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-19 0:44 C++ PATCH for c++/64105 (ICE on generic lambda with -std=c++11) Jason Merrill
2014-12-19 17:54 ` Paolo Carlini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).