Bug 1345478 - Make the PrintErrorKind::Error case explicitly unreachable in PrintSingleError; r?bbouvier
This patch explicitly calls MOZ_CRASH() in the switch case
PrintErrorKind::Error that is never reached inside the function
PrintSingleError in the file js/src/jscntxt.cpp.
Explicitly handling all the possible cases avoids the compiler to issue
warnings for them: a non handled case in the switch code that might derive
from additions to the enum class PrintErrorKind can be caught at compile time
rather then having a default switch case for handling it, which instead would
be called at runtime.
MozReview-Commit-ID: ECZlMoLvn2m
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -547,17 +547,17 @@ PrintSingleError(JSContext* cx, FILE* fi
report->column));
prefix = Move(tmp);
}
if (kind != PrintErrorKind::Error) {
const char* kindPrefix = nullptr;
switch (kind) {
case PrintErrorKind::Error:
- break;
+ MOZ_CRASH("unreachable");
case PrintErrorKind::Warning:
kindPrefix = "warning";
break;
case PrintErrorKind::StrictWarning:
kindPrefix = "strict warning";
break;
case PrintErrorKind::Note:
kindPrefix = "note";