Commit 8865587c authored by Paul Eggert's avatar Paul Eggert

Add -Wswitch to --enable-gcc-warnings

Make --enable-gcc-warnings a bit pickier, by also using -Wswitch.
* configure.ac (WERROR_CFLAGS): Don’t add -Wno-switch.
* lib-src/etags.c (main, consider_token, C_entries):
* src/coding.c (encode_invocation_designation):
* src/data.c (Ftype_of):
* src/eval.c (Fdefvaralias, default_toplevel_binding)
(Fbacktrace__locals, mark_specpdl):
* src/lisp.h (record_xmalloc):
* src/syntax.c (scan_lists, scan_sexps_forward):
* src/window.c (window_relative_x_coord):
* src/xdisp.c (push_it, pop_it):
* src/xterm.c (xg_scroll_callback, x_check_fullscreen):
Error out or do nothing (as appropriate) if a switch statement
with an enum value does not cover all of the enum.
* src/dispextern.h (struct iterator_stack_entry.u.comp):
Remove unused member discovered by using -Wswitch.
* src/lisp.h (record_xmalloc): Add a ‘+ 0’ to pacify -Wswitch.
* src/vm-limit.c (check_memory_limits):
Simplify warning-diagnostic computation by using a table.
parent 82198ed5
......@@ -928,10 +928,13 @@ else
# option problematic.
nw="$nw -Wsuggest-attribute=pure"
# This part is merely for shortening the command line,
# since -Wall implies -Wswitch.
nw="$nw -Wswitch"
# This part is merely for shortening the command line,
# since -Wno-FOO needs to be added below regardless.
nw="$nw -Wmissing-field-initializers"
nw="$nw -Wswitch"
nw="$nw -Wtype-limits"
nw="$nw -Wunused-parameter"
......@@ -948,7 +951,6 @@ else
gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-type-limits]) # Too many warnings for now
gl_WARN_ADD([-Wno-switch]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wno-format-nonliteral])
......
......@@ -1268,6 +1268,8 @@ main (int argc, char **argv)
this_file = argbuffer[i].what;
process_file (stdin, this_file, lang);
break;
default:
error ("internal error: arg_type");
}
}
......@@ -2754,6 +2756,9 @@ consider_token (char *str, int len, int c, int *c_extp,
case st_C_struct:
case st_C_enum:
typdef = ttypeseen;
break;
default:
break;
}
break;
case ttypeseen:
......@@ -2770,9 +2775,12 @@ consider_token (char *str, int len, int c, int *c_extp,
case st_C_struct:
case st_C_enum:
return false;
}
default:
return true;
}
default:
break;
}
switch (toktype)
{
......@@ -2804,6 +2812,8 @@ consider_token (char *str, int len, int c, int *c_extp,
fvdef = fvnone;
}
return false;
default:
break;
}
if (structdef == skeyseen)
......@@ -2827,6 +2837,8 @@ consider_token (char *str, int len, int c, int *c_extp,
case st_C_objimpl:
objdef = oimplementation;
return false;
default:
break;
}
break;
case oimplementation:
......@@ -2888,6 +2900,8 @@ consider_token (char *str, int len, int c, int *c_extp,
objdef = onone;
}
return false;
default:
break;
}
/* A function, variable or enum constant? */
......@@ -2943,6 +2957,8 @@ consider_token (char *str, int len, int c, int *c_extp,
return false;
}
break;
default:
break;
}
/* FALLTHRU */
case fvnameseen:
......@@ -2959,8 +2975,12 @@ consider_token (char *str, int len, int c, int *c_extp,
fvdef = fvnameseen; /* function or variable */
*is_func_or_var = true;
return true;
default:
break;
}
break;
default:
break;
}
return false;
......@@ -3470,6 +3490,8 @@ C_entries (int c_ext, FILE *inf)
fvdef = fignore;
}
break;
default:
break;
}
if (structdef == stagseen && !cjava)
{
......@@ -3480,6 +3502,8 @@ C_entries (int c_ext, FILE *inf)
case dsharpseen:
savetoken = token;
break;
default:
break;
}
if (!yacc_rules || lp == newlb.buffer + 1)
{
......@@ -3522,6 +3546,8 @@ C_entries (int c_ext, FILE *inf)
strcpy (token_name.buffer + toklen, ":");
}
break;
default:
break;
}
if (structdef == stagseen)
{
......@@ -3599,6 +3625,8 @@ C_entries (int c_ext, FILE *inf)
make_C_tag (true); /* an Objective C method */
objdef = oinbody;
break;
default:
break;
}
switch (fvdef)
{
......@@ -3672,6 +3700,8 @@ C_entries (int c_ext, FILE *inf)
fvdef = fvnone;
}
break;
default:
break;
}
break;
case '(':
......@@ -3705,6 +3735,8 @@ C_entries (int c_ext, FILE *inf)
case flistseen:
fvdef = finlist;
break;
default:
break;
}
parlev++;
break;
......@@ -3730,6 +3762,8 @@ C_entries (int c_ext, FILE *inf)
case finlist:
fvdef = flistseen;
break;
default:
break;
}
if (!instruct
&& (typdef == tend
......@@ -3801,6 +3835,8 @@ C_entries (int c_ext, FILE *inf)
bracelev = -1;
}
break;
default:
break;
}
switch (structdef)
{
......@@ -3814,6 +3850,8 @@ C_entries (int c_ext, FILE *inf)
structdef = snone;
make_C_tag (false); /* a struct or enum */
break;
default:
break;
}
bracelev += 1;
break;
......
......@@ -4295,6 +4295,9 @@ encode_invocation_designation (struct charset *charset,
else
ENCODE_LOCKING_SHIFT_3;
break;
default:
break;
}
}
......@@ -7292,6 +7295,8 @@ produce_annotation (struct coding_system *coding, ptrdiff_t pos)
case CODING_ANNOTATE_CHARSET_MASK:
produce_charset (coding, charbuf, pos);
break;
default:
break;
}
charbuf += len;
}
......
......@@ -226,8 +226,9 @@ for example, (type-of 1) returns `integer'. */)
return Qfloat;
case Lisp_Misc_Finalizer:
return Qfinalizer;
}
default:
emacs_abort ();
}
case Lisp_Vectorlike:
if (WINDOW_CONFIGURATIONP (object))
......
......@@ -2378,10 +2378,6 @@ struct it
struct it_slice slice;
ptrdiff_t image_id;
} image;
/* method == GET_FROM_COMPOSITION */
struct {
Lisp_Object object;
} comp;
/* method == GET_FROM_STRETCH */
struct {
Lisp_Object object;
......
......@@ -596,6 +596,11 @@ The return value is BASE-VARIABLE. */)
error ("Cannot make an internal variable an alias");
case SYMBOL_LOCALIZED:
error ("Don't know how to make a localized variable an alias");
case SYMBOL_PLAINVAL:
case SYMBOL_VARALIAS:
break;
default:
emacs_abort ();
}
/* http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg00834.html
......@@ -640,6 +645,17 @@ default_toplevel_binding (Lisp_Object symbol)
if (EQ (specpdl_symbol (pdl), symbol))
binding = pdl;
break;
case SPECPDL_UNWIND:
case SPECPDL_UNWIND_PTR:
case SPECPDL_UNWIND_INT:
case SPECPDL_UNWIND_VOID:
case SPECPDL_BACKTRACE:
case SPECPDL_LET_LOCAL:
break;
default:
emacs_abort ();
}
}
return binding;
......@@ -3462,6 +3478,17 @@ NFRAMES and BASE specify the activation frame to use, as in `backtrace-frame'.
else
result = Fcons (Fcons (sym, val), result);
}
break;
case SPECPDL_UNWIND:
case SPECPDL_UNWIND_PTR:
case SPECPDL_UNWIND_INT:
case SPECPDL_UNWIND_VOID:
case SPECPDL_BACKTRACE:
break;
default:
emacs_abort ();
}
}
}
......@@ -3504,6 +3531,14 @@ mark_specpdl (void)
mark_object (specpdl_symbol (pdl));
mark_object (specpdl_old_value (pdl));
break;
case SPECPDL_UNWIND_PTR:
case SPECPDL_UNWIND_INT:
case SPECPDL_UNWIND_VOID:
break;
default:
emacs_abort ();
}
}
}
......
......@@ -4353,12 +4353,13 @@ INLINE ptrdiff_t
lisp_word_count (ptrdiff_t nbytes)
{
if (-1 >> 1 == -1)
switch (word_size)
switch (word_size + 0)
{
case 2: return nbytes >> 1;
case 4: return nbytes >> 2;
case 8: return nbytes >> 3;
case 16: return nbytes >> 4;
default: break;
}
return nbytes / word_size - (nbytes % word_size < 0);
}
......
......@@ -2799,12 +2799,8 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
: c_code == Sstring_fence)
break;
switch (c_code)
{
case Scharquote:
case Sescape:
if (c_code == Scharquote || c_code == Sescape)
INC_BOTH (from, from_byte);
}
INC_BOTH (from, from_byte);
}
INC_BOTH (from, from_byte);
......@@ -3419,11 +3415,16 @@ do { prev_from = from; \
case Sstring_fence:
if (!nofence) goto string_end;
break;
case Scharquote:
case Sescape:
INC_FROM;
startquotedinstring:
if (from >= end) goto endquoted;
break;
default:
break;
}
INC_FROM;
}
......
......@@ -170,19 +170,13 @@ check_memory_limits (void)
if (new_warnlevel > warnlevel || new_warnlevel == warned_95)
{
warnlevel = new_warnlevel;
switch (warnlevel)
static char const *const warn_diagnostic[] =
{
case warned_75:
(*warn_function) ("Warning: past 75% of memory limit");
break;
case warned_85:
(*warn_function) ("Warning: past 85% of memory limit");
break;
case warned_95:
(*warn_function) ("Warning: past 95% of memory limit");
}
"Warning: past 75% of memory limit",
"Warning: past 85% of memory limit",
"Warning: past 95% of memory limit"
};
warn_function (warn_diagnostic[warnlevel - 1]);
}
/* Handle going down in usage levels, with some hysteresis. */
else
......
......@@ -1291,10 +1291,18 @@ window_relative_x_coord (struct window *w, enum window_part part, int x)
+ window_box_width (w, RIGHT_MARGIN_AREA)
+ ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w))
? WINDOW_RIGHT_FRINGE_WIDTH (w) : 0));
}
/* ON_SCROLL_BAR, ON_NOTHING, and ON_VERTICAL_BORDER: */
case ON_NOTHING:
case ON_VERTICAL_BORDER:
case ON_VERTICAL_SCROLL_BAR:
case ON_HORIZONTAL_SCROLL_BAR:
case ON_RIGHT_DIVIDER:
case ON_BOTTOM_DIVIDER:
return 0;
default:
emacs_abort ();
}
}
......
......@@ -5895,6 +5895,13 @@ push_it (struct it *it, struct text_pos *position)
case GET_FROM_STRETCH:
p->u.stretch.object = it->object;
break;
case GET_FROM_BUFFER:
case GET_FROM_DISPLAY_VECTOR:
case GET_FROM_STRING:
case GET_FROM_C_STRING:
break;
default:
emacs_abort ();
}
p->position = position ? *position : it->position;
p->current = it->current;
......@@ -6017,6 +6024,11 @@ pop_it (struct it *it)
it->method = GET_FROM_BUFFER;
it->object = it->w->contents;
}
break;
case GET_FROM_C_STRING:
break;
default:
emacs_abort ();
}
it->end_charpos = p->end_charpos;
it->string_nchars = p->string_nchars;
......
......@@ -5407,6 +5407,8 @@ xg_scroll_callback (GtkRange *range,
? scroll_bar_after_handle : scroll_bar_below_handle);
bar->dragging = -1;
break;
default:
break;
}
if (part != scroll_bar_nowhere)
......@@ -10193,6 +10195,9 @@ x_check_fullscreen (struct frame *f)
case FULLSCREEN_HEIGHT:
lval = Qfullheight;
height = x_display_pixel_height (dpyinfo);
break;
default:
emacs_abort ();
}
frame_size_history_add
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment