PR c++/85228 - ICE with lambda in enumerator.
authorJason Merrill <jason@redhat.com>
Thu, 5 Apr 2018 14:48:40 +0000 (10:48 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 5 Apr 2018 14:48:40 +0000 (10:48 -0400)
* pt.c (bt_instantiate_type_proc): Don't assume
CLASSTYPE_TEMPLATE_INFO is non-null.

From-SVN: r259130

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/constexpr-lambda21.C [new file with mode: 0644]

index 37d82bd..cd3e363 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-05  Jason Merrill  <jason@redhat.com>
+
+       PR c++/85228 - ICE with lambda in enumerator in template.
+       * pt.c (bt_instantiate_type_proc): Don't assume
+       CLASSTYPE_TEMPLATE_INFO is non-null.
+
 2018-04-05  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        Implement P0969
index ed6e62c..dc74635 100644 (file)
@@ -22841,6 +22841,7 @@ bt_instantiate_type_proc (binding_entry entry, void *data)
   tree storage = *(tree *) data;
 
   if (MAYBE_CLASS_TYPE_P (entry->type)
+      && CLASSTYPE_TEMPLATE_INFO (entry->type)
       && !uses_template_parms (CLASSTYPE_TI_ARGS (entry->type)))
     do_type_instantiation (TYPE_MAIN_DECL (entry->type), storage, 0);
 }
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda21.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda21.C
new file mode 100644 (file)
index 0000000..8b0c95b
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/85228
+// { dg-additional-options -std=c++17 }
+
+template<int> struct A
+{
+  enum E { e = []{ return 0; }() };
+};
+
+template class A<0>;