aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 5646fa7..6294e19 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -8691,18 +8691,16 @@ begin_lambda_type (tree lambda)
tree
lambda_return_type (tree expr)
{
- tree type;
+ if (expr == NULL_TREE)
+ return void_type_node;
if (type_unknown_p (expr)
|| BRACE_ENCLOSED_INITIALIZER_P (expr))
{
cxx_incomplete_type_error (expr, TREE_TYPE (expr));
return void_type_node;
}
- if (type_dependent_expression_p (expr))
- type = dependent_lambda_return_type_node;
- else
- type = cv_unqualified (type_decays_to (unlowered_expr_type (expr)));
- return type;
+ gcc_checking_assert (!type_dependent_expression_p (expr));
+ return cv_unqualified (type_decays_to (unlowered_expr_type (expr)));
}
/* Given a LAMBDA_EXPR or closure type LAMBDA, return the op() of the
@@ -8749,29 +8747,32 @@ lambda_capture_field_type (tree expr)
return type;
}
-/* Recompute the return type for LAMBDA with body of the form:
- { return EXPR ; } */
+/* Insert the deduced return type for an auto function. */
void
-apply_lambda_return_type (tree lambda, tree return_type)
+apply_deduced_return_type (tree fco, tree return_type)
{
- tree fco = lambda_function (lambda);
tree result;
- LAMBDA_EXPR_RETURN_TYPE (lambda) = return_type;
-
if (return_type == error_mark_node)
return;
- if (TREE_TYPE (TREE_TYPE (fco)) == return_type)
- return;
- /* TREE_TYPE (FUNCTION_DECL) == METHOD_TYPE
- TREE_TYPE (METHOD_TYPE) == return-type */
+ if (LAMBDA_FUNCTION_P (fco))
+ {
+ tree lambda = CLASSTYPE_LAMBDA_EXPR (current_class_type);
+ LAMBDA_EXPR_RETURN_TYPE (lambda) = return_type;
+ }
+
+ if (DECL_CONV_FN_P (fco))
+ DECL_NAME (fco) = mangle_conv_op_name_for_type (return_type);
+
TREE_TYPE (fco) = change_return_type (return_type, TREE_TYPE (fco));
result = DECL_RESULT (fco);
if (result == NULL_TREE)
return;
+ if (TREE_TYPE (result) == return_type)
+ return;
/* We already have a DECL_RESULT from start_preparsed_function.
Now we need to redo the work it and allocate_struct_function
@@ -8786,12 +8787,13 @@ apply_lambda_return_type (tree lambda, tree return_type)
DECL_RESULT (fco) = result;
- if (!processing_template_decl && aggregate_value_p (result, fco))
+ if (!processing_template_decl)
{
+ bool aggr = aggregate_value_p (result, fco);
#ifdef PCC_STATIC_STRUCT_RETURN
- cfun->returns_pcc_struct = 1;
+ cfun->returns_pcc_struct = aggr;
#endif
- cfun->returns_struct = 1;
+ cfun->returns_struct = aggr;
}
}