jump.c (never_reached_warning): Add finish argument.
* jump.c (never_reached_warning): Add finish argument. If finish is NULL, stop on CODE_LABEL, otherwise stop before first real insn after end. * rtl.h (never_reached_warning): Adjust prototype. * cse.c (cse_insn): Pass NULL as finish to never_reached_warning. * cfgrtl.c (flow_delete_block): Pass b->end as finish to never_reached_warning. * gcc.dg/Wunreachable-1.c: New test. * gcc.dg/Wunreachable-2.c: New test. From-SVN: r49713
This commit is contained in:
parent
34e68c86fb
commit
56d4428505
@ -1,3 +1,13 @@
|
||||
2002-02-12 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* jump.c (never_reached_warning): Add finish argument.
|
||||
If finish is NULL, stop on CODE_LABEL, otherwise stop before first
|
||||
real insn after end.
|
||||
* rtl.h (never_reached_warning): Adjust prototype.
|
||||
* cse.c (cse_insn): Pass NULL as finish to never_reached_warning.
|
||||
* cfgrtl.c (flow_delete_block): Pass b->end as finish to
|
||||
never_reached_warning.
|
||||
|
||||
2002-02-12 Graham Stott <grahams@redhat.com>
|
||||
|
||||
* config/hp/pa.h (GO_IF_LEGITIMATE_ADDRESS): Fix typos.
|
||||
|
@ -338,7 +338,7 @@ flow_delete_block (b)
|
||||
|
||||
insn = b->head;
|
||||
|
||||
never_reached_warning (insn);
|
||||
never_reached_warning (insn, b->end);
|
||||
|
||||
if (GET_CODE (insn) == CODE_LABEL)
|
||||
maybe_remove_eh_handler (insn);
|
||||
|
@ -5795,7 +5795,7 @@ cse_insn (insn, libcall_insn)
|
||||
else
|
||||
INSN_CODE (insn) = -1;
|
||||
|
||||
never_reached_warning (insn);
|
||||
never_reached_warning (insn, NULL);
|
||||
|
||||
/* Do not bother deleting any unreachable code,
|
||||
let jump/flow do that. */
|
||||
|
23
gcc/jump.c
23
gcc/jump.c
@ -1913,13 +1913,12 @@ delete_for_peephole (from, to)
|
||||
so it's possible to get spurious warnings from this. */
|
||||
|
||||
void
|
||||
never_reached_warning (avoided_insn)
|
||||
rtx avoided_insn;
|
||||
never_reached_warning (avoided_insn, finish)
|
||||
rtx avoided_insn, finish;
|
||||
{
|
||||
rtx insn;
|
||||
rtx a_line_note = NULL;
|
||||
int two_avoided_lines = 0;
|
||||
int contains_insn = 0;
|
||||
int two_avoided_lines = 0, contains_insn = 0, reached_end = 0;
|
||||
|
||||
if (! warn_notreached)
|
||||
return;
|
||||
@ -1929,10 +1928,11 @@ never_reached_warning (avoided_insn)
|
||||
|
||||
for (insn = avoided_insn; insn != NULL; insn = NEXT_INSN (insn))
|
||||
{
|
||||
if (GET_CODE (insn) == CODE_LABEL)
|
||||
if (finish == NULL && GET_CODE (insn) == CODE_LABEL)
|
||||
break;
|
||||
else if (GET_CODE (insn) == NOTE /* A line number note? */
|
||||
&& NOTE_LINE_NUMBER (insn) >= 0)
|
||||
|
||||
if (GET_CODE (insn) == NOTE /* A line number note? */
|
||||
&& NOTE_LINE_NUMBER (insn) >= 0)
|
||||
{
|
||||
if (a_line_note == NULL)
|
||||
a_line_note = insn;
|
||||
@ -1941,7 +1941,14 @@ never_reached_warning (avoided_insn)
|
||||
!= NOTE_LINE_NUMBER (insn));
|
||||
}
|
||||
else if (INSN_P (insn))
|
||||
contains_insn = 1;
|
||||
{
|
||||
if (reached_end)
|
||||
break;
|
||||
contains_insn = 1;
|
||||
}
|
||||
|
||||
if (insn == finish)
|
||||
reached_end = 1;
|
||||
}
|
||||
if (two_avoided_lines && contains_insn)
|
||||
warning_with_file_and_line (NOTE_SOURCE_FILE (a_line_note),
|
||||
|
@ -1808,7 +1808,7 @@ extern enum rtx_code reversed_comparison_code_parts PARAMS ((enum rtx_code,
|
||||
rtx, rtx, rtx));
|
||||
extern void delete_for_peephole PARAMS ((rtx, rtx));
|
||||
extern int condjump_in_parallel_p PARAMS ((rtx));
|
||||
extern void never_reached_warning PARAMS ((rtx));
|
||||
extern void never_reached_warning PARAMS ((rtx, rtx));
|
||||
extern void purge_line_number_notes PARAMS ((rtx));
|
||||
extern void copy_loop_headers PARAMS ((rtx));
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-02-12 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* gcc.dg/Wunreachable-1.c: New test.
|
||||
* gcc.dg/Wunreachable-2.c: New test.
|
||||
|
||||
2002-02-12 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||
|
||||
* gcc.dg/c90-const-expr-3.c, gcc.dg/c99-const-expr-3.c: New tests.
|
||||
|
24
gcc/testsuite/gcc.dg/Wunreachable-1.c
Normal file
24
gcc/testsuite/gcc.dg/Wunreachable-1.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wunreachable-code" } */
|
||||
|
||||
extern void foo (void);
|
||||
extern void baz (void);
|
||||
|
||||
void bar (int i)
|
||||
{
|
||||
if (i < 2)
|
||||
{
|
||||
baz ();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i >= 4 && i <= 5)
|
||||
foo ();
|
||||
return;
|
||||
}
|
||||
|
||||
baz (); /* { dg-warning "will never be executed" "" } */
|
||||
baz ();
|
||||
baz ();
|
||||
}
|
19
gcc/testsuite/gcc.dg/Wunreachable-2.c
Normal file
19
gcc/testsuite/gcc.dg/Wunreachable-2.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wunreachable-code" } */
|
||||
|
||||
extern int foo (const char *);
|
||||
extern void baz (void);
|
||||
const char *a[] = { "one", "two" };
|
||||
|
||||
void bar (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
if (! foo (a[i]))
|
||||
return;
|
||||
|
||||
baz (); /* { dg-bogus "will never be executed" } */
|
||||
baz ();
|
||||
baz ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user