2010-01-13 Jakub Jelinek PR middle-end/42674 * c-decl.c (finish_function): Don't emit -Wreturn-type warnings in functions with noreturn attribute. * decl.c (finish_function): Don't emit -Wreturn-type warnings in functions with noreturn attribute. * c-c++-common/pr42674.c: New test. --- gcc/c-decl.c.jj 2010-01-04 10:46:33.000000000 +0100 +++ gcc/c-decl.c 2010-01-13 18:41:44.000000000 +0100 @@ -8032,6 +8032,8 @@ finish_function (void) && !current_function_returns_value && !current_function_returns_null /* Don't complain if we are no-return. */ && !current_function_returns_abnormally + /* Don't complain if we are declared noreturn. */ + && !TREE_THIS_VOLATILE (fndecl) /* Don't warn for main(). */ && !MAIN_NAME_P (DECL_NAME (fndecl)) /* Or if they didn't actually specify a return type. */ --- gcc/cp/decl.c.jj 2009-12-23 17:31:06.000000000 +0100 +++ gcc/cp/decl.c 2010-01-13 18:43:01.000000000 +0100 @@ -12541,6 +12541,8 @@ finish_function (int flags) && !current_function_returns_value && !current_function_returns_null /* Don't complain if we abort or throw. */ && !current_function_returns_abnormally + /* Don't complain if we are declared noreturn. */ + && !TREE_THIS_VOLATILE (fndecl) && !DECL_NAME (DECL_RESULT (fndecl)) && !TREE_NO_WARNING (fndecl) /* Structor return values (if any) are set by the compiler. */ --- gcc/testsuite/c-c++-common/pr42674.c.jj 2010-01-13 18:57:20.000000000 +0100 +++ gcc/testsuite/c-c++-common/pr42674.c 2010-01-13 18:57:58.000000000 +0100 @@ -0,0 +1,13 @@ +/* PR middle-end/42674 */ +/* { dg-do compile } */ +/* { dg-options "-Wreturn-type" } */ + +extern void bar (void); +static int foo (void) __attribute__ ((__noreturn__, __used__)); + +static int +foo (void) +{ + while (1) + bar (); +}