aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-01-30 15:01:36 -0500
committerJason Merrill <jason@gcc.gnu.org>2018-01-30 15:01:36 -0500
commitb1c7b29a3cae7dcf652cc3e3f971ec010153d814 (patch)
treec9a38c49787858118e4d7cf09bd1e94269d7829f /gcc
parent8d79f003d366e17bb17a4b0a7aab01fea51ffa71 (diff)
downloadgcc-b1c7b29a3cae7dcf652cc3e3f971ec010153d814.zip
gcc-b1c7b29a3cae7dcf652cc3e3f971ec010153d814.tar.gz
gcc-b1c7b29a3cae7dcf652cc3e3f971ec010153d814.tar.bz2
PR c++/84091 - ICE with local class in lambda in template.
* decl2.c (determine_visibility): Look for outer containing template instantiation. From-SVN: r257202
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl2.c10
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-local1.C13
3 files changed, 27 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 536a3e3..ceb1e85 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2018-01-30 Jason Merrill <jason@redhat.com>
+ PR c++/84091 - ICE with local class in lambda in template.
+ * decl2.c (determine_visibility): Look for outer containing template
+ instantiation.
+
PR c++/84098 - ICE with lambda in template NSDMI.
* pt.c (instantiate_class_template_1): Ignore more lambdas.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index ef7e6de..2da6f90 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2418,6 +2418,16 @@ determine_visibility (tree decl)
by that. */
if (DECL_LANG_SPECIFIC (fn) && DECL_USE_TEMPLATE (fn))
template_decl = fn;
+ else if (template_decl)
+ {
+ /* FN must be a regenerated lambda function, since they don't
+ have template arguments. Find a containing non-lambda
+ template instantiation. */
+ tree ctx = fn;
+ while (ctx && !get_template_info (ctx))
+ ctx = get_containing_scope (ctx);
+ template_decl = ctx;
+ }
}
else if (VAR_P (decl) && DECL_TINFO_P (decl)
&& flag_visibility_ms_compat)
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-local1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-local1.C
new file mode 100644
index 0000000..a2dd350
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-local1.C
@@ -0,0 +1,13 @@
+// PR c++/84091
+// { dg-do compile { target c++11 } }
+
+template < typename > void f ()
+{
+ [] { struct A {} a; } ();
+}
+
+int main ()
+{
+ f < int > ();
+ return 0;
+}