+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
/* 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. */
&& !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. */
{
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))
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);
--- /dev/null
+// { dg-options "-Wall" }
+
+template <class T>
+int f (T t) { } // { dg-warning "no return" }