+2017-10-10 Jason Merrill <jason@redhat.com>
+
+ * typeck.c (check_return_expr): Check non-dependent conversion in
+ templates.
+ * constraint.cc (check_function_concept): Don't complain about an
+ empty concept if seen_error.
+
2017-10-10 Richard Sandiford <richard.sandiford@linaro.org>
* cvt.c (ignore_overflows): Use wi::to_wide when
{
location_t loc = DECL_SOURCE_LOCATION (fn);
if (TREE_CODE (body) == STATEMENT_LIST && !STATEMENT_LIST_HEAD (body))
- error_at (loc, "definition of concept %qD is empty", fn);
+ {
+ if (seen_error ())
+ /* The definition was probably erroneous, not empty. */;
+ else
+ error_at (loc, "definition of concept %qD is empty", fn);
+ }
else
error_at (loc, "definition of concept %qD has multiple statements", fn);
}
if (check_for_bare_parameter_packs (retval))
return error_mark_node;
- if (WILDCARD_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl)))
+ /* If one of the types might be void, we can't tell whether we're
+ returning a value. */
+ if ((WILDCARD_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl)))
+ && !current_function_auto_return_pattern)
|| (retval != NULL_TREE
- && type_dependent_expression_p (retval)))
- return retval;
+ && (TREE_TYPE (retval) == NULL_TREE
+ || WILDCARD_TYPE_P (TREE_TYPE (retval)))))
+ goto dependent;
}
functype = TREE_TYPE (TREE_TYPE (current_function_decl));
warning (OPT_Weffc__, "%<operator=%> should return a reference to %<*this%>");
}
- if (processing_template_decl)
+ if (dependent_type_p (functype)
+ || type_dependent_expression_p (retval))
{
+ dependent:
/* We should not have changed the return value. */
gcc_assert (retval == saved_retval);
return retval;
named_return_value_okay_p =
(retval != NULL_TREE
+ && !processing_template_decl
/* Must be a local, automatic variable. */
&& VAR_P (retval)
&& DECL_CONTEXT (retval) == current_function_decl
build_zero_cst (TREE_TYPE (retval)));
}
+ if (processing_template_decl)
+ return saved_retval;
+
/* Actually copy the value returned into the appropriate location. */
if (retval && retval != result)
retval = build2 (INIT_EXPR, TREE_TYPE (result), result, retval);