PR c++/85842 - -Wreturn-type, constexpr if and generic lambda.
[gcc.git] / gcc / cp / pt.c
index cfce9a9db62b21d8c4777a9c0bb7085802cbebac..d0fc9ee51a50e47794865b8f4489fa62d5b62836 100644 (file)
@@ -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);