Subject: bug#75964: Switching the Emacs build to -Wswitch-enum in src/

From: Pip Cet <[email-masked]>
Date: Sun, 02 Feb 2025 11:48:45 +0000

"Eli Zaretskii" <[email-masked]> writes:

>> Date: Sun, 02 Feb 2025 09:26:48 +0000
>> From: Pip Cet <[email-masked]>
>> Cc: [email-masked], [email-masked], [email-masked]
>>
>> "Eli Zaretskii" <[email-masked]> writes:
>>
>> >> Cc: [email-masked], Stefan Kangas <[email-masked]>
>> >> Date: Sun, 02 Feb 2025 08:39:11 +0000
>> >> From:  Pip Cet via "Bug reports for GNU Emacs,
>> >>  the Swiss army knife of text editors" <[email-masked]>
>> >>
>> >> I think we should enable -Wswitch-enum now, and expect it to generate
>> >> more warnings in the future.
>> >
>> > I'm not sure I understand what "in the future" means here, but please
>>
>> Future GCC versions may and will add warnings about cases that they
>> currently fail to warn about, for the same switch.  I don't think we can
>> change that.
>
> If future GCC versions add warnings, we will handle them when that
> happens and the warnings are reported or seen.  We don't need (and
> really cannot) worry about that at this time.

Agreed.

>> > Apologies if the above is not relevant to what you were discussing
>> > regarding adding warning options.
>>
>> I think it's highly relevant: I proposed several ways of adding the
>> warning options:  one file at a time, #pragma'd out, or enabled globally
>> and only merged once we can fix, at least, the common build systems.
>
> SGTM, thanks.

So while I'd like us to keep those options in mind, I've removed them
from the following diff.  The idea is this would give an overview over
which code segments would become hard to read as a result of such a
change, and whether it's bad enough that we need to look at
alternatives.

I think this concerns bidi.c and keyboard.c in particular.

I've marked some places where I'm not sure the old behavior was okay,
but I haven't checked them in detail.  I haven't found any "there was a
bug here and we only caught it because of this new warning" smoking
guns.

I've also stayed away from lib-src for now.

>> Simply enabling them globally and waiting for someone else to fix the
>> warnings only leads to other warnings being missed.
>
> Right.

diff --git a/configure.ac b/configure.ac
index 9db1f07d7fc..1fd86b9bac9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1828,6 +1828,8 @@ AC_DEFUN
     [nw="$nw -Wsuggest-attribute=noreturn"])
 
   gl_MANYWARN_ALL_GCC([ws])
+  ws="$ws -Wswitch-enum"
+#   ws="$ws -Wswitch-enum-consistency"  .... one day
   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
   for w in $ws; do
     gl_WARN_ADD([$w])
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 61a45622933..2dfc42389dc 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -657,6 +657,8 @@ find_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
       list = var ? &cls->static_vars : &cls->static_fns;
       break;
 
+    case SC_UNKNOWN:
+    case SC_MEMBER:
     default:
       list = var ? &cls->vars : &cls->fns;
       break;
@@ -902,6 +904,8 @@ add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
       list = var ? &cls->static_vars : &cls->static_fns;
       break;
 
+    case SC_UNKNOWN:
+    case SC_MEMBER:
     default:
       list = var ? &cls->vars : &cls->fns;
       break;
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 6243f666955..f55057ee2ea 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -718,6 +718,7 @@ write_globals (void)
 	      seen_defun = true;
 	    }
 	  break;
+	case INVALID:
 	default:
 	  fatal ("not a recognized DEFVAR_");
 	}
diff --git a/src/alloc.c b/src/alloc.c
index 7fa05e54202..6eeffb3e4e9 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3341,7 +3341,6 @@ cleanup_vector (struct Lisp_Vector *vector)
       break;
     /* Keep the switch exhaustive.  */
     case PVEC_NORMAL_VECTOR:
-    case PVEC_FREE:
     case PVEC_SYMBOL_WITH_POS:
     case PVEC_MISC_PTR:
     case PVEC_PROCESS:
@@ -3361,6 +3360,8 @@ cleanup_vector (struct Lisp_Vector *vector)
     case PVEC_SUB_CHAR_TABLE:
     case PVEC_RECORD:
       break;
+    case PVEC_FREE: eassume (0);
+    default: eassume (0);
     }
 }
 
@@ -5113,8 +5114,7 @@ mark_maybe_pointer (void *p, bool symbol_only)
 	  }
 	  break;
 
-	default:
-	  emacs_abort ();
+	default: eassume (0);
 	}
 
       mark_object (obj);
@@ -5492,8 +5492,7 @@ valid_lisp_object_p (Lisp_Object obj)
     case MEM_TYPE_VECTOR_BLOCK:
       return live_small_vector_p (m, p);
 
-    default:
-      break;
+    default: eassume (0);
     }
 
   return 0;
@@ -6727,10 +6726,31 @@ #define CHECK_ALLOCATED_AND_LIVE_SYMBOL()		((void) 0)
 #endif
 		break;
 
-	      case PVEC_FREE:
-		emacs_abort ();
-
-	      default:
+	      case PVEC_NORMAL_VECTOR:
+	      case PVEC_BIGNUM:
+	      case PVEC_MARKER:
+	      case PVEC_FINALIZER:
+	      case PVEC_SYMBOL_WITH_POS:
+	      case PVEC_MISC_PTR:
+	      case PVEC_USER_PTR:
+	      case PVEC_PROCESS:
+	      case PVEC_TERMINAL:
+	      case PVEC_WINDOW_CONFIGURATION:
+	      case PVEC_OTHER:
+	      case PVEC_XWIDGET:
+	      case PVEC_XWIDGET_VIEW:
+	      case PVEC_THREAD:
+	      case PVEC_MUTEX:
+	      case PVEC_CONDVAR:
+	      case PVEC_MODULE_FUNCTION:
+	      case PVEC_NATIVE_COMP_UNIT:
+	      case PVEC_TS_PARSER:
+	      case PVEC_TS_NODE:
+	      case PVEC_TS_COMPILED_QUERY:
+	      case PVEC_SQLITE:
+	      case PVEC_CLOSURE:
+	      case PVEC_RECORD:
+	      case PVEC_FONT:
 		{
 		  /* A regular vector or pseudovector needing no special
 		     treatment.  */
@@ -6741,6 +6761,8 @@ #define CHECK_ALLOCATED_AND_LIVE_SYMBOL()		((void) 0)
 		  mark_stack_push_values (ptr->contents, size);
 		}
 		break;
+	      case PVEC_FREE: eassume (0);
+	      default: eassume (0);
 	      }
 	  }
 	  break;
@@ -6790,7 +6812,7 @@ #define CHECK_ALLOCATED_AND_LIVE_SYMBOL()		((void) 0)
 		   reachable from font_style_table which is also
 		   staticpro'd.  */
 		break;
-	      default: emacs_abort ();
+	      default: eassume (0);
 	      }
 	    set_string_marked (XSTRING (ptr->u.s.name));
 	    mark_interval_tree (string_intervals (ptr->u.s.name));
@@ -6846,8 +6868,9 @@ #define CHECK_ALLOCATED_AND_LIVE_SYMBOL()		((void) 0)
 	case Lisp_Int1:
 	  break;
 
-	default:
-	  emacs_abort ();
+	case Lisp_Type_Unused0:
+	  eassume (0);
+	default: eassume (0);
 	}
     }
 
@@ -6926,8 +6949,8 @@ survives_gc_p (Lisp_Object obj)
         pdumper_object_p (XFLOAT (obj));
       break;
 
-    default:
-      emacs_abort ();
+    case Lisp_Type_Unused0: eassume (0);
+    default: eassume (0);
     }
 
   return survives_p;
diff --git a/src/android.c b/src/android.c
index f8d2df8fcf5..bd3a6028c85 100644
--- a/src/android.c
+++ b/src/android.c
@@ -745,8 +745,7 @@ android_write_event (union android_event *event)
       kill (getpid (), SIGIO);
       break;
 
-    default:
-      break;
+    default: eassume (0);
     }
 }
 
@@ -3815,8 +3814,7 @@ android_create_pixmap_from_bitmap_data (char *data, unsigned int width,
 
       break;
 
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   /* Unlock the bitmap itself.  */
@@ -4346,8 +4344,7 @@ android_copy_area (android_drawable src, android_drawable dest,
    /* do_blit = android_blit_invert; */
       /* A GC with its operation set to ANDROID_GC_INVERT is never given
 	 to CopyArea.  */
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   /* Load the bounds of the destination rectangle.  */
@@ -4799,8 +4796,7 @@ android_get_image (android_drawable handle,
       break;
 
       /* Other formats are currently not supported.  */
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   image->format = format;
diff --git a/src/bidi.c b/src/bidi.c
index d8754e2db73..9fd33a049c5 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -303,8 +303,20 @@ bidi_get_type (int ch, bidi_dir_t override)
       case FSI:
       case PDI:
 	return default_type;
-      default:
-	if (override == L2R)
+    case UNKNOWN_BT:
+    case STRONG_L:
+    case STRONG_R:
+    case WEAK_EN:
+    case WEAK_AN:
+    case STRONG_AL:
+    case WEAK_ES:
+    case WEAK_ET:
+    case WEAK_CS:
+    case WEAK_NSM:
+    case NEUTRAL_S:
+    case NEUTRAL_WS:
+    case NEUTRAL_ON:
+    default: 	if (override == L2R)
 	  return STRONG_L;
 	else if (override == R2L)
 	  return STRONG_R;
@@ -354,8 +366,7 @@ bidi_get_category (bidi_type_t type)
       case FSI:
       case PDI:
 	return EXPLICIT_FORMATTING;
-      default:
-	emacs_abort ();
+      default: 	emacs_abort ();
     }
 }
 
@@ -2047,8 +2058,28 @@ bidi_resolve_explicit (struct bidi_it *bidi_it)
 		new_level = bidi_pop_embedding_level (bidi_it);
 	    }
 	  break;
-	default:
-	  eassert (prev_type != FSI);
+	case UNKNOWN_BT:
+	case STRONG_L:
+	case STRONG_R:
+	case WEAK_EN:
+	case WEAK_AN:
+	case WEAK_BN:
+	case NEUTRAL_B:
+	case STRONG_AL:
+	case LRE:
+	case LRO:
+	case RLE:
+	case RLO:
+	case FSI:
+	case PDI:
+	case WEAK_ES:
+	case WEAK_ET:
+	case WEAK_CS:
+	case WEAK_NSM:
+	case NEUTRAL_S:
+	case NEUTRAL_WS:
+	case NEUTRAL_ON:
+	default: 	  eassert (prev_type != FSI);
 	  /* Nothing.  */
 	  break;
 	}
@@ -2197,8 +2228,22 @@ bidi_resolve_explicit (struct bidi_it *bidi_it)
       bidi_check_type (bidi_it->type_after_wn);
       type = WEAK_BN; /* X9/Retaining */
       break;
-    default:
-      /* Nothing.  */
+    case UNKNOWN_BT:
+    case STRONG_L:
+    case STRONG_R:
+    case WEAK_EN:
+    case WEAK_AN:
+    case WEAK_BN:
+    case NEUTRAL_B:
+    case STRONG_AL:
+    case WEAK_ES:
+    case WEAK_ET:
+    case WEAK_CS:
+    case WEAK_NSM:
+    case NEUTRAL_S:
+    case NEUTRAL_WS:
+    case NEUTRAL_ON:
+    default: /* Nothing.  */
       break;
     }
 
@@ -2723,8 +2768,27 @@ bidi_find_bracket_pairs (struct bidi_it *bidi_it)
 			  : FLAG_OPPOSITE_INSIDE);
 		  r2l_seen = true;
 		  break;
-		default:
-		  break;
+		case UNKNOWN_BT:
+		case WEAK_BN:
+		case NEUTRAL_B:
+		case STRONG_AL:
+		case LRE:
+		case LRO:
+		case RLE:
+		case RLO:
+		case PDF:
+		case LRI:
+		case RLI:
+		case FSI:
+		case PDI:
+		case WEAK_ES:
+		case WEAK_ET:
+		case WEAK_CS:
+		case WEAK_NSM:
+		case NEUTRAL_S:
+		case NEUTRAL_WS:
+		case NEUTRAL_ON:
+		default: 		  break;
 		}
 	      if (flag)
 		{
@@ -2995,8 +3059,27 @@ bidi_resolve_brackets (struct bidi_it *bidi_it)
 		? STRONG_L				     /* N0c1 */
 		: embedding_type;			     /* N0c2 */
 	      break;
-	    default:
-	      /* N0d: Do not set the type for that bracket pair.  */
+	    case UNKNOWN_BT:
+	    case WEAK_BN:
+	    case NEUTRAL_B:
+	    case STRONG_AL:
+	    case LRE:
+	    case LRO:
+	    case RLE:
+	    case RLO:
+	    case PDF:
+	    case LRI:
+	    case RLI:
+	    case FSI:
+	    case PDI:
+	    case WEAK_ES:
+	    case WEAK_ET:
+	    case WEAK_CS:
+	    case WEAK_NSM:
+	    case NEUTRAL_S:
+	    case NEUTRAL_WS:
+	    case NEUTRAL_ON:
+	    default: 	      /* N0d: Do not set the type for that bracket pair.  */
 	      break;
 	    }
 	}
@@ -3191,8 +3274,26 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
 		     were R in terms of their influence on NIs."  */
 		  next_type = STRONG_R;
 		  break;
-		default:
-		  emacs_abort ();
+		case UNKNOWN_BT:
+		case WEAK_BN:
+		case NEUTRAL_B:
+		case LRE:
+		case LRO:
+		case RLE:
+		case RLO:
+		case PDF:
+		case LRI:
+		case RLI:
+		case FSI:
+		case PDI:
+		case WEAK_ES:
+		case WEAK_ET:
+		case WEAK_CS:
+		case WEAK_NSM:
+		case NEUTRAL_S:
+		case NEUTRAL_WS:
+		case NEUTRAL_ON:
+		default: 		  emacs_abort ();
 		  break;
 		}
 	    }
diff --git a/src/buffer.c b/src/buffer.c
index 40f7ec83d6b..4e8f12727c1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1389,7 +1389,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer)
 	  result = Fdefault_value (variable);
 	break;
       }
-    default: emacs_abort ();
+    default: eassume (0);
     }
 
   return result;
diff --git a/src/data.c b/src/data.c
index 5fcdda1b6e8..aac95f4329e 100644
--- a/src/data.c
+++ b/src/data.c
@@ -286,16 +286,18 @@ DEFUN ("cl-type-of", Fcl_type_of, Scl_type_of, 1, 1, 0,
           return Qsub_char_table;
         /* "Impossible" cases.  */
 	case PVEC_MISC_PTR:
-        case PVEC_OTHER:
-        case PVEC_FREE: ;
+        case PVEC_OTHER: break;
+        case PVEC_FREE: eassume (0);
         }
       emacs_abort ();
 
     case Lisp_Float:
       return Qfloat;
 
-    default:
-      emacs_abort ();
+    default: eassume (0);
+
+    case Lisp_Type_Unused0:
+      eassume (0);
     }
 }
 
@@ -737,7 +739,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
       /* In set_internal, we un-forward vars when their value is
 	 set to Qunbound.  */
       return Qt;
-    default: emacs_abort ();
+    default: eassume (0);
     }
 
   return (BASE_EQ (valcontents, Qunbound) ? Qnil : Qt);
@@ -1335,7 +1337,7 @@ do_symval_forwarding (lispfwd valcontents)
     case Lisp_Fwd_Kboard_Obj:
       return *(Lisp_Object *) (XKBOARD_OBJFWD (valcontents)->offset
 			       + (char *) kboard_for_bindings ());
-    default: emacs_abort ();
+    default: eassume (0);
     }
 }
 
@@ -1592,7 +1594,7 @@ find_symbol_value (Lisp_Object symbol)
       }
     case SYMBOL_FORWARDED:
       return do_symval_forwarding (SYMBOL_FWD (sym));
-    default: emacs_abort ();
+    default: eassume (0);
     }
 }
 
@@ -1664,7 +1666,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
     case SYMBOL_UNTRAPPED_WRITE:
       break;
 
-    default: emacs_abort ();
+    default: eassume (0);
     }
 
  start:
@@ -1777,7 +1779,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
 	store_symval_forwarding (/* sym, */ innercontents, newval, buf);
 	break;
       }
-    default: emacs_abort ();
+    default: eassume (0);
     }
   return;
 }
@@ -1951,7 +1953,7 @@ default_value (Lisp_Object symbol)
 	/* For other variables, get the current value.  */
 	return do_symval_forwarding (valcontents);
       }
-    default: emacs_abort ();
+    default: eassume (0);
     }
 }
 
@@ -2009,7 +2011,7 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
     case SYMBOL_UNTRAPPED_WRITE:
       break;
 
-    default: emacs_abort ();
+    default: eassume (0);
     }
 
  start:
@@ -2075,7 +2077,7 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
           set_internal (symbol, value, Qnil, bindflag);
         return;
       }
-    default: emacs_abort ();
+    default: eassume (0);
     }
 }
 
@@ -2177,7 +2179,7 @@ DEFUN ("make-variable-buffer-local", Fmake_variable_buffer_local,
       else if (BUFFER_OBJFWDP (valcontents.fwd))
 	return variable;
       break;
-    default: emacs_abort ();
+    default: eassume (0);
     }
 
   if (SYMBOL_CONSTANT_P (variable))
@@ -2240,7 +2242,7 @@ DEFUN ("make-local-variable", Fmake_local_variable, Smake_local_variable,
 	error ("Symbol %s may not be buffer-local",
 	       SDATA (SYMBOL_NAME (variable)));
       break;
-    default: emacs_abort ();
+    default: eassume (0);
     }
 
   if (sym->u.s.trapped_write == SYMBOL_NOWRITE)
@@ -2337,7 +2339,7 @@ DEFUN ("kill-local-variable", Fkill_local_variable, Skill_local_variable,
     case SYMBOL_LOCALIZED:
       blv = SYMBOL_BLV (sym);
       break;
-    default: emacs_abort ();
+    default: eassume (0);
     }
 
   if (sym->u.s.trapped_write == SYMBOL_TRAPPED_WRITE)
@@ -2410,7 +2412,7 @@ DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p,
 	  }
 	return Qnil;
       }
-    default: emacs_abort ();
+    default: eassume (0);
     }
 }
 
@@ -2445,7 +2447,7 @@ DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_s
     case SYMBOL_FORWARDED:
       /* All BUFFER_OBJFWD slots become local if they are set.  */
       return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil);
-    default: emacs_abort ();
+    default: eassume (0);
     }
 }
 
@@ -2488,7 +2490,7 @@ DEFUN ("variable-binding-locus", Fvariable_binding_locus, Svariable_binding_locu
 	return SYMBOL_BLV (sym)->where;
       else
 	return Qnil;
-    default: emacs_abort ();
+    default: eassume (0);
     }
 }
 
@@ -3133,7 +3135,10 @@ floatop_arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
 	    xsignal0 (Qarith_error);
 	  accum /= next;
 	  break;
-	default: eassume (false);
+	case Alogior:
+	case Alogxor:
+	case Alogand:
+	default: eassume (0);
 	}
 
     next_arg:
@@ -3193,8 +3198,7 @@ bignum_arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
 	    xsignal0 (Qarith_error);
 	  mpz_tdiv_q (mpz[0], *accum, *next);
 	  break;
-	default:
-	  eassume (false);
+	default: eassume (0);
 	}
       accum = &mpz[0];
 
@@ -3258,7 +3262,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
 	  case Alogand: accum &= next; continue;
 	  case Alogior: accum |= next; continue;
 	  case Alogxor: accum ^= next; continue;
-	  default: eassume (false);
+	  default: eassume (0);
 	  }
 	if (overflow)
 	  break;
@@ -3772,8 +3776,8 @@ bool_vector_binop_driver (Lisp_Object a,
 	destdata[i] = adata[i] &~ bdata[i];
       break;
 
-    default:
-      eassume (0);
+    case bool_vector_subsetp:
+    default: eassume (0);
     }
 
   return dest;
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 5f89122eaf7..e22347a7e1e 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -557,8 +557,7 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object)
       xd_signature_cat (signature, DBUS_DICT_ENTRY_END_CHAR_AS_STRING);
       break;
 
-    default:
-      wrong_type_argument (QD_Bus, object);
+    default: wrong_type_argument (QD_Bus, object);
     }
 
   XD_DEBUG_MESSAGE ("%s", signature);
@@ -985,8 +984,7 @@ xd_retrieve_arg (int dtype, DBusMessageIter *iter)
 	return Fcons (xd_dbus_type_to_symbol (dtype), Fnreverse (result));
       }
 
-    default:
-      XD_DEBUG_MESSAGE ("DBusType '%c' not supported", dtype);
+    default: XD_DEBUG_MESSAGE ("DBusType '%c' not supported", dtype);
       return Qnil;
     }
 }
diff --git a/src/dired.c b/src/dired.c
index 915a2097042..95108fb7b14 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -612,8 +612,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
 	  directoryp = file_name_completion_dirp (fd, dp, len);
 	  break;
 
-	default:
-	  directoryp = false;
+	default: 	  directoryp = false;
 	  break;
 	}
 
diff --git a/src/dispextern.h b/src/dispextern.h
index 1b383164752..85b2e57402b 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2337,9 +2337,11 @@ #define MAX_FRINGE_BITMAPS (1<<FRINGE_ID_BITS)
   GET_FROM_IMAGE,
   GET_FROM_STRETCH,
   GET_FROM_XWIDGET,
-  NUM_IT_METHODS
+  MAX_IT_METHOD = GET_FROM_XWIDGET
 };
 
+#define NUM_IT_METHODS (MAX_IT_METHOD + 1)
+
 /* FIXME: What is this?  Why 5?  */
 #define IT_STACK_SIZE 5
 
diff --git a/src/dispnew.c b/src/dispnew.c
index 5f5575d484b..cd1f2255c93 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3608,6 +3608,8 @@ produce_box_glyphs (enum box box, struct glyph_row *row, int x, int n,
     case BOX_DOUBLE_UP_RIGHT:
     case BOX_DOUBLE_UP_LEFT:
       emacs_abort ();
+    default:
+      eassume (0);
     }
 
   /* FIXME/tty: some face for the border.  */
diff --git a/src/emacs.c b/src/emacs.c
index f0281044c9e..72a2e42b193 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -846,6 +846,7 @@ dump_error_to_string (int result)
       return "dump file is result of failed dump attempt";
     case PDUMPER_LOAD_VERSION_MISMATCH:
       return "not built for this Emacs executable";
+    case PDUMPER_LOAD_ERROR:
     default:
       return (result <= PDUMPER_LOAD_ERROR
 	      ? "generic error"
diff --git a/src/eval.c b/src/eval.c
index 70f533842b9..372b84d4d48 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -729,6 +729,19 @@ default_toplevel_binding (Lisp_Object symbol)
     {
       switch ((--pdl)->kind)
 	{
+	case SPECPDL_UNWIND:
+	case SPECPDL_UNWIND_ARRAY:
+	case SPECPDL_UNWIND_PTR:
+	case SPECPDL_UNWIND_INT:
+	case SPECPDL_UNWIND_INTMAX:
+	case SPECPDL_UNWIND_EXCURSION:
+	case SPECPDL_UNWIND_VOID:
+	case SPECPDL_BACKTRACE:
+	case SPECPDL_NOP:
+	case SPECPDL_MODULE_RUNTIME:
+	case SPECPDL_MODULE_ENVIRONMENT:
+	case SPECPDL_LET_LOCAL:
+	  break;
 	case SPECPDL_LET_DEFAULT:
 	case SPECPDL_LET:
 	  if (EQ (specpdl_symbol (pdl), symbol))
@@ -762,6 +775,18 @@ lexbound_p (Lisp_Object symbol)
 	    }
 	  break;
 
+	case SPECPDL_UNWIND:
+	case SPECPDL_UNWIND_ARRAY:
+	case SPECPDL_UNWIND_PTR:
+	case SPECPDL_UNWIND_INT:
+	case SPECPDL_UNWIND_INTMAX:
+	case SPECPDL_UNWIND_EXCURSION:
+	case SPECPDL_UNWIND_VOID:
+	case SPECPDL_BACKTRACE:
+	case SPECPDL_NOP:
+	case SPECPDL_MODULE_RUNTIME:
+	case SPECPDL_MODULE_ENVIRONMENT:
+	case SPECPDL_LET_LOCAL:
 	default: break;
 	}
     }
@@ -3489,6 +3514,7 @@ do_specbind (struct Lisp_Symbol *sym, union specbinding *bind,
       set_internal (specpdl_symbol (bind), value, Qnil, bindflag);
       break;
 
+    case SYMBOL_VARALIAS:
     default:
       emacs_abort ();
     }
@@ -4081,6 +4107,15 @@ specpdl_unrewind (union specbinding *pdl, int distance, bool vars_only)
 	  }
 	  break;
 
+	case SPECPDL_UNWIND_ARRAY:
+	case SPECPDL_UNWIND_PTR:
+	case SPECPDL_UNWIND_INT:
+	case SPECPDL_UNWIND_INTMAX:
+	case SPECPDL_UNWIND_VOID:
+	case SPECPDL_BACKTRACE:
+	case SPECPDL_NOP:
+	case SPECPDL_MODULE_RUNTIME:
+	case SPECPDL_MODULE_ENVIRONMENT:
 	default: break;
 	}
     }
@@ -4149,6 +4184,18 @@ DEFUN ("backtrace--locals", Fbacktrace__locals, Sbacktrace__locals, 1, 2, NULL,
       {
 	switch (tmp->kind)
 	  {
+	  case SPECPDL_UNWIND:
+	  case SPECPDL_UNWIND_ARRAY:
+	  case SPECPDL_UNWIND_PTR:
+	  case SPECPDL_UNWIND_INT:
+	  case SPECPDL_UNWIND_INTMAX:
+	  case SPECPDL_UNWIND_EXCURSION:
+	  case SPECPDL_UNWIND_VOID:
+	  case SPECPDL_BACKTRACE:
+	  case SPECPDL_NOP:
+	  case SPECPDL_MODULE_RUNTIME:
+	  case SPECPDL_MODULE_ENVIRONMENT
+	    break;
 	  case SPECPDL_LET:
 	  case SPECPDL_LET_DEFAULT:
 	  case SPECPDL_LET_LOCAL:
diff --git a/src/filelock.c b/src/filelock.c
index e61c6776e3e..3105e8044d3 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -373,7 +373,9 @@ integer_prefixed (char const *s)
     ANOTHER_OWNS_IT = NEGATIVE_ERRNO ? 1 : -1,
 
     /* This Emacs process owns it.  */
-    I_OWN_IT = 2 * ANOTHER_OWNS_IT
+    I_OWN_IT = 2 * ANOTHER_OWNS_IT,
+
+    NOBODY_OWNS_IT = 0,
   };
 
 /* Return 0 if nobody owns the lock file LFNAME or the lock is obsolete,
@@ -800,7 +802,7 @@ DEFUN ("file-locked-p", Ffile_locked_p, Sfile_locked_p, 1, 1, 0,
     case ANOTHER_OWNS_IT:
       ret = make_string (locker.user, locker.at - locker.user);
       break;
-    case  0: ret = Qnil; break;
+    case NOBODY_OWNS_IT: ret = Qnil; break;
     default: report_file_errno ("Testing file lock", filename, owner);
     }
 
diff --git a/src/fns.c b/src/fns.c
index ec1a39fada7..1d3ec32a637 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2860,6 +2860,12 @@ internal_equal_1 (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
 	    else
 	      hash_put (h, o1, Fcons (o2, Qnil), hash);
 	  }
+	case Lisp_Symbol:
+	case Lisp_Type_Unused0:
+	case Lisp_Int0:
+	case Lisp_Int1:
+	case Lisp_String:
+	case Lisp_Float:
 	default: ;
 	}
     }
@@ -2986,8 +2992,12 @@ internal_equal_1 (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
 	      && (equal_kind != EQUAL_INCLUDING_PROPERTIES
 	          || compare_string_intervals (o1, o2)));
 
-    default:
-      break;
+    case Lisp_Type_Unused0:
+      eassume (0);
+    case Lisp_Symbol:
+    case Lisp_Int0:
+    case Lisp_Int1:
+    default: break;
     }
 
   return false;
@@ -3195,8 +3205,35 @@ value_cmp (Lisp_Object a, Lisp_Object b, int maxdepth)
 		b = XSYMBOL_WITH_POS_SYM (b);
 		goto tail_recurse;
 
-	      default:
-		/* Treat other types as unordered.  */
+	      case PVEC_FREE: eassume (0);
+	      case PVEC_OVERLAY:
+	      case PVEC_FINALIZER:
+	      case PVEC_MISC_PTR:
+	      case PVEC_USER_PTR:
+	      case PVEC_FRAME:
+	      case PVEC_WINDOW:
+	      case PVEC_HASH_TABLE:
+	      case PVEC_OBARRAY:
+	      case PVEC_TERMINAL:
+	      case PVEC_WINDOW_CONFIGURATION:
+	      case PVEC_SUBR:
+	      case PVEC_OTHER:
+	      case PVEC_XWIDGET:
+	      case PVEC_XWIDGET_VIEW:
+	      case PVEC_THREAD:
+	      case PVEC_MUTEX:
+	      case PVEC_CONDVAR:
+	      case PVEC_MODULE_FUNCTION:
+	      case PVEC_NATIVE_COMP_UNIT:
+	      case PVEC_TS_PARSER:
+	      case PVEC_TS_NODE:
+	      case PVEC_TS_COMPILED_QUERY:
+	      case PVEC_SQLITE:
+	      case PVEC_CLOSURE:
+	      case PVEC_CHAR_TABLE:
+	      case PVEC_SUB_CHAR_TABLE:
+	      case PVEC_FONT:
+	      default: 		/* Treat other types as unordered.  */
 		return 0;
 	      }
 	}
@@ -3226,8 +3263,8 @@ value_cmp (Lisp_Object a, Lisp_Object b, int maxdepth)
       }
       goto type_mismatch;
 
-    default:
-      eassume (0);
+    case Lisp_Type_Unused0:
+    default: eassume (0);
     }
  type_mismatch:
   xsignal2 (Qtype_mismatch, a, b);
@@ -5572,8 +5609,9 @@ sxhash_obj (Lisp_Object obj, int depth)
     case Lisp_Float:
       return sxhash_float (XFLOAT_DATA (obj));
 
-    default:
-      emacs_abort ();
+    case Lisp_Type_Unused0:
+      eassume (0);
+    default: emacs_abort ();
     }
 }
 
diff --git a/src/font.c b/src/font.c
index dfe479f9355..1bbb27b07fc 100644
--- a/src/font.c
+++ b/src/font.c
@@ -432,8 +432,22 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val,
 	case FONT_WIDTH_INDEX:
 	  Vfont_width_table = new_table;
 	  break;
-	default:
-	  break;
+	case FONT_TYPE_INDEX:
+	case FONT_FOUNDRY_INDEX:
+	case FONT_FAMILY_INDEX:
+	case FONT_ADSTYLE_INDEX:
+	case FONT_REGISTRY_INDEX:
+	case FONT_SIZE_INDEX:
+	case FONT_DPI_INDEX:
+	case FONT_SPACING_INDEX:
+	case FONT_AVGWIDTH_INDEX:
+	case FONT_EXTRA_INDEX:
+	case FONT_OBJLIST_INDEX:
+	case FONT_NAME_INDEX:
+	case FONT_FULLNAME_INDEX:
+	case FONT_FILE_INDEX:
+	case FONT_OBJECT_MAX:
+	default: 	  eassume (0);
 	}
       ASET (font_style_table, prop - FONT_WEIGHT_INDEX, new_table);
       return (100 << 8) | (i << 4);
diff --git a/src/fringe.c b/src/fringe.c
index 5cd6ff5fc8d..301ea0aba3d 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -861,8 +861,8 @@ draw_fringe_bitmap (struct window *w, struct glyph_row *row, int left_p)
 	  cursor = Qhbar;
 	  break;
 	case NO_CURSOR:
-	default:
-	  w->phys_cursor_on_p = 0;
+	case DEFAULT_CURSOR:
+	default: 	  w->phys_cursor_on_p = 0;
 	  row->cursor_in_fringe_p = 0;
 	  break;
 	}
diff --git a/src/keyboard.c b/src/keyboard.c
index 2d8c45c05ee..2b6a27c0604 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -4278,8 +4278,27 @@ kbd_buffer_get_event (KBOARD **kbp,
           kbd_fetch_ptr = next_kbd_event (event);
         }
         break;
-      default:
-	{
+
+      case MULTIBYTE_CHAR_KEYSTROKE_EVENT:
+      case ASCII_KEYSTROKE_EVENT:
+      case NON_ASCII_KEYSTROKE_EVENT:
+      case TIMER_EVENT:
+      case MOUSE_CLICK_EVENT:
+      case WHEEL_EVENT:
+      case HORIZ_WHEEL_EVENT:
+      case SCROLL_BAR_CLICK_EVENT:
+      case HORIZONTAL_SCROLL_BAR_CLICK_EVENT:
+      case MENU_BAR_EVENT:
+      case DRAG_N_DROP_EVENT:
+      case USER_SIGNAL_EVENT:
+      case TAB_BAR_EVENT:
+      case TOOL_BAR_EVENT:
+      case TOUCH_END_EVENT:
+      case TOUCHSCREEN_UPDATE_EVENT:
+      case TOUCHSCREEN_BEGIN_EVENT:
+      case TOUCHSCREEN_END_EVENT:
+      case PINCH_EVENT:
+      default: 	{
 	  /* If this event is on a different frame, return a
 	     switch-frame this time, and leave the event in the queue
 	     for next time.  */
@@ -7117,9 +7136,15 @@ make_lispy_event (struct input_event *event)
     case PREEDIT_TEXT_EVENT:
       return list2 (Qpreedit_text, event->arg);
 
-      /* The 'kind' field of the event is something we don't recognize.  */
-    default:
+    case SELECTION_REQUEST_EVENT:
+    case MENU_BAR_ACTIVATE_EVENT:
+    case SELECTION_CLEAR_EVENT:
+    case MONITORS_CHANGED_EVENT:
+    case TIMER_EVENT:
       emacs_abort ();
+
+      /* The 'kind' field of the event is something we don't recognize.  */
+    default: emacs_abort ();
     }
 }
 
@@ -12826,6 +12851,36 @@ is_ignored_event (union buffered_input_event *event)
 #ifdef HAVE_DBUS
     case DBUS_EVENT: ignore_event = Qdbus_event; break;
 #endif
+    case ASCII_KEYSTROKE_EVENT:
+    case MULTIBYTE_CHAR_KEYSTROKE_EVENT:
+    case NON_ASCII_KEYSTROKE_EVENT:
+    case TIMER_EVENT:
+    case MOUSE_CLICK_EVENT:
+    case WHEEL_EVENT:
+    case HORIZ_WHEEL_EVENT:
+    case SCROLL_BAR_CLICK_EVENT:
+    case HORIZONTAL_SCROLL_BAR_CLICK_EVENT:
+    case SELECTION_CLEAR_EVENT:
+    case DELETE_WINDOW_EVENT:
+    case MENU_BAR_EVENT:
+    case MENU_BAR_ACTIVATE_EVENT:
+    case DRAG_N_DROP_EVENT:
+    case USER_SIGNAL_EVENT:
+    case TAB_BAR_EVENT:
+    case TOOL_BAR_EVENT:
+    case MOVE_FRAME_EVENT:
+    case SELECT_WINDOW_EVENT:
+    case SAVE_SESSION_EVENT:
+    case THREAD_EVENT:
+    case CONFIG_CHANGED_EVENT:
+    case PREEDIT_TEXT_EVENT:
+    case TOUCH_END_EVENT:
+    case TOUCHSCREEN_UPDATE_EVENT:
+    case TOUCHSCREEN_BEGIN_EVENT:
+    case TOUCHSCREEN_END_EVENT:
+    case PINCH_EVENT:
+    case MONITORS_CHANGED_EVENT:
+    case NO_EVENT:
     default: ignore_event = Qnil; break;
     }
 
diff --git a/src/lread.c b/src/lread.c
index 6af95873bb8..5e2389b3a64 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3994,8 +3994,14 @@ read0 (Lisp_Object readcharfun, bool locate_syms)
 	  obj = string_props_from_rev_list (read_stack_pop () ->u.vector.elems,
 					    readcharfun);
 	  break;
-	default:
-	  invalid_syntax (")", readcharfun);
+	case RE_list_dot: /* ( a . ) */
+	case RE_vector: /* [ a ) */
+	case RE_char_table:
+	case RE_sub_char_table:
+	case RE_byte_code:
+	case RE_special:
+	case RE_numbered:
+	default: 	  invalid_syntax (")", readcharfun);
 	}
       break;
 
@@ -4032,8 +4038,14 @@ read0 (Lisp_Object readcharfun, bool locate_syms)
 	  obj = sub_char_table_from_rev_list (read_stack_pop ()->u.vector.elems,
 					      readcharfun);
 	  break;
-	default:
-	  invalid_syntax ("]", readcharfun);
+	case RE_list_start:
+	case RE_list:
+	case RE_list_dot:
+	case RE_record:
+	case RE_string_props:
+	case RE_special:
+	case RE_numbered:
+	default: 	  invalid_syntax ("]", readcharfun);
 	  break;
 	}
       break;
@@ -4695,8 +4707,14 @@ substitute_object_recurse (struct subst *subst, Lisp_Object subtree)
       }
 
       /* Other types don't recurse any further.  */
-    default:
+    case Lisp_Int0:
+    case Lisp_Int1:
+    case Lisp_Float:
+    case Lisp_Symbol:
       return subtree;
+
+    case Lisp_Type_Unused0:
+    default: eassume (0);
     }
 }
 
diff --git a/src/pdumper.c b/src/pdumper.c
index dee13fb9a81..9918a690e58 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -178,19 +178,35 @@ #define dump_offsetof(type, member)                             \
     /* dump_ptr = dump_ptr + dump_base  */
     RELOC_DUMP_TO_DUMP_PTR_RAW,
     /* dump_mpz = [rebuild bignum]  */
+#ifdef HAVE_NATIVE_COMP
     RELOC_NATIVE_COMP_UNIT,
     RELOC_NATIVE_SUBR,
+#endif
     RELOC_BIGNUM,
     /* dump_lv = make_lisp_ptr (dump_lv + dump_base,
 				type - RELOC_DUMP_TO_DUMP_LV)
        (Special case for symbols: make_lisp_symbol)
        Must be second-last.  */
     RELOC_DUMP_TO_DUMP_LV,
+    RELOC_DUMP_TO_DUMP_LV1,
+    RELOC_DUMP_TO_DUMP_LV2,
+    RELOC_DUMP_TO_DUMP_LV3,
+    RELOC_DUMP_TO_DUMP_LV4,
+    RELOC_DUMP_TO_DUMP_LV5,
+    RELOC_DUMP_TO_DUMP_LV6,
+    RELOC_DUMP_TO_DUMP_LV7,
     /* dump_lv = make_lisp_ptr (dump_lv + emacs_basis(),
 				type - RELOC_DUMP_TO_DUMP_LV)
        (Special case for symbols: make_lisp_symbol.)
        Must be last.  */
     RELOC_DUMP_TO_EMACS_LV = RELOC_DUMP_TO_DUMP_LV + 8,
+    RELOC_DUMP_TO_EMACS_LV1,
+    RELOC_DUMP_TO_EMACS_LV2,
+    RELOC_DUMP_TO_EMACS_LV3,
+    RELOC_DUMP_TO_EMACS_LV4,
+    RELOC_DUMP_TO_EMACS_LV5,
+    RELOC_DUMP_TO_EMACS_LV6,
+    RELOC_DUMP_TO_EMACS_LV7,
   };
 
 enum emacs_reloc_type
@@ -1445,6 +1461,9 @@ dump_reloc_dump_to_dump_lv (struct dump_context *ctx,
     case Lisp_Float:
       reloc_type = RELOC_DUMP_TO_DUMP_LV + type;
       break;
+    case Lisp_Type_Unused0: eassume (0);
+    case Lisp_Int0:
+    case Lisp_Int1:
     default:
       emacs_abort ();
     }
@@ -1494,8 +1513,12 @@ dump_reloc_dump_to_emacs_lv (struct dump_context *ctx,
     case Lisp_Float:
       reloc_type = RELOC_DUMP_TO_EMACS_LV + type;
       break;
+    case Lisp_Symbol:
+    case Lisp_Int0:
+    case Lisp_Int1:
     default:
       emacs_abort ();
+    case Lisp_Type_Unused0: eassume (0);
     }
 
   dump_push (&ctx->dump_relocs[EARLY_RELOCS],
@@ -1817,8 +1840,12 @@ dump_field_lv_or_rawptr (struct dump_context *ctx,
         case Lisp_Float:
           value = make_lisp_ptr (ptrval, *ptr_raw_type);
           break;
-        default:
-          emacs_abort ();
+	case Lisp_Int0:
+	case Lisp_Int1:
+	  emacs_abort ();
+
+	case Lisp_Type_Unused0: eassume (0);
+        default: eassume (0);
         }
     }
 
@@ -2392,8 +2419,7 @@ dump_fwd (struct dump_context *ctx, lispfwd fwd)
     case Lisp_Fwd_Kboard_Obj:
       offset = dump_fwd_kboard_obj (ctx, p);
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   return offset;
@@ -2458,8 +2484,10 @@ dump_pre_dump_symbol (struct dump_context *ctx, struct Lisp_Symbol *symbol)
       dump_remember_symbol_aux (ctx, symbol_lv,
 				dump_fwd (ctx, symbol->u.s.val.fwd));
       break;
-    default:
+    case SYMBOL_PLAINVAL:
+    case SYMBOL_VARALIAS:
       break;
+    default: eassume (0);
     }
   dump_clear_referrer (ctx);
 }
@@ -2524,8 +2552,7 @@ dump_symbol (struct dump_context *ctx,
     case SYMBOL_FORWARDED:
       dump_field_fixup_later (ctx, &out, symbol, &symbol->u.s.val.fwd);
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
   dump_field_lv (ctx, &out, symbol, &symbol->u.s.function, WEIGHT_NORMAL);
   dump_field_lv (ctx, &out, symbol, &symbol->u.s.plist, WEIGHT_NORMAL);
@@ -2555,8 +2582,10 @@ dump_symbol (struct dump_context *ctx,
 	  ? aux_offset
 	  : dump_fwd (ctx, symbol->u.s.val.fwd)));
       break;
-    default:
+    case SYMBOL_PLAINVAL:
+    case SYMBOL_VARALIAS:
       break;
+    default: eassume (0);
     }
   return offset;
 }
@@ -3142,10 +3171,11 @@ dump_vectorlike (struct dump_context *ctx,
     case PVEC_SQLITE:
     case PVEC_MODULE_FUNCTION:
     case PVEC_SYMBOL_WITH_POS:
-    case PVEC_FREE:
     case PVEC_TS_PARSER:
     case PVEC_TS_NODE:
       break;
+    case PVEC_FREE: eassume (0);
+    default: eassume (0);
     }
   int iptype = ptype;
   static char const fmt[] = "pseudovector type %d";
@@ -3248,8 +3278,9 @@ dump_object (struct dump_context *ctx, Lisp_Object object)
     case Lisp_Int1:
       eassert ("should not be dumping int: is self-representing" && 0);
       abort ();
-    default:
-      emacs_abort ();
+    case Lisp_Type_Unused0:
+      eassume (0);
+    default: eassume (0);
     }
   dump_clear_referrer (ctx);
 
@@ -3605,8 +3636,7 @@ dump_drain_cold_data (struct dump_context *ctx)
 	  dump_cold_native_subr (ctx, data);
 	  break;
 #endif
-        default:
-          emacs_abo
rt ();
+        default: eassume (0);
         }
     }
 
@@ -3633,8 +3663,12 @@ read_ptr_raw_and_lv (const void *mem,
         case Lisp_Float:
           *out_lv = make_lisp_ptr (*out_ptr, type);
           break;
-        default:
-          emacs_abort ();
+	case Lisp_Int0:
+	case Lisp_Int1:
+	  emacs_abort ();
+	case Lisp_Type_Unused0:
+	  eassume (0);
+	default: eassume (0);
         }
     }
 }
@@ -3886,8 +3920,7 @@ decode_emacs_reloc (struct dump_context *ctx, Lisp_Object lreloc)
           }
       }
       break;
-    default:
-      eassume (!"not reached");
+    default: eassume (0);
     }
 
   /* We should have consumed the whole relocation descriptor.  */
@@ -4071,8 +4104,7 @@ dump_do_fixup (struct dump_context *ctx,
         do_write = false;
         break;
       }
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
   if (do_write)
     dump_write (ctx, &dump_value, sizeof (dump_value));
@@ -4523,8 +4555,7 @@ dump_anonymous_allocate_w32 (void *base,
       mem_type = MEM_COMMIT;
       mem_prot = PAGE_READWRITE;
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   ret = VirtualAlloc (base, size, mem_type, mem_prot);
@@ -4563,8 +4594,7 @@ dump_anonymous_allocate_posix (void *base,
     case DUMP_MEMORY_ACCESS_READWRITE:
       mem_prot = PROT_READ | PROT_WRITE;
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   int mem_flags = MAP_PRIVATE | MAP_ANONYMOUS;
@@ -4657,11 +4687,11 @@ dump_map_file_w32 (void *base, int fd, off_t offset, size_t size,
     case DUMP_MEMORY_ACCESS_READWRITE:
       protect = PAGE_WRITECOPY;	/* for Windows 9X */
       break;
-    default:
     case DUMP_MEMORY_ACCESS_NONE:
     case DUMP_MEMORY_ACCESS_READ:
       protect = PAGE_READONLY;
       break;
+    default: eassume (0);
     }
 
   section = CreateFileMapping (file,
@@ -4685,8 +4715,7 @@ dump_map_file_w32 (void *base, int fd, off_t offset, size_t size,
     case DUMP_MEMORY_ACCESS_READWRITE:
       map_access = FILE_MAP_COPY;
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   ret = MapViewOfFileEx (section,
@@ -4729,8 +4758,7 @@ dump_map_file_posix (void *base, int fd, off_t offset, size_t size,
       mem_prot = PROT_READ | PROT_WRITE;
       mem_flags = MAP_PRIVATE;
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   if (base)
@@ -5531,13 +5559,16 @@ dump_do_dump_relocation (const uintptr_t dump_base,
         mpz_roinit_n (bignum->value, limbs, reload_info.nlimbs);
         break;
       }
-    default: /* Lisp_Object in the dump; precise type in reloc.type */
+    case RELOC_DUMP_TO_DUMP_LV ... RELOC_DUMP_TO_DUMP_LV + 7:
+    case RELOC_DUMP_TO_EMACS_LV ... RELOC_DUMP_TO_EMACS_LV + 7:
+      /* Lisp_Object in the dump; precise type in reloc.type */
       {
         Lisp_Object lv = dump_make_lv_from_reloc (dump_base, reloc);
         eassert (dump_reloc_size (reloc) == sizeof (lv));
         dump_write_lv_to_dump (dump_base, reloc_offset, lv);
         break;
       }
+    default: eassume (0);
     }
 }
 
@@ -5597,8 +5628,7 @@ dump_do_emacs_relocation (const uintptr_t dump_base,
         memcpy (emacs_ptr_at (reloc.emacs_offset), &lv, sizeof (lv));
         break;
       }
-    default:
-      fatal ("unrecognied relocation type %d", (int) reloc.type);
+    default: eassume (0);
     }
 }
 
diff --git a/src/print.c b/src/print.c
index c7cba5bface..a2537fcf759 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1461,8 +1461,12 @@ print_preprocess (Lisp_Object obj)
 		    break;
 		  }
 
-		default:
-		  break;
+		case Lisp_Symbol:
+		case Lisp_Type_Unused0:
+		case Lisp_Int0:
+		case Lisp_Int1:
+		case Lisp_Float:
+		default: 		  break;
 		}
 	    }
 	}
@@ -2103,9 +2107,9 @@ print_vectorlike_unreadable (Lisp_Object obj, Lisp_Object printcharfun,
     case PVEC_BIGNUM:
     case PVEC_BOOL_VECTOR:
     /* Impossible cases.  */
-    case PVEC_FREE:
     case PVEC_OTHER:
       break;
+    case PVEC_FREE: eassume (0);
     }
   emacs_abort ();
 }
@@ -2640,14 +2644,44 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
 	  print_bool_vector (obj, printcharfun);
 	  break;
 
-	default:
-	  print_vectorlike_unreadable (obj, printcharfun, escapeflag, buf);
+	case PVEC_MARKER:
+	case PVEC_OVERLAY:
+	case PVEC_FINALIZER:
+	case PVEC_SYMBOL_WITH_POS:
+	case PVEC_MISC_PTR:
+	case PVEC_USER_PTR:
+	case PVEC_PROCESS:
+	case PVEC_FRAME:
+	case PVEC_WINDOW:
+	case PVEC_BUFFER:
+	case PVEC_OBARRAY:
+	case PVEC_TERMINAL:
+	case PVEC_WINDOW_CONFIGURATION:
+	case PVEC_SUBR:
+	case PVEC_OTHER:
+	case PVEC_XWIDGET:
+	case PVEC_XWIDGET_VIEW:
+	case PVEC_THREAD:
+	case PVEC_MUTEX:
+	case PVEC_CONDVAR:
+	case PVEC_MODULE_FUNCTION:
+	case PVEC_NATIVE_COMP_UNIT:
+	case PVEC_TS_PARSER:
+	case PVEC_TS_NODE:
+	case PVEC_TS_COMPILED_QUERY:
+	case PVEC_SQLITE:
+	case PVEC_FONT:
+	default: 	  print_vectorlike_unreadable (obj, printcharfun, escapeflag, buf);
 	  break;
+
+	case PVEC_FREE: eassume (0);
 	}
 	break;
 
-    default:
-      emacs_abort ();
+    case Lisp_Type_Unused0:
+      eassume (0);
+
+    default: emacs_abort ();
     }
   print_depth--;
 
diff --git a/src/process.c b/src/process.c
index 807f06f990b..00944710128 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2949,8 +2949,8 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val)
       }
 #endif
 
-    default:
-      return 0;
+    case SOPT_UNKNOWN:
+    default: return 0;
     }
 
   if (ret < 0)
diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index d3017f46751..e568b4638f4 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -2907,9 +2907,36 @@ forall_firstchar_1 (re_char *p, re_char *pend,
 	      case succeed_n:
 	        newp2 = extract_address (newp1 + 1);
 	        goto do_twoway_jump;
-	      default:
+	      case no_op:
 	        newp2 = loop_end; /* "Safe" choice.  */
 	        goto do_jump;
+	      case succeed:
+	      case exactn:
+	      case anychar:
+	      case charset:
+	      case charset_not:
+	      case start_memory:
+	      case stop_memory:
+	      case duplicate:
+	      case begline:
+	      case endline:
+	      case begbuf:
+	      case endbuf:
+	      case jump:
+	      case jump_n:
+	      case set_number_at:
+	      case wordbeg:
+	      case wordend:
+	      case wordbound:
+	      case notwordbound:
+	      case symbeg:
+	      case symend:
+	      case syntaxspec:
+	      case notsyntaxspec:
+	      case at_dot:
+	      case categoryspec:
+	      case notcategoryspec:
+	      default: eassume (0);
 	      }
 
 	  case on_failure_jump:
@@ -3221,7 +3248,18 @@ analyze_first_fastmap (const re_char *p, void *arg)
     case symend:
       /* This false doesn't mean failure but rather "not succeeded yet".  */
       return false;
-
+    case no_op:
+    case start_memory:
+    case stop_memory:
+    case jump:
+    case on_failure_jump:
+    case on_failure_keep_string_jump:
+    case on_failure_jump_loop:
+    case on_failure_jump_nastyloop:
+    case on_failure_jump_smart:
+    case succeed_n:
+    case jump_n:
+    case set_number_at:
     default:
 #if ENABLE_CHECKING
       abort (); /* We have listed all the cases.  */
@@ -3270,6 +3308,18 @@ analyze_first_null (const re_char *p, void *arg)
       /* This false doesn't mean failure but rather "not succeeded yet".  */
       return false;
 
+    case no_op:
+    case start_memory:
+    case stop_memory:
+    case jump:
+    case on_failure_jump:
+    case on_failure_keep_string_jump:
+    case on_failure_jump_loop:
+    case on_failure_jump_nastyloop:
+    case on_failure_jump_smart:
+    case succeed_n:
+    case jump_n:
+    case set_number_at:
     default:
 #if ENABLE_CHECKING
       abort (); /* We have listed all the cases.  */
@@ -3739,8 +3789,32 @@ skip_one_char (re_char *p)
       p++;
       break;
 
-    default:
-      p = NULL;
+    case no_op:
+    case succeed:
+    case start_memory:
+    case stop_memory:
+    case duplicate:
+    case begline:
+    case endline:
+    case begbuf:
+    case endbuf:
+    case jump:
+    case on_failure_jump:
+    case on_failure_keep_string_jump:
+    case on_failure_jump_loop:
+    case on_failure_jump_nastyloop:
+    case on_failure_jump_smart:
+    case succeed_n:
+    case jump_n:
+    case set_number_at:
+    case wordbeg:
+    case wordend:
+    case wordbound:
+    case notwordbound:
+    case symbeg:
+    case symend:
+    case at_dot:
+    default: p = NULL;
     }
   return p;
 }
@@ -3974,6 +4048,37 @@ #define RETURN_CONSTRAIN(v)        \
 	     chars should cover all possible chars, which, as a matter of
 	     fact, is virtually impossible in multibyte buffers.  */
 	  return false;
+	case no_op:
+	case succeed:
+	case anychar:
+	case start_memory:
+	case stop_memory:
+	case duplicate:
+	case begline:
+	case endline:
+	case begbuf:
+	case endbuf:
+	case jump:
+	case on_failure_jump:
+	case on_failure_keep_string_jump:
+	case on_failure_jump_loop:
+	case on_failure_jump_nastyloop:
+	case on_failure_jump_smart:
+	case succeed_n:
+	case jump_n:
+	case set_number_at:
+	case wordbeg:
+	case wordend:
+	case wordbound:
+	case notwordbound:
+	case symbeg:
+	case symend:
+	case syntaxspec:
+	case notsyntaxspec:
+	case at_dot:
+	case categoryspec:
+	case notcategoryspec:
+	  break;
 	}
       return false;
     case anychar:
@@ -4011,6 +4116,18 @@ #define RETURN_CONSTRAIN(v)        \
       /* At this point, we know nothing about what this can match, sadly.  */
       return false;
 
+    case no_op:
+    case start_memory:
+    case stop_memory:
+    case jump:
+    case on_failure_jump:
+    case on_failure_keep_string_jump:
+    case on_failure_jump_loop:
+    case on_failure_jump_nastyloop:
+    case on_failure_jump_smart:
+    case succeed_n:
+    case jump_n:
+    case set_number_at:
     default:
 #if ENABLE_CHECKING
       abort (); /* We have listed all the cases.  */
@@ -5225,8 +5342,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
 	  }
 	  break;
 
-	default:
-	  abort ();
+	default: 	  abort ();
 	}
       continue;  /* Successfully executed one pattern command; keep going.  */
 
@@ -5262,8 +5378,34 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
 	      /* A special frame used for nastyloops. */
 	      goto fail;
 
-	    default:
-	      abort ();
+	    case succeed:
+	    case exactn:
+	    case anychar:
+	    case charset:
+	    case charset_not:
+	    case start_memory:
+	    case stop_memory:
+	    case duplicate:
+	    case begline:
+	    case endline:
+	    case begbuf:
+	    case endbuf:
+	    case jump:
+	    case on_failure_jump_smart:
+	    case jump_n:
+	    case set_number_at:
+	    case wordbeg:
+	    case wordend:
+	    case wordbound:
+	    case notwordbound:
+	    case symbeg:
+	    case symend:
+	    case syntaxspec:
+	    case notsyntaxspec:
+	    case at_dot:
+	    case categoryspec:
+	    case notcategoryspec:
+	    default: 	      abort ();
 	    }
 
 	  eassert (p >= bufp->buffer && p <= pend);
diff --git a/src/syntax.c b/src/syntax.c
index 91dbe6a5f83..56db5c484fb 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -882,8 +882,18 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
 	    }
 	  break;
 
-	default:
+	case Swhitespace:
+	case Spunct:
+	case Sword:
+	case Ssymbol:
+	case Sclose:
+	case Squote:
+	case Smath:
+	case Sescape:
+	case Scharquote:
+	case Sinherit:
 	  break;
+	default: 	  eassume (0);
 	}
     }
 
@@ -1399,9 +1409,7 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value,
       insert_string ("comment fence"); break;
     case Sstring_fence:
       insert_string ("string fence"); break;
-    default:
-      insert_string ("invalid");
-      return syntax;
+    default: eassume (0);
     }
 
   if (!NILP (match_lisp))
@@ -2738,8 +2746,19 @@ scan_lists (EMACS_INT from0, EMACS_INT count, EMACS_INT depth, bool sexpflag)
 		    case Ssymbol:
 		    case Squote:
 		      break;
-		    default:
+		    case Swhitespace:
+		    case Spunct:
+		    case Sopen:
+		    case Sclose:
+		    case Sstring:
+		    case Smath:
+		    case Scomment:
+		    case Sendcomment:
+		    case Sinherit:
+		    case Scomment_fence:
+		    case Sstring_fence:
 		      goto done;
+		    default: 		      eassume (0);
 		    }
 		  inc_both (&from, &from_byte);
 		  rarely_quit (++quit_count);
@@ -2819,9 +2838,14 @@ scan_lists (EMACS_INT from0, EMACS_INT count, EMACS_INT depth, bool sexpflag)
 	      inc_both (&from, &from_byte);
 	      if (!depth && sexpflag) goto done;
 	      break;
-	    default:
+	    case Swhitespace:
+	    case Spunct:
+	    case Squote:
+	    case Sendcomment:
+	    case Sinherit:
 	      /* Ignore whitespace, punctuation, quote, endcomment.  */
 	      break;
+	    default: 	      eassume (0);
 	    }
 	}
 
@@ -2909,7 +2933,21 @@ scan_lists (EMACS_INT from0, EMACS_INT count, EMACS_INT depth, bool sexpflag)
 		    switch (syntax_multibyte (c1, multibyte_symbol_p))
 		      {
 		      case Sword: case Ssymbol: case Squote: break;
-		      default: goto done2;
+		      case Spunct:
+		      case Sopen:
+		      case Sclose:
+		      case Sstring:
+		      case Smath:
+		      case Sescape:
+		      case Scharquote:
+		      case Scomment:
+		      case Sendcomment:
+		      case Sinherit:
+		      case Scomment_fence:
+		      case Sstring_fence:
+		      case Swhitespace:
+			goto done2;
+		      default: eassume (0);
 		      }
 		  dec_both (&from, &from_byte);
 		  rarely_quit (++quit_count);
@@ -3000,9 +3038,14 @@ scan_lists (EMACS_INT from0, EMACS_INT count, EMACS_INT depth, bool sexpflag)
 		}
 	      if (!depth && sexpflag) goto done2;
 	      break;
-	    default:
+	    case Spunct:
+	    case Squote:
+	    case Scomment:
+	    case Sinherit:
+	    case Swhitespace:
 	      /* Ignore whitespace, punctuation, quote, endcomment.  */
 	      break;
+	    default: 	      eassume (0);
 	    }
 	}
 
@@ -3304,8 +3347,19 @@ #define INC_FROM				\
 		case Ssymbol:
 		case Squote:
 		  break;
-		default:
+		case Spunct:
+		case Sopen:
+		case Sclose:
+		case Sstring:
+		case Smath:
+		case Scomment:
+		case Sendcomment:
+		case Sinherit:
+		case Scomment_fence:
+		case Sstring_fence:
+		case Swhitespace:
 		  goto symdone;
+		default: 		  eassume (0);
 		}
 	      INC_FROM;
 	      rarely_quit (++quit_count);
@@ -3422,8 +3476,21 @@ #define INC_FROM				\
 		    if (from >= end) goto endquoted;
 		    break;
 
-		  default:
+		  case Spunct:
+		  case Sword:
+		  case Ssymbol:
+		  case Sopen:
+		  case Sclose:
+		  case Squote:
+		  case Sstring:
+		  case Smath:
+		  case Scomment:
+		  case Sendcomment:
+		  case Sinherit:
+		  case Scomment_fence:
+		  case Swhitespace:
 		    break;
+		  default: 		    eassume (0);
 		  }
 		INC_FROM;
 		rarely_quit (++quit_count);
@@ -3439,9 +3506,14 @@ #define INC_FROM				\
 	case Smath:
 	  /* FIXME: We should do something with it.  */
 	  break;
-	default:
+	case Spunct:
+	case Squote:
+	case Sendcomment:
+	case Sinherit:
+	case Swhitespace:
 	  /* Ignore whitespace, punctuation, quote, endcomment.  */
 	  break;
+	default: 	  eassume (0);
 	}
     }
   goto done;
diff --git a/src/syntax.h b/src/syntax.h
index 354b116bfd1..c2c14d686b4 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -59,9 +59,10 @@ #define Vstandard_syntax_table BVAR (&buffer_defaults, syntax_table)
 		       other side by any char with the same syntaxcode.  */
     Sstring_fence,  /* Starts/ends string which is delimited on the
 		       other side by any char with the same syntaxcode.  */
-    Smax	 /* Upper bound on codes that are meaningful.  */
+    Smaxm1 = Sstring_fence	 /* Upper bound on codes that are meaningful.  */
   };
 
+#define Smax (Smaxm1 + 1)
 
 struct gl_state_s
 {
diff --git a/src/sysdep.c b/src/sysdep.c
index a161b4af100..a3051c4978b 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2520,7 +2520,7 @@ emacs_fopen (char const *file, char const *mode)
     case 'r': omode = O_RDONLY; oflags = 0; break;
     case 'w': omode = O_WRONLY; oflags = O_CREAT | O_TRUNC; break;
     case 'a': omode = O_WRONLY; oflags = O_CREAT | O_APPEND; break;
-    default: emacs_abort ();
+    default: eassume (0);
     }
 
   while (*m)
diff --git a/src/term.c b/src/term.c
index f307d709316..5cb545d8632 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3476,6 +3476,8 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
 		first_item--;
 	      leave = 0;
 	      break;
+	    case MI_CONTINUE:
+	    case MI_ITEM_SELECTED:
 	    default:
 	      /* MI_ITEM_SELECTED is handled below, so nothing to do.  */
 	      break;
diff --git a/src/textconv.c b/src/textconv.c
index 105a8077072..fe269aee8d7 100644
--- a/src/textconv.c
+++ b/src/textconv.c
@@ -267,9 +267,15 @@ textconv_query (struct frame *f, struct textconv_callback_struct *query,
 	      pos = end;
 	      break;
 
-	    default:
+	    case TEXTCONV_BACKWARD_CHAR:
+	    case TEXTCONV_BACKWARD_WORD:
+	    case TEXTCONV_CARET_UP:
+	    case TEXTCONV_PREVIOUS_LINE:
+	    case TEXTCONV_LINE_END:
+	    case TEXTCONV_ABSOLUTE_POSITION:
 	      pos = max (BEGV, start - 1);
 	      break;
+	    default: 	      eassume (0);
 	    }
 	}
     }
@@ -433,8 +439,8 @@ textconv_query (struct frame *f, struct textconv_callback_struct *query,
 	  return 1;
 	}
 
-    default:
-      break;
+    case TEXTCONV_RETRIEVAL:
+    default: break;
     }
 
   /* Undo any changes to the excursion.  */
diff --git a/src/timefns.c b/src/timefns.c
index aab4dbb9206..db5eaa7a25c 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -577,8 +577,9 @@ decode_ticks_hz (Lisp_Object ticks, Lisp_Object hz, enum cform cform)
     case CFORM_TICKS_HZ:
       return (union c_time) { .th = { .ticks = ticks, .hz = hz } };
 
-    default:
-      return (union c_time) { .ts = ticks_hz_to_timespec (ticks, hz) };
+    case CFORM_TIMESPEC:
+    case CFORM_SECS_ONLY:
+    default: return (union c_time) { .ts = ticks_hz_to_timespec (ticks, hz) };
     }
 }
 
diff --git a/src/treesit.c b/src/treesit.c
index 62606d99749..8bf18f9defb 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -1457,8 +1457,9 @@ treesit_query_error_to_string (TSQueryError error)
       return "Capture error at";
     case TSQueryErrorStructure:
       return "Structure error at";
-    default:
-      return "Unknown error";
+    case TSQueryErrorLanguage:
+      return "Language error at";
+    default: return "Unknown error";
     }
 }
 
diff --git a/src/xdisp.c b/src/xdisp.c
index 36e82f873ab..9a167ff453f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2961,6 +2961,8 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       height = WINDOW_BOTTOM_DIVIDER_WIDTH (w);
       goto add_edge;
 
+    case ON_NOTHING:
+    case ON_HORIZONTAL_SCROLL_BAR: /* FIXME: is this right? */
     default:
       ;
     virtual_glyph:
@@ -11028,8 +11030,9 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos
 	    it->continuation_lines_width += it->current_x;
 	  break;
 
-	default:
-	  emacs_abort ();
+	case MOVE_UNDEFINED:
+	case MOVE_X_REACHED:
+	default: 	  emacs_abort ();
 	}
 
       /* Reset/increment for the next run.  */
@@ -20528,8 +20531,9 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
 	case CURSOR_MOVEMENT_MUST_SCROLL:
 	  goto try_to_scroll;
 
-	default:
-	  emacs_abort ();
+	case CURSOR_MOVEMENT_CANNOT_BE_USED:
+	case CURSOR_MOVEMENT_NEED_LARGER_MATRICES:
+	default: 	  emacs_abort ();
 	}
     }
   /* If current starting point was originally the beginning of a line
@@ -26362,6 +26366,7 @@ DEFUN ("current-bidi-paragraph-direction", Fcurrent_bidi_paragraph_direction,
 	case R2L:
 	  return Qright_to_left;
 	  break;
+	case NEUTRAL_DIR: /* Is this right? */
 	default:
 	  emacs_abort ();
 	}
@@ -28155,8 +28160,14 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
       }
       break;
 
-    default:
-    invalid:
+    case Lisp_Type_Unused0:
+      eassume (0);
+
+    case Lisp_Int0:
+    case Lisp_Int1:
+    case Lisp_Vectorlike:
+    case Lisp_Float:
+    default: invalid:
       elt = build_string ("*invalid*");
       goto tail_recurse;
     }
diff --git a/src/xfaces.c b/src/xfaces.c
index fbbaffb8889..6a701f89cd3 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1334,8 +1334,21 @@ load_color2 (struct frame *f, struct face *face, Lisp_Object name,
 	  color->pixel = FRAME_FOREGROUND_PIXEL (f);
 	  break;
 
-	default:
-	  emacs_abort ();
+	case LFACE_FAMILY_INDEX:
+	case LFACE_FOUNDRY_INDEX:
+	case LFACE_SWIDTH_INDEX:
+	case LFACE_HEIGHT_INDEX:
+	case LFACE_WEIGHT_INDEX:
+	case LFACE_SLANT_INDEX:
+	case LFACE_INVERSE_INDEX:
+	case LFACE_STIPPLE_INDEX:
+	case LFACE_FONT_INDEX:
+	case LFACE_INHERIT_INDEX:
+	case LFACE_FONTSET_INDEX:
+	case LFACE_DISTANT_FOREGROUND_INDEX:
+	case LFACE_EXTEND_INDEX:
+	case LFACE_VECTOR_SIZE:
+	default: 	  emacs_abort ();
 	}
     }
 #ifdef GLYPH_DEBUG
@@ -1615,8 +1628,19 @@ DEFUN ("x-family-fonts", Fx_family_fonts, Sx_family_fonts, 0, 2, 0,
 	font_props_for_sorting[i] = FONT_SIZE_INDEX; break;
       case XLFD_WEIGHT:
 	font_props_for_sorting[i] = FONT_WEIGHT_INDEX; break;
-      default:
-	font_props_for_sorting[i] = FONT_SLANT_INDEX; break;
+      case XLFD_FOUNDRY:
+      case XLFD_FAMILY:
+      case XLFD_SLANT:
+      case XLFD_ADSTYLE:
+      case XLFD_PIXEL_SIZE:
+      case XLFD_RESX:
+      case XLFD_RESY:
+      case XLFD_SPACING:
+      case XLFD_AVGWIDTH:
+      case XLFD_REGISTRY:
+      case XLFD_ENCODING:
+      case XLFD_LAST:
+      default: 	font_props_for_sorting[i] = FONT_SLANT_INDEX; break;
       }
   font_props_for_sorting[i++] = FONT_FAMILY_INDEX;
   font_props_for_sorting[i++] = FONT_FOUNDRY_INDEX;
@@ -4430,8 +4454,12 @@ face_attr_equal_p (Lisp_Object v1, Lisp_Object v2)
     case Lisp_Symbol:
       return false;
 
-    default:
-      return !NILP (Fequal (v1, v2));
+    case Lisp_Type_Unused0:
+      eassume (0);
+    case Lisp_Vectorlike:
+    case Lisp_Cons:
+    case Lisp_Float:
+    default: return !NILP (Fequal (v1, v2));
     }
 }
 
@@ -5138,8 +5166,8 @@ lookup_basic_face (struct window *w, struct frame *f, int face_id)
     case INTERNAL_BORDER_FACE_ID:	name = Qinternal_border; 	break;
     case CHILD_FRAME_BORDER_FACE_ID:	name = Qchild_frame_border; 	break;
 
-    default:
-      emacs_abort (); /* the caller is supposed to pass us a basic face id */
+    case BASIC_FACE_ID_SENTINEL:
+    default: emacs_abort (); /* the caller is supposed to pass us a basic face id */
     }
 
   /* Do a quick scan through Vface_remapping_alist, and return immediately
@@ -6611,8 +6639,24 @@ map_tty_color (struct frame *f, struct face *face, Lisp_Object color,
       face->underline_color = pixel;
       break;
     case LFACE_BACKGROUND_INDEX:
-    default:
-      face->background = pixel;
+    case LFACE_FAMILY_INDEX:
+    case LFACE_FOUNDRY_INDEX:
+    case LFACE_SWIDTH_INDEX:
+    case LFACE_HEIGHT_INDEX:
+    case LFACE_WEIGHT_INDEX:
+    case LFACE_SLANT_INDEX:
+    case LFACE_INVERSE_INDEX:
+    case LFACE_STIPPLE_INDEX:
+    case LFACE_OVERLINE_INDEX:
+    case LFACE_STRIKE_THROUGH_INDEX:
+    case LFACE_BOX_INDEX:
+    case LFACE_FONT_INDEX:
+    case LFACE_INHERIT_INDEX:
+    case LFACE_FONTSET_INDEX:
+    case LFACE_DISTANT_FOREGROUND_INDEX:
+    case LFACE_EXTEND_INDEX:
+    case LFACE_VECTOR_SIZE:
+    default: face->background = pixel;
       break;
     }
 }
diff --git a/src/xfns.c b/src/xfns.c
index ec7d54180e4..2cfcba6f29a 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3379,8 +3379,14 @@ xic_preedit_caret_callback (XIC xic, XPointer client_data,
 	case XIMBackwardWord:
 	  call_data->position = max (0, output->preedit_caret--);
 	  break;
-	default:
-	  call_data->position = output->preedit_caret;
+	case XIMCaretUp:
+	case XIMCaretDown:
+	case XIMNextLine:
+	case XIMPreviousLine:
+	case XIMLineStart:
+	case XIMLineEnd:
+	case XIMDontChange:
+	default: 	  call_data->position = output->preedit_caret;
 	}
 
       if (output->preedit_chars)
@@ -3874,8 +3880,8 @@ xic_string_conversion_callback (XIC ic, XPointer client_data,
       request.direction = TEXTCONV_ABSOLUTE_POSITION;
       break;
 
-    default:
-      goto failure;
+    case XIMDontChange:
+    default: goto failure;
     }
 
   /* factor is signed in call_data but is actually a CARD16.  */
diff --git a/src/xterm.c b/src/xterm.c
index 0a877e9edf9..02c5f03830b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5652,10 +5652,10 @@ xi_populate_device_from_info (struct x_display_info *dpyinfo,
 	      xi_device->direct_p = true;
 	    else
 	      xi_device->direct_p = false;
+	    break;
 	  }
 #endif /* HAVE_XINPUT2_2 */
-	default:
-	  break;
+	default: eassume (0);
 	}
     }
 
@@ -6150,8 +6150,30 @@ x_try_cr_xlib_drawable (struct frame *f, GC gc)
     case CAIRO_SURFACE_TYPE_IMAGE:
       break;
 
-    default:
-      return false;
+    case CAIRO_SURFACE_TYPE_PDF:
+    case CAIRO_SURFACE_TYPE_PS:
+    case CAIRO_SURFACE_TYPE_XCB:
+    case CAIRO_SURFACE_TYPE_GLITZ:
+    case CAIRO_SURFACE_TYPE_QUARTZ:
+    case CAIRO_SURFACE_TYPE_WIN32:
+    case CAIRO_SURFACE_TYPE_BEOS:
+    case CAIRO_SURFACE_TYPE_DIRECTFB:
+    case CAIRO_SURFACE_TYPE_SVG:
+    case CAIRO_SURFACE_TYPE_OS2:
+    case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
+    case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
+    case CAIRO_SURFACE_TYPE_SCRIPT:
+    case CAIRO_SURFACE_TYPE_QT:
+    case CAIRO_SURFACE_TYPE_RECORDING:
+    case CAIRO_SURFACE_TYPE_VG:
+    case CAIRO_SURFACE_TYPE_GL:
+    case CAIRO_SURFACE_TYPE_DRM:
+    case CAIRO_SURFACE_TYPE_TEE:
+    case CAIRO_SURFACE_TYPE_XML:
+    case CAIRO_SURFACE_TYPE_SKIA:
+    case CAIRO_SURFACE_TYPE_SUBSURFACE:
+    case CAIRO_SURFACE_TYPE_COGL:
+    default: return false;
     }
 
   /* FRAME_CR_CONTEXT (f) is an image surface we can not draw into
@@ -10928,8 +10950,7 @@ x_fill_underline (struct frame *f, struct glyph_string *s,
 
     case FACE_NO_UNDERLINE:
     case FACE_UNDERLINE_WAVE:
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 }
 
@@ -15862,8 +15883,18 @@ xg_scroll_callback (GtkRange *range, GtkScrollType scroll,
 	      ? scroll_bar_after_handle : scroll_bar_below_handle);
       bar->dragging = -1;
       break;
-    default:
-      break;
+case GTK_SCROLL_NONE:
+case GTK_SCROLL_STEP_UP:
+case GTK_SCROLL_STEP_DOWN:
+case GTK_SCROLL_PAGE_UP:
+case GTK_SCROLL_PAGE_DOWN:
+case GTK_SCROLL_STEP_LEFT:
+case GTK_SCROLL_STEP_RIGHT:
+case GTK_SCROLL_PAGE_LEFT:
+case GTK_SCROLL_PAGE_RIGHT:
+case GTK_SCROLL_START:
+case GTK_SCROLL_END:
+    default: break;
     }
 
   if (part != scroll_bar_nowhere)
@@ -18030,6 +18061,10 @@ x_net_wm_state (struct frame *f, Window window)
     case FULLSCREEN_MAXIMIZED:
       lval = Qmaximized;
       break;
+    case FULLSCREEN_NONE:
+      lval = Qnil;
+      break;
+    default: eassume (0);
     }
 
   store_frame_param (f, Qfullscreen, lval);
@@ -19139,6 +19174,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		    x_dnd_action_symbol = QXdndActionCopy;
 		    break;
 
+		  case XM_DRAG_NOOP:
+		  case XM_DRAG_LINK:
+		  case XM_DRAG_LINK_REC:
 		    /* This means XM_DRAG_OPERATION_IS_LINK (operation).  */
 		  default:
 		    x_dnd_action_symbol = QXdndActionLink;
@@ -26086,8 +26124,9 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
 	      w->phys_cursor_width = 0;
 	      break;
 
-	    default:
+	    case DEFAULT_CURSOR:
 	      emacs_abort ();
+	    default: 	      emacs_abort ();
 	    }
 	}
 
@@ -28259,6 +28298,10 @@ x_handle_net_wm_state (struct frame *f, const XPropertyEvent *event)
     case FULLSCREEN_MAXIMIZED:
       lval = Qmaximized;
       break;
+    case FULLSCREEN_NONE:
+      lval = Qnil;
+      break;
+    default: eassume (0);
     }
 
   store_frame_param (f, Qfullscreen, lval);
@@ -28312,8 +28355,8 @@ x_check_fullscreen (struct frame *f)
           lval = Qfullheight;
           height = x_display_pixel_height (dpyinfo);
 	  break;
-	default:
-	  emacs_abort ();
+	case FULLSCREEN_NONE:
+	default: 	  emacs_abort ();
         }
 
       x_wm_set_size_hint (f, 0, false);
@@ -29919,8 +29962,7 @@ x_get_atom_name (struct x_display_info *dpyinfo, Atom atom,
     case XA_FONT:
       return xstrdup ("FONT");
 
-    default:
-      if (dpyinfo->motif_drag_atom
+    default: if (dpyinfo->motif_drag_atom
 	  && atom == dpyinfo->motif_drag_atom)
 	return xstrdup (dpyinfo->motif_drag_atom_name);
 
diff --git a/src/xwidget.c b/src/xwidget.c
index 4f5b46c692a..c2a29048ea2 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -196,8 +196,7 @@ xw_forward_event_translate (GdkEvent *event, struct xwidget_view *xv,
 	  return 1;
 	}
       return 0;
-    default:
-      return 0;
+    default: eassume (0);
     }
 }
 
@@ -1548,8 +1547,7 @@ xi_translate_notify_detail (int detail)
       return GDK_NOTIFY_NONLINEAR;
     case XINotifyNonlinearVirtual:
       return GDK_NOTIFY_NONLINEAR_VIRTUAL;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 }
 #endif
@@ -2398,8 +2396,8 @@ webkit_create_cb (WebKitWebView *webview,
     case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED:
     case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED:
     case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED:
-    default:
       return NULL;
+    default: eassume (0);
     }
 }
 
@@ -2618,8 +2616,7 @@ webkit_decide_policy_cb (WebKitWebView *webView,
       return FALSE;
       break;
     }
-  default:
-    return FALSE;
+  default: eassume (0);
   }
 }