+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.
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);
--- /dev/null
+// 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);