re PR c++/79264 (ICE verify_type failed)
authorNathan Sidwell <nathan@acm.org>
Tue, 31 Jan 2017 15:10:41 +0000 (15:10 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 31 Jan 2017 15:10:41 +0000 (15:10 +0000)
PR c++/79264
* lambda.c (maybe_generic_this_capture): Deal with
template-id-exprs.
* semantics.c (finish_member_declaration): Assert class is being
defined.

PR c++/79264
* g++.dg/cpp1y/pr61636-1.C: Augment.

From-SVN: r245065

gcc/cp/ChangeLog
gcc/cp/lambda.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr61636-1.C

index 18732c927e3360fce8f5c10ca67d959c13ac8bac..ea1435d05b60bc736a87799176a102be9b454ac9 100644 (file)
@@ -1,3 +1,10 @@
+2017-01-31  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/79264
+       * lambda.c (maybe_generic_this_capture): Deal with template-id-exprs.
+       * semantics.c (finish_member_declaration): Assert class is being
+       defined.
+
 2017-01-30  Alexandre Oliva <aoliva@redhat.com>
 
        Introduce C++ support in libcc1.
index 538c80639574bdbd8a104a66b22146e6c081ff81..46ab30f0a76df8f14c68bb87a26ccc9f47de953c 100644 (file)
@@ -849,13 +849,21 @@ maybe_generic_this_capture (tree object, tree fns)
           interest.  */
        if (BASELINK_P (fns))
          fns = BASELINK_FUNCTIONS (fns);
+       bool id_expr = TREE_CODE (fns) == TEMPLATE_ID_EXPR;
+       if (id_expr)
+         fns = TREE_OPERAND (fns, 0);
        for (; fns; fns = OVL_NEXT (fns))
-         if (DECL_NONSTATIC_MEMBER_FUNCTION_P (OVL_CURRENT (fns)))
-           {
-             /* Found a non-static member.  Capture this.  */
-             lambda_expr_this_capture (lam, true);
-             break;
-           }
+         {
+           tree fn = OVL_CURRENT (fns);
+
+           if ((!id_expr || TREE_CODE (fn) == TEMPLATE_DECL)
+               && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
+             {
+               /* Found a non-static member.  Capture this.  */
+               lambda_expr_this_capture (lam, true);
+               break;
+             }
+         }
       }
 }
 
index bd91e1832f73f1486ddb40b3cdef2664068b9a1b..e4f2a6a8807931a693654c18946dc2be7623be41 100644 (file)
@@ -2962,6 +2962,12 @@ finish_member_declaration (tree decl)
   /* We should see only one DECL at a time.  */
   gcc_assert (DECL_CHAIN (decl) == NULL_TREE);
 
+  /* Don't add decls after definition.  */
+  gcc_assert (TYPE_BEING_DEFINED (current_class_type)
+             /* We can add lambda types when late parsing default
+                arguments.  */
+             || LAMBDA_TYPE_P (TREE_TYPE (decl)));
+
   /* Set up access control for DECL.  */
   TREE_PRIVATE (decl)
     = (current_access_specifier == access_private_node);
index 76835d4ce5370ea03844bca82225693bb615cef4..675c190bb1ac0a868661d4386dd5c5eb72134e7d 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-31  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/79264
+       * g++.dg/cpp1y/pr61636-1.C: Augment.
+
 2017-01-31  Christophe Lyon  <christophe.lyon@linaro.org>
 
        * gcc.dg/memcmp-1.c (static void test_driver_memcmp): Call
index 9426d5f12178a5f978dfbfaad8d22bf11dd755e1..5cc8ca1d274edee009717d54abc5c6de9d567bbe 100644 (file)
@@ -1,4 +1,5 @@
 // PR c++/61636
+// PR c++/79264
 // { dg-do compile { target c++14 } }
 
 // ICE because we figure this capture too late.
@@ -28,4 +29,8 @@ void A::b() {
   auto lam2 = [&](auto asdf) { Baz (asdf); };
 
   lam2 (0);
+
+  auto lam3 = [&](auto asdf) { Baz<int> (asdf); };
+
+  lam3 (0);
 }