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.
# 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"
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])
this_file = argbuffer[i].what;
process_file (stdin, this_file, lang);
break;
+ default:
+ error ("internal error: arg_type");
}
}
case st_C_struct:
case st_C_enum:
typdef = ttypeseen;
+ break;
+ default:
+ break;
}
break;
case ttypeseen:
case st_C_struct:
case st_C_enum:
return false;
+ default:
+ return true;
}
- return true;
+ default:
+ break;
}
switch (toktype)
fvdef = fvnone;
}
return false;
+ default:
+ break;
}
if (structdef == skeyseen)
case st_C_objimpl:
objdef = oimplementation;
return false;
+ default:
+ break;
}
break;
case oimplementation:
objdef = onone;
}
return false;
+ default:
+ break;
}
/* A function, variable or enum constant? */
return false;
}
break;
+ default:
+ break;
}
/* FALLTHRU */
case fvnameseen:
fvdef = fvnameseen; /* function or variable */
*is_func_or_var = true;
return true;
+ default:
+ break;
}
break;
+ default:
+ break;
}
return false;
fvdef = fignore;
}
break;
+ default:
+ break;
}
if (structdef == stagseen && !cjava)
{
case dsharpseen:
savetoken = token;
break;
+ default:
+ break;
}
if (!yacc_rules || lp == newlb.buffer + 1)
{
break;
switch (objdef)
{
- case otagseen:
+ case otagseen:
objdef = oignore;
make_C_tag (true); /* an Objective C class */
break;
strcpy (token_name.buffer + toklen, ":");
}
break;
+ default:
+ break;
}
if (structdef == stagseen)
{
make_C_tag (true); /* an Objective C method */
objdef = oinbody;
break;
+ default:
+ break;
}
switch (fvdef)
{
fvdef = fvnone;
}
break;
+ default:
+ break;
}
break;
case '(':
case flistseen:
fvdef = finlist;
break;
+ default:
+ break;
}
parlev++;
break;
case finlist:
fvdef = flistseen;
break;
+ default:
+ break;
}
if (!instruct
&& (typdef == tend
bracelev = -1;
}
break;
+ default:
+ break;
}
switch (structdef)
{
structdef = snone;
make_C_tag (false); /* a struct or enum */
break;
+ default:
+ break;
}
bracelev += 1;
break;
else
ENCODE_LOCKING_SHIFT_3;
break;
+
+ default:
+ break;
}
}
case CODING_ANNOTATE_CHARSET_MASK:
produce_charset (coding, charbuf, pos);
break;
+ default:
+ break;
}
charbuf += len;
}
return Qfloat;
case Lisp_Misc_Finalizer:
return Qfinalizer;
+ default:
+ emacs_abort ();
}
- emacs_abort ();
case Lisp_Vectorlike:
if (WINDOW_CONFIGURATIONP (object))
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;
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
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;
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 ();
}
}
}
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 ();
}
}
}
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);
}
: c_code == Sstring_fence)
break;
- switch (c_code)
- {
- case Scharquote:
- case Sescape:
- INC_BOTH (from, from_byte);
- }
+ if (c_code == Scharquote || c_code == Sescape)
+ INC_BOTH (from, from_byte);
INC_BOTH (from, from_byte);
}
INC_BOTH (from, from_byte);
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;
}
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
+ 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: */
- return 0;
+ 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 ();
+ }
}
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;
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;
? scroll_bar_after_handle : scroll_bar_below_handle);
bar->dragging = -1;
break;
+ default:
+ break;
}
if (part != scroll_bar_nowhere)
case FULLSCREEN_HEIGHT:
lval = Qfullheight;
height = x_display_pixel_height (dpyinfo);
+ break;
+ default:
+ emacs_abort ();
}
frame_size_history_add