aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-02-11 18:05:16 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-02-11 18:05:16 -0500
commit0df9962aa8165580b1c61de81429ab6d3cde0b58 (patch)
tree5e4e8111e6e2ca8fa1e7e09392cf2dc585d544d9 /gcc
parentab97c3cdaf837637722237a4d1c33ddfdf6f7ee7 (diff)
downloadgcc-0df9962aa8165580b1c61de81429ab6d3cde0b58.zip
gcc-0df9962aa8165580b1c61de81429ab6d3cde0b58.tar.gz
gcc-0df9962aa8165580b1c61de81429ab6d3cde0b58.tar.bz2
PR c++/89241 - ICE with __func__ in lambda in template.
When we're instantiating a generic lambda, its enclosing context will have already been instantiated, so we need to look for that as well. * pt.c (enclosing_instantiation_of): Also check instantiated_lambda_fn_p for the template context. From-SVN: r268784
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c3
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-func1.C12
3 files changed, 20 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3d3bb2a..5fe18cc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-02-11 Jason Merrill <jason@redhat.com>
+
+ PR c++/89241 - ICE with __func__ in lambda in template.
+ * pt.c (enclosing_instantiation_of): Also check
+ instantiated_lambda_fn_p for the template context.
+
2019-02-11 Marek Polacek <polacek@redhat.com>
PR c++/89212 - ICE converting nullptr to pointer-to-member-function.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 184cb85..b96e3aa 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13355,7 +13355,8 @@ enclosing_instantiation_of (tree otctx)
tree fn = current_function_decl;
int lambda_count = 0;
- for (; tctx && lambda_fn_in_template_p (tctx);
+ for (; tctx && (lambda_fn_in_template_p (tctx)
+ || instantiated_lambda_fn_p (tctx));
tctx = decl_function_context (tctx))
++lambda_count;
for (; fn; fn = decl_function_context (fn))
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func1.C
new file mode 100644
index 0000000..4a63855
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func1.C
@@ -0,0 +1,12 @@
+// PR c++/89241
+// { dg-do compile { target c++14 } }
+
+template <typename al> void m(al p) {
+ p(1);
+}
+
+template <typename ax> void f() {
+ m([](auto) { __func__; });
+}
+
+template void f<int>();