Patchwork C++ PATCH for c++/52845 (bogus warning with empty lambda)

login
register
mail settings
Submitter Jason Merrill
Date April 4, 2012, 2:39 p.m.
Message ID <4F7C5D23.8050809@redhat.com>
Download mbox | patch
Permalink /patch/150743/
State New
Headers show

Comments

Jason Merrill - April 4, 2012, 2:39 p.m.
My patch for return type deduction forgot to update the fntype local 
variable in finish_function, leading to a bogus warning about a missing 
return statement.

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

Patch

commit 12a282edca78579074f5f4180cd2dce1edebd2bf
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 4 10:14:46 2012 -0400

    	PR c++/52845
    	* decl.c (finish_function): Update fntype after deducing return type.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d210f19..e2f01d5 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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
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
index 0000000..2afeccf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn4.C
@@ -0,0 +1,7 @@ 
+// PR c++/52845
+// { dg-options "-std=c++11 -Wall" }
+
+void f()
+{
+  [](){};
+}