]> 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:51:22 +0000 (23:51 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 22 Jul 2016 03:51:22 +0000 (23:51 -0400)
* semantics.c (apply_deduced_return_type): Call
complete_type_or_else before building the new RESULT_DECL.

From-SVN: r238630

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

index bf6a736e24f540cd2bb635a52039fd64146521f5..0b17648eb650559ce70ef4043fa2785089bd9f33 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++/71630
        * pt.c (instantiate_decl): Fix pattern_defined for namespace scope
        variable templates.
index 74e40a967767393cb96e32e6fa85e3b7c250cd5c..6705d1f97c9a4f353f8bf564ae6adec8aa7ff6f9 100644 (file)
@@ -7698,6 +7698,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.  */
@@ -7713,8 +7717,6 @@ apply_deduced_return_type (tree fco, tree return_type)
 
   if (!processing_template_decl)
     {
-      if (!VOID_TYPE_P (TREE_TYPE (result)))
-       complete_type_or_else (TREE_TYPE (result), NULL_TREE);
       bool aggr = aggregate_value_p (result, fco);
 #ifdef PCC_STATIC_STRUCT_RETURN
       cfun->returns_pcc_struct = aggr;
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);
+}