Commit efc7052d by Jason Merrill Committed by Jason Merrill

decl.c (finish_function): Also complain about no return in templates.

        * decl.c (finish_function): Also complain about no return in
        templates.
        * semantics.c (finish_return_stmt): Also call check_return_expr in
        templates.
        * typeck.c (check_return_expr): In a template, just remember that we
        saw a return.

From-SVN: r60236
parent a3a0177e
2002-12-17 Jason Merrill <jason@redhat.com>
* decl.c (finish_function): Also complain about no return in
templates.
* semantics.c (finish_return_stmt): Also call check_return_expr in
templates.
* typeck.c (check_return_expr): In a template, just remember that we
saw a return.
2002-12-16 Jason Merrill <jason@redhat.com> 2002-12-16 Jason Merrill <jason@redhat.com>
* semantics.c (simplify_aggr_init_exprs_r): Don't change the type * semantics.c (simplify_aggr_init_exprs_r): Don't change the type
......
...@@ -14540,7 +14540,6 @@ finish_function (flags) ...@@ -14540,7 +14540,6 @@ finish_function (flags)
/* Complain if there's just no return statement. */ /* Complain if there's just no return statement. */
if (warn_return_type if (warn_return_type
&& !processing_template_decl
&& TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE && TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE
&& !current_function_returns_value && !current_function_returns_null && !current_function_returns_value && !current_function_returns_null
/* Don't complain if we abort or throw. */ /* Don't complain if we abort or throw. */
...@@ -14548,7 +14547,7 @@ finish_function (flags) ...@@ -14548,7 +14547,7 @@ finish_function (flags)
&& !DECL_NAME (DECL_RESULT (fndecl)) && !DECL_NAME (DECL_RESULT (fndecl))
/* Normally, with -Wreturn-type, flow will complain. Unless we're an /* Normally, with -Wreturn-type, flow will complain. Unless we're an
inline function, as we might never be compiled separately. */ inline function, as we might never be compiled separately. */
&& DECL_INLINE (fndecl)) && (DECL_INLINE (fndecl) || processing_template_decl))
warning ("no return statement in function returning non-void"); warning ("no return statement in function returning non-void");
/* Clear out memory we no longer need. */ /* Clear out memory we no longer need. */
......
...@@ -400,7 +400,6 @@ finish_return_stmt (expr) ...@@ -400,7 +400,6 @@ finish_return_stmt (expr)
{ {
tree r; tree r;
if (!processing_template_decl)
expr = check_return_expr (expr); expr = check_return_expr (expr);
if (!processing_template_decl) if (!processing_template_decl)
{ {
......
...@@ -6172,6 +6172,12 @@ check_return_expr (retval) ...@@ -6172,6 +6172,12 @@ check_return_expr (retval)
return NULL_TREE; return NULL_TREE;
} }
if (processing_template_decl)
{
current_function_returns_value = 1;
return retval;
}
/* When no explicit return-value is given in a function with a named /* When no explicit return-value is given in a function with a named
return value, the named return value is used. */ return value, the named return value is used. */
result = DECL_RESULT (current_function_decl); result = DECL_RESULT (current_function_decl);
......
// { dg-options "-Wall" }
template <class T>
int f (T t) { } // { dg-warning "no return" }
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