diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-01-14 23:43:56 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-01-14 23:43:56 +0100 |
commit | ef5d11818dec252c1c843e82645b52ea71ab315c (patch) | |
tree | eb13b6e69e774559a950dcafa95ea447376bfcfe | |
parent | 5b1cbe1453663b9abd6df089c2882071f2335fb2 (diff) | |
download | gcc-ef5d11818dec252c1c843e82645b52ea71ab315c.zip gcc-ef5d11818dec252c1c843e82645b52ea71ab315c.tar.gz gcc-ef5d11818dec252c1c843e82645b52ea71ab315c.tar.bz2 |
re PR middle-end/42674 (Bogus "no return statement in function returning non-void" warning)
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.
From-SVN: r155920
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-decl.c | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr42674.c | 13 |
6 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 29f71b1..ce96cca 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2010-01-14 Jakub Jelinek <jakub@redhat.com> + PR middle-end/42674 + * c-decl.c (finish_function): Don't emit -Wreturn-type warnings in + functions with noreturn attribute. + PR c++/42608 * varasm.c (declare_weak): Add weak attribute to decl if it doesn't have one already. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index a244a83..91d5884 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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. */ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c6e309f..1d13261 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-01-14 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/42674 + * decl.c (finish_function): Don't emit -Wreturn-type warnings in + functions with noreturn attribute. + 2010-01-14 Jason Merrill <jason@redhat.com> PR c++/42701 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e89113a..2409aa3 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b28449..f4d13be 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-01-14 Jakub Jelinek <jakub@redhat.com> + PR middle-end/42674 + * c-c++-common/pr42674.c: New test. + PR c++/42608 * g++.dg/template/instantiate11.C: New test. diff --git a/gcc/testsuite/c-c++-common/pr42674.c b/gcc/testsuite/c-c++-common/pr42674.c new file mode 100644 index 0000000..ae6730c --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr42674.c @@ -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 (); +} |