This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.
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()
+{
+  [](){};
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]