]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/69223 - ICE with deduced template return type.
authorJason Merrill <jason@redhat.com>
Fri, 22 Jul 2016 03:57:43 +0000 (23:57 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 22 Jul 2016 03:57:43 +0000 (23:57 -0400)
* semantics.c (apply_deduced_return_type): Call
complete_type_or_else before building the new RESULT_DECL.

From-SVN: r238631

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C [new file with mode: 0644]

index 553c2ba8fc7aaa731de025cb2adf721616c096db..db5eb75223b919b016bba6f62e772625c9f2e985 100644 (file)
@@ -1,5 +1,9 @@
 2016-07-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/69223
+       * semantics.c (apply_deduced_return_type): Call
+       complete_type_or_else before building the new RESULT_DECL.
+
        PR c++/71913
        * call.c (unsafe_copy_elision_p): It's OK to elide when
        initializing an unknown object.
index bc8fec1103bad022937648e3cb7adc40f485f6e1..7699765fe586c8cbe88021515152400063eb3040 100644 (file)
@@ -10664,6 +10664,10 @@ apply_deduced_return_type (tree fco, tree return_type)
   if (TREE_TYPE (result) == return_type)
     return;
 
+  if (!processing_template_decl && !VOID_TYPE_P (return_type)
+      && !complete_type_or_else (return_type, NULL_TREE))
+    return;
+
   /* We already have a DECL_RESULT from start_preparsed_function.
      Now we need to redo the work it and allocate_struct_function
      did to reflect the new type.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C
new file mode 100644 (file)
index 0000000..68ac29c
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/69223
+// { dg-do compile { target c++11 } }
+
+template <class T> struct A
+{
+  T x[20];
+};
+
+int main()
+{
+  auto l = [](const A<int>& i){ return i; };
+  A<int> a;
+
+  l(a);
+}