aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-01-27 16:40:45 -0500
committerJason Merrill <jason@gcc.gnu.org>2015-01-27 16:40:45 -0500
commit2cc7f90b6e4906efd9cd909d7182630dbf9e819b (patch)
tree5a56e487c0acb4630d95d68c8581667225c6c537
parent53c04ec92a37b35a7f37e00bd5a4b611cf470e3c (diff)
downloadgcc-2cc7f90b6e4906efd9cd909d7182630dbf9e819b.zip
gcc-2cc7f90b6e4906efd9cd909d7182630dbf9e819b.tar.gz
gcc-2cc7f90b6e4906efd9cd909d7182630dbf9e819b.tar.bz2
re PR c++/58597 (ICE with lambda in default argument of template function)
PR c++/58597 * lambda.c (maybe_add_lambda_conv_op): Check cfun rather than current_function_decl. From-SVN: r220192
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/lambda.c2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C9
3 files changed, 14 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b914f4b..2ae15d0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 6c9e224..b160c8c 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -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
index 0000000..fe8767a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C
@@ -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;