* decl2.c (change_return_type): New fn.
* semantics.c (apply_lambda_return_type): Use it.
* cp-tree.h: Declare it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156634
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-02-09 Jason Merrill <jason@redhat.com>
+
+ PR c++/42370
+ * decl2.c (change_return_type): New fn.
+ * semantics.c (apply_lambda_return_type): Use it.
+ * cp-tree.h: Declare it.
+
2010-02-05 Richard Guenther <rguenther@suse.de>
* Make-lang.in (cp/cp-lang.o): Depend on gt-cp-cp-lang.h.
/* in decl2.c */
extern bool check_java_method (tree);
extern tree build_memfn_type (tree, tree, cp_cv_quals);
+extern tree change_return_type (tree, tree);
extern void maybe_retrofit_in_chrg (tree);
extern void maybe_make_one_only (tree);
extern bool vague_linkage_fn_p (tree);
return fntype;
}
+/* Return a variant of FNTYPE, a FUNCTION_TYPE or METHOD_TYPE, with its
+ return type changed to NEW_RET. */
+
+tree
+change_return_type (tree new_ret, tree fntype)
+{
+ tree newtype;
+ tree args = TYPE_ARG_TYPES (fntype);
+ tree raises = TYPE_RAISES_EXCEPTIONS (fntype);
+ tree attrs = TYPE_ATTRIBUTES (fntype);
+
+ if (same_type_p (new_ret, TREE_TYPE (fntype)))
+ return fntype;
+
+ if (TREE_CODE (fntype) == FUNCTION_TYPE)
+ newtype = build_function_type (new_ret, args);
+ else
+ newtype = build_method_type_directly (TYPE_METHOD_BASETYPE (fntype),
+ new_ret, TREE_CHAIN (args));
+ if (raises)
+ newtype = build_exception_variant (newtype, raises);
+ if (attrs)
+ newtype = cp_build_type_attribute_variant (newtype, attrs);
+
+ return newtype;
+}
+
/* Build a PARM_DECL with NAME and TYPE, and set DECL_ARG_TYPE
appropriately. */
/* TREE_TYPE (FUNCTION_DECL) == METHOD_TYPE
TREE_TYPE (METHOD_TYPE) == return-type */
- TREE_TYPE (TREE_TYPE (fco)) = return_type;
+ TREE_TYPE (fco) = change_return_type (return_type, TREE_TYPE (fco));
result = DECL_RESULT (fco);
if (result == NULL_TREE)
+2010-02-09 Jason Merrill <jason@redhat.com>
+
+ PR c++/42370
+ * g++.dg/cpp0x/lambda/lambda-warn2.C: New.
+
2010-02-09 Tobias Burnus <burnus@net-b.de>
PR fortran/41869
--- /dev/null
+// PR c++/42370
+// { dg-options "-std=c++0x -Wall" }
+
+void foo()
+{
+ []{ return 0; }();
+} // { dg-bogus "no return statement" }