re PR c++/58597 (ICE with lambda in default argument of template function)
authorJason Merrill <jason@redhat.com>
Tue, 27 Jan 2015 21:40:45 +0000 (16:40 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 27 Jan 2015 21:40:45 +0000 (16:40 -0500)
PR c++/58597
* lambda.c (maybe_add_lambda_conv_op): Check cfun rather than
current_function_decl.

From-SVN: r220192

gcc/cp/ChangeLog
gcc/cp/lambda.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C [new file with mode: 0644]

index b914f4b133426334a036a15ad7545200ee402310..2ae15d027d8329e74b9989e494f203c76a7ff73b 100644 (file)
@@ -1,5 +1,9 @@
 2015-01-27  Jason Merrill  <jason@redhat.com>
 
+       PR c++/58597
+       * lambda.c (maybe_add_lambda_conv_op): Check cfun rather than
+       current_function_decl.
+
        PR c++/63889
        * pt.c (finish_template_variable): Move from semantics.c.
        Handle multiple template arg levels.  Handle coercion here.
index 6c9e224c0f49ef6383fc60a9a4b56a7d949d5403..b160c8cb7ae16578d0090b7f804017f7c8ad3aa0 100644 (file)
@@ -854,7 +854,7 @@ prepare_op_call (tree fn, int nargs)
 void
 maybe_add_lambda_conv_op (tree type)
 {
-  bool nested = (current_function_decl != NULL_TREE);
+  bool nested = (cfun != NULL);
   bool nested_def = decl_function_context (TYPE_MAIN_DECL (type));
   tree callop = lambda_function (type);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C
new file mode 100644 (file)
index 0000000..fe8767a
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/58597
+// { dg-do compile { target c++11 } }
+
+template<typename> struct A
+{
+  template<typename T> A(T, int = []{ return 0; }()) {}
+};
+
+A<int> a = 0;