aboutsummaryrefslogtreecommitdiff
path: root/src/dump_analysis.cpp
diff options
context:
space:
mode:
authorMichael Dusan <michael.dusan@gmail.com>2020-04-01 12:47:50 -0400
committerAndrew Kelley <andrew@ziglang.org>2020-04-01 15:56:00 -0400
commit212e2354b8ab631995b0c25f7cf1d9a3e01fac57 (patch)
treeb5d42acd5308378b995bc97b191c8a4efd240a43 /src/dump_analysis.cpp
parent0f1f56bb69610ea424ac311db72510b474249095 (diff)
downloadzig-212e2354b8ab631995b0c25f7cf1d9a3e01fac57.tar.gz
zig-212e2354b8ab631995b0c25f7cf1d9a3e01fac57.zip
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.
Diffstat (limited to 'src/dump_analysis.cpp')
-rw-r--r--src/dump_analysis.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dump_analysis.cpp b/src/dump_analysis.cpp
index c31438b658..3522dcf6f4 100644
--- a/src/dump_analysis.cpp
+++ b/src/dump_analysis.cpp
@@ -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);