diff mbox series

C++ PATCH for c++/85228, ICE with lambda in enumerator

Message ID CADzB+2mJN9E3x7jO809erNnrtr2L9dhWumXDv8JE_CFhaSEKZQ@mail.gmail.com
State New
Headers show
Series C++ PATCH for c++/85228, ICE with lambda in enumerator | expand

Commit Message

Jason Merrill April 5, 2018, 2:47 p.m. UTC
Now that we instantiate lambdas with their enclosing context, the
closure type doesn't have CLASSTYPE_TEMPLATE_INFO.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox series

Patch

commit 7c51c3a6ef0b137fc124ba65f686a607370f2c3a
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 5 10:26:20 2018 -0400

            PR c++/85228 - ICE with lambda in enumerator.
    
            * pt.c (bt_instantiate_type_proc): Don't assume
            CLASSTYPE_TEMPLATE_INFO is non-null.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ed6e62c2364..dc74635876e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 00000000000..8b0c95b37f3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda21.C
@@ -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>;