public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/84802, ICE capturing uninstantiated class
@ 2018-03-12 12:57 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2018-03-12 12:57 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

If A<int> isn't instantiated by the time we build the capture proxy
VAR_DECL, it gets no DECL_SIZE. So make sure it is.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 84802.diff --]
[-- Type: text/x-patch, Size: 1092 bytes --]

commit e979dc834d91e52c0c568f85c2b62ec67dac3cdc
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Mar 12 01:01:14 2018 -0400

            PR c++/84802 - ICE capturing uninstantiated class.
    
            * lambda.c (build_capture_proxy): Call complete_type.

diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index de064ffc85e..b3c75c84682 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -432,6 +432,8 @@ build_capture_proxy (tree member, tree init)
       object = convert (type, ptr);
     }
 
+  complete_type (type);
+
   var = build_decl (input_location, VAR_DECL, name, type);
   SET_DECL_VALUE_EXPR (var, object);
   DECL_HAS_VALUE_EXPR_P (var) = 1;
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice9.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice9.C
new file mode 100644
index 00000000000..a07acfff884
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice9.C
@@ -0,0 +1,11 @@
+// PR c++/84802
+// { dg-do compile { target c++14 } }
+
+template <class T> struct A { };
+
+void f (A<int>& ar)
+{
+  [](const auto& x)
+    { return [x]{}(); }
+  (ar);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-12 12:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 12:57 C++ PATCH for c++/84802, ICE capturing uninstantiated class Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).