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
This commit is contained in:
Roger Sayle 2003-07-09 01:17:28 +00:00 committed by Roger Sayle
parent 436bcda146
commit 8af61113c7
5 changed files with 60 additions and 2 deletions

View File

@ -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...

View File

@ -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 ();
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}