PR middle-end/10336, c++/10401
authorJason Merrill <jason@redhat.com>
Tue, 15 Apr 2003 16:13:14 +0000 (12:13 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 15 Apr 2003 16:13:14 +0000 (12:13 -0400)
        PR middle-end/10336, c++/10401
        * jump.c (never_reached_warning): Also stop looking if we reach the
        beginning of the function.

From-SVN: r65637

gcc/ChangeLog
gcc/jump.c
gcc/testsuite/gcc.dg/Wunreachable-4.c [new file with mode: 0644]

index 2856bc1683d7c467a728319bf94752b89fcb66f8..e2750ace4e5e92ee714e750e6d21234264ff0251 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-14  Jason Merrill  <jason@redhat.com>
+
+       PR middle-end/10336, c++/10401
+       * jump.c (never_reached_warning): Also stop looking if we reach the 
+       beginning of the function.
+
 2003-04-15  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        PR target/10338
index b48bc6b03478fd5c14c92e4276a48291c0a4dd7c..5563ee34581a93d919b66ed36e6a039f4f07c212 100644 (file)
@@ -1913,7 +1913,8 @@ never_reached_warning (avoided_insn, finish)
      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)
+    if (GET_CODE (insn) != NOTE
+       || NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
       {
        insn = NEXT_INSN (insn);
        break;
diff --git a/gcc/testsuite/gcc.dg/Wunreachable-4.c b/gcc/testsuite/gcc.dg/Wunreachable-4.c
new file mode 100644 (file)
index 0000000..38ae6f8
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR middle-end/10336 */
+/* { dg-options "-Wunreachable-code" } */
+
+void foo(int i)
+{
+  switch(i) {
+    case 0:
+      break;
+    case 1:
+      break;
+  }
+}