This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix warnings in unwind-dw2.c
- To: gcc-patches at gcc dot gnu dot org
- Subject: fix warnings in unwind-dw2.c
- From: Zack Weinberg <zackw at panix dot com>
- Date: Sat, 18 Aug 2001 17:38:18 -0400
This patch silences a warning about a variable used uninitialized in
unwind-dw2.c. The issue is that we have nested switch statements of
the form
switch (op) {
case a: case b: case c:
common_code();
switch (op) {
case a: result = code_a();
case b: result = code_b();
case c: result = code_c();
}
default: abort();
}
use(result);
GCC doesn't know that control cannot reach the inner switch unless op
is one of a, b, c, so it thinks there is a code path reaching the use
on which result is not initialized.
The patch just adds default: abort(); to the inner switches to nullify
the bogus code paths.
zw
* unwind-dw2.c (execute_stack_op): Add default aborts to
the inner switches to prevent warnings.
===================================================================
Index: unwind-dw2.c
--- unwind-dw2.c 2001/08/17 21:23:12 1.6
+++ unwind-dw2.c 2001/08/18 21:31:08
@@ -563,6 +563,9 @@ execute_stack_op (const unsigned char *o
op_ptr = read_uleb128 (op_ptr, &ptrtmp); reg = ptrtmp;
result += reg;
break;
+
+ default:
+ abort ();
}
break;
@@ -640,6 +643,9 @@ execute_stack_op (const unsigned char *o
case DW_OP_ne:
result = (_Unwind_Sword)first != (_Unwind_Sword)second;
break;
+
+ default:
+ abort ();
}
}
break;