2005-09-23 Alexandre Oliva * decl.c (finish_function): Skip no-return-statment warning if the return type uses template parms. * g++.dg/warn/return-void-1.C: New test. --- gcc/cp/decl.c.orig +++ gcc/cp/decl.c @@ -14475,7 +14475,8 @@ 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) || processing_template_decl)) + && (DECL_INLINE (fndecl) || processing_template_decl) + && !uses_template_parms (TREE_TYPE (fntype))) warning ("no return statement in function returning non-void"); /* Clear out memory we no longer need. */ --- gcc/testsuite/g++.dg/warn/return-void-1.C +++ gcc/testsuite/g++.dg/warn/return-void-1.C @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-Wall" } + +template T dummy1() {} +template T dummy2() {} // { dg-warning "end of non-void" } +template inline T dummy3() {} +template inline T dummy4() {} // { dg-warning "end of non-void|no return statement" } + +int main() +{ + dummy1(); + dummy2(); // { dg-warning "instantiated from here" } + dummy3(); + dummy4(); // { dg-warning "instantiated from here" } +}