stage1: make C++ switch fallthrough an error
Make fallthrough an error when compiler supports it. This requires a new
macro that is defined with such compilers to be used as a statement, at
all fallthrough sites:
switch (...) {
case 0:
...
ZIG_FALLTHROUGH;
case 1:
...
break;
default:
...
break;
}
If we ever move to C++17 as minimal requirement, then the macro can be
replaced with `[[fallthrough]];` at statement sites.
This commit is contained in:
committed by
Andrew Kelley
parent
0f1f56bb69
commit
212e2354b8
@@ -80,7 +80,7 @@ static void jw_array_elem(JsonWriter *jw) {
|
||||
zig_unreachable();
|
||||
case JsonWriterStateArray:
|
||||
fprintf(jw->f, ",");
|
||||
// fallthrough
|
||||
ZIG_FALLTHROUGH;
|
||||
case JsonWriterStateArrayStart:
|
||||
jw->state[jw->state_index] = JsonWriterStateArray;
|
||||
jw_push_state(jw, JsonWriterStateValue);
|
||||
@@ -134,7 +134,7 @@ static void jw_object_field(JsonWriter *jw, const char *name) {
|
||||
zig_unreachable();
|
||||
case JsonWriterStateObject:
|
||||
fprintf(jw->f, ",");
|
||||
// fallthrough
|
||||
ZIG_FALLTHROUGH;
|
||||
case JsonWriterStateObjectStart:
|
||||
jw->state[jw->state_index] = JsonWriterStateObject;
|
||||
jw_push_state(jw, JsonWriterStateValue);
|
||||
|
||||
Reference in New Issue
Block a user