Commit 520fe2e3 by Jason Merrill Committed by Jason Merrill

PR c++/85842 - -Wreturn-type, constexpr if and generic lambda.

	* pt.c (tsubst_lambda_expr): Copy current_function_returns_* to
	generic lambda.

From-SVN: r260685
parent 71b55d45
2018-05-24 Jason Merrill <jason@redhat.com>
PR c++/85842 - -Wreturn-type, constexpr if and generic lambda.
* pt.c (tsubst_lambda_expr): Copy current_function_returns_* to
generic lambda.
2018-05-24 Ville Voutilainen <ville.voutilainen@gmail.com>
Pedwarn on a non-standard position of a C++ attribute.
......
......@@ -17636,6 +17636,17 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
register_parameter_specializations (oldfn, fn);
if (oldtmpl)
{
/* We might not partially instantiate some parts of the function, so
copy these flags from the original template. */
language_function *ol = DECL_STRUCT_FUNCTION (oldfn)->language;
current_function_returns_value = ol->returns_value;
current_function_returns_null = ol->returns_null;
current_function_returns_abnormally = ol->returns_abnormally;
current_function_infinite_loop = ol->infinite_loop;
}
tsubst_expr (DECL_SAVED_TREE (oldfn), args, complain, r,
/*constexpr*/false);
......
// PR c++/85842
// { dg-additional-options -std=c++17 }
template<class T>
auto f = [](auto&& arg) -> T* {
if constexpr (sizeof(arg) == 1) {
return nullptr;
} else {
return static_cast<T*>(&arg);
}
};
auto p = f<int>(0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment