diff options
| author | Michael Dusan <michael.dusan@gmail.com> | 2020-04-01 12:47:50 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-04-01 15:56:00 -0400 |
| commit | 212e2354b8ab631995b0c25f7cf1d9a3e01fac57 (patch) | |
| tree | b5d42acd5308378b995bc97b191c8a4efd240a43 /src/codegen.cpp | |
| parent | 0f1f56bb69610ea424ac311db72510b474249095 (diff) | |
| download | zig-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/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 616e6360e0..1bc80c8dc7 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3954,8 +3954,9 @@ static void render_async_var_decls(CodeGen *g, Scope *scope) { if (var->did_the_decl_codegen) { render_decl_var(g, var); } - // fallthrough } + ZIG_FALLTHROUGH; + case ScopeIdDecls: case ScopeIdBlock: case ScopeIdDefer: |
