aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>2003-04-03 20:22:47 -0500
committerJason Merrill <jason@gcc.gnu.org>2003-04-03 20:22:47 -0500
commit3e22acbe1705b70b7ba4416f2de122dc14c91462 (patch)
treefab10fd86eff90a6e01cc268c932076c66283e5a
parent250abc11eccbee224efe7316d546352d7298e9cf (diff)
re PR c/10175 (-Wunreachable-code doesn't work for single lines)
PR c/10175 * jump.c (never_reached_warning): Look backwards for a line note. From-SVN: r65228
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/jump.c12
2 files changed, 18 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d0a6e3adce5..da14be42104 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,7 +1,12 @@
+2003-04-03 Jason Merrill <jason@redhat.com>
+
+ PR c/10175
+ * jump.c (never_reached_warning): Look backwards for a line note.
+
2003-04-02 Richard Henderson <rth@redhat.com>
- * dwarf2out.c (output_call_frame_info): Ignore fde->nothrow as an
- optimization when flag_exceptions not enabled.
+ * dwarf2out.c (output_call_frame_info): Ignore fde->nothrow as an
+ optimization when flag_exceptions not enabled.
2003-03-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
diff --git a/gcc/jump.c b/gcc/jump.c
index 92806fcaa4b..9d272e8bc5c 100644
--- a/gcc/jump.c
+++ b/gcc/jump.c
@@ -1954,10 +1954,20 @@ never_reached_warning (avoided_insn, finish)
if (!warn_notreached)
return;
+ /* Back up to the first of any NOTEs preceding avoided_insn; flow passes
+ us the head of a block, a NOTE_INSN_BASIC_BLOCK, which often follows
+ the line note. */
+ for (insn = PREV_INSN (avoided_insn); ; insn = PREV_INSN (insn))
+ if (GET_CODE (insn) != NOTE)
+ {
+ insn = NEXT_INSN (insn);
+ break;
+ }
+
/* Scan forwards, looking at LINE_NUMBER notes, until we hit a LABEL
in case FINISH is NULL, otherwise until we run out of insns. */
- for (insn = avoided_insn; insn != NULL; insn = NEXT_INSN (insn))
+ for (; insn != NULL; insn = NEXT_INSN (insn))
{
if ((finish == NULL && GET_CODE (insn) == CODE_LABEL)
|| GET_CODE (insn) == BARRIER)