re PR c++/52845 (non-void return type deduced for lambda with empty compound statement)
authorJason Merrill <jason@redhat.com>
Wed, 4 Apr 2012 14:40:51 +0000 (10:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 4 Apr 2012 14:40:51 +0000 (10:40 -0400)
PR c++/52845
* decl.c (finish_function): Update fntype after deducing return type.

From-SVN: r186139

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

index 4b42e41..1b93ecd 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52845
+       * decl.c (finish_function): Update fntype after deducing return type.
+
 2012-04-03  Jason Merrill  <jason@redhat.com>
 
        PR c++/52796
index d210f19..e2f01d5 100644 (file)
@@ -13518,6 +13518,7 @@ finish_function (int flags)
                  "deduced to %<void%>");
        }
       apply_deduced_return_type (fndecl, void_type_node);
+      fntype = TREE_TYPE (fndecl);
     }
 
   /* Save constexpr function body before it gets munged by
index ed9a3c5..92c18df 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52845
+       * g++.dg/cpp0x/lambda/lambda-warn4.C: New.
+
 2012-04-03  Jason Merrill  <jason@redhat.com>
 
        PR c++/52796
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn4.C
new file mode 100644 (file)
index 0000000..2afeccf
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/52845
+// { dg-options "-std=c++11 -Wall" }
+
+void f()
+{
+  [](){};
+}