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
This commit is contained in:
parent
a3a0177e77
commit
efc7052de7
@ -1,3 +1,12 @@
|
||||
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>
|
||||
|
||||
* semantics.c (simplify_aggr_init_exprs_r): Don't change the type
|
||||
|
@ -14540,7 +14540,6 @@ finish_function (flags)
|
||||
|
||||
/* Complain if there's just no return statement. */
|
||||
if (warn_return_type
|
||||
&& !processing_template_decl
|
||||
&& TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE
|
||||
&& !current_function_returns_value && !current_function_returns_null
|
||||
/* Don't complain if we abort or throw. */
|
||||
@ -14548,7 +14547,7 @@ finish_function (flags)
|
||||
&& !DECL_NAME (DECL_RESULT (fndecl))
|
||||
/* Normally, with -Wreturn-type, flow will complain. Unless we're an
|
||||
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");
|
||||
|
||||
/* Clear out memory we no longer need. */
|
||||
|
@ -400,8 +400,7 @@ finish_return_stmt (expr)
|
||||
{
|
||||
tree r;
|
||||
|
||||
if (!processing_template_decl)
|
||||
expr = check_return_expr (expr);
|
||||
expr = check_return_expr (expr);
|
||||
if (!processing_template_decl)
|
||||
{
|
||||
if (DECL_DESTRUCTOR_P (current_function_decl))
|
||||
|
@ -6172,6 +6172,12 @@ check_return_expr (retval)
|
||||
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
|
||||
return value, the named return value is used. */
|
||||
result = DECL_RESULT (current_function_decl);
|
||||
|
4
gcc/testsuite/g++.dg/warn/noreturn-2.C
Normal file
4
gcc/testsuite/g++.dg/warn/noreturn-2.C
Normal file
@ -0,0 +1,4 @@
|
||||
// { dg-options "-Wall" }
|
||||
|
||||
template <class T>
|
||||
int f (T t) { } // { dg-warning "no return" }
|
Loading…
Reference in New Issue
Block a user