diff options
| author | gingerBill <bill@gingerbill.org> | 2024-06-29 18:56:45 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-06-29 18:56:45 +0100 |
| commit | e8517e2694524a94ee88cf925a4a667fb6575f90 (patch) | |
| tree | 8507b80291c469d2f9794d2ac54097f1f59f6b6b /src/check_stmt.cpp | |
| parent | 96330996a60aec89d2fa94804d9b94613be7c14d (diff) | |
`-strict-style`: enforce `case` to be in the same column as `switch`
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index f2e3b0242..edf2fae39 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1258,6 +1258,20 @@ gb_internal void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags error_line("\tSuggestion: Was '#partial switch' wanted?\n"); } } + + if (build_context.strict_style) { + Token stok = ss->token; + for_array(i, bs->stmts) { + Ast *stmt = bs->stmts[i]; + if (stmt->kind != Ast_CaseClause) { + continue; + } + Token ctok = stmt->CaseClause.token; + if (ctok.pos.column > stok.pos.column) { + error(ctok, "With '-strict-style', 'case' statements must share the same column as the 'switch' token"); + } + } + } } |