diff options
author | Roger Sayle <roger@eyesopen.com> | 2003-07-09 01:17:28 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2003-07-09 01:17:28 +0000 |
commit | 8af61113c7c4ec81ef7d4947a9e59d980333e397 (patch) | |
tree | 2d332d084bfac5b9cdcc4d9879b6b97227ad5b7b /gcc | |
parent | 436bcda146cf914b1211274a158c1b4b9d2a68a2 (diff) | |
download | gcc-8af61113c7c4ec81ef7d4947a9e59d980333e397.zip gcc-8af61113c7c4ec81ef7d4947a9e59d980333e397.tar.gz gcc-8af61113c7c4ec81ef7d4947a9e59d980333e397.tar.bz2 |
re PR other/11370 (-Wunreachable-code gives false complaints)
PR c/11370
* calls.c (emit_call_1): Don't bother popping the arguments off of
the stack after a noreturn function call; The adjustment is dead.
(expand_call): Likewise.
* gcc.dg/Wunreachable-6.c: New testcase.
* gcc.dg/Wunreachable-7.c: New testcase.
From-SVN: r69119
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/calls.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wunreachable-6.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wunreachable-7.c | 18 |
5 files changed, 60 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2d68c41..733ff95 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2003-07-08 Roger Sayle <roger@eyesopen.com> + + PR c/11370 + * calls.c (emit_call_1): Don't bother popping the arguments off of + the stack after a noreturn function call; The adjustment is dead. + (expand_call): Likewise. + 2003-07-08 Geoffrey Keating <geoffk@apple.com> * expr.c (MOVE_MAX_PIECES): Move from here... diff --git a/gcc/calls.c b/gcc/calls.c index 0415744..700564a 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -529,6 +529,10 @@ emit_call_1 (rtx funexp, tree fndecl ATTRIBUTE_UNUSED, tree funtype ATTRIBUTE_UN if the context of the call as a whole permits. */ inhibit_defer_pop = old_inhibit_defer_pop; + /* Don't bother cleaning up after a noreturn function. */ + if (ecf_flags & (ECF_NORETURN | ECF_LONGJMP)) + return; + if (n_popped > 0) { if (!already_popped) @@ -3074,6 +3078,10 @@ expand_call (tree exp, rtx target, int ignore) } emit_barrier_after (last); + + /* Stack adjustments after a noreturn call are dead code. */ + stack_pointer_delta = old_stack_allocated; + pending_stack_adjust = 0; } if (flags & ECF_LONGJMP) @@ -3304,8 +3312,9 @@ expand_call (tree exp, rtx target, int ignore) normal_call_insns = insns; /* Verify that we've deallocated all the stack we used. */ - if (old_stack_allocated != - stack_pointer_delta - pending_stack_adjust) + if (! (flags & (ECF_NORETURN | ECF_LONGJMP)) + && old_stack_allocated != stack_pointer_delta + - pending_stack_adjust) abort (); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5884c7f..cbd7cae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2003-07-08 Roger Sayle <roger@eyesopen.com> + + PR c/11370 + * gcc.dg/Wunreachable-6.c: New testcase. + * gcc.dg/Wunreachable-7.c: New testcase. + 2003-07-08 Jakub Jelinek <jakub@redhat.com> PR c/11420 diff --git a/gcc/testsuite/gcc.dg/Wunreachable-6.c b/gcc/testsuite/gcc.dg/Wunreachable-6.c new file mode 100644 index 0000000..77b6228 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wunreachable-6.c @@ -0,0 +1,18 @@ +/* PR c/11370 */ +/* { dg-do compile } */ +/* { dg-options "-Wunreachable-code" } */ + +int main(int argc, char *argv[]) +{ + if (argc != 1) + exit(1); + + { + int ix; /* { dg-bogus "will never be executed" } */ + ix = printf("hello\n"); + printf("%d\n", ix); + } + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/Wunreachable-7.c b/gcc/testsuite/gcc.dg/Wunreachable-7.c new file mode 100644 index 0000000..a19c94a --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wunreachable-7.c @@ -0,0 +1,18 @@ +/* PR c/11370 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wunreachable-code" } */ + +int main(int argc, char *argv[]) +{ + if (argc != 1) + exit(1); + + { + int ix; /* { dg-bogus "will never be executed" } */ + ix = printf("hello\n"); + printf("%d\n", ix); + } + + return 0; +} + |