3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-10 16:01:11 +00:00
z3/src/ast/normal_forms
davedets d46fbad3b6
Make implicit switch case fall-throughs explicit (#10284)
This is another PR towards the goal of getting Z3 to compile cleanly
when included via FetchContents into clang-tidy, which uses a pretty
strict set of warnings.

This PR enable the "-Wimplicit-fallthrough" warning, then fix all the
warnings this gets
in the clang build, by:
* Augmenting UNREACHABLE to add __builtin_unreachable(), which
suppresses
warnings for fallthrough in that cse.
* Adding Z3_fallthrough in many cases, to make it clear that
fallthroughs are intentional.
* Adding [[noreturn]] to functions that throw, so the compiler knows
they don't fall through to the next case.
* In a couple of cases, there's a fall-through to a default case, which
does "break", or "return nullptr". In those cases, I duplicated the
action in the preceding case, to make it more self-contained, and robust
in the face of change.

In some cases, I am concerned about whether the warnings are identifying
real bugs. For example, the fall-throughs in these files seem at least a
little suspect:
nnf.cpp
seq_rewriter.cpp
lar_solver.cpp 

while very probably correct, also seem at least a tiny bit suspect.
However, this PR does *not* attempt to change any behavior, only to
silence the warnings. It would be great if somebody with more knowledge
of the code could vet these cases. If vetted, the explicit presence of
the Z3_fallthrough would reassure future readers of the code that the
fall-through is intentional, not accidental.
2026-07-29 09:05:42 -07:00
..
CMakeLists.txt
defined_names.cpp disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
defined_names.h
elim_term_ite.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
elim_term_ite.h
name_exprs.cpp move closure conversion to solver internalization 2026-05-30 18:41:37 -07:00
name_exprs.h
nnf.cpp Make implicit switch case fall-throughs explicit (#10284) 2026-07-29 09:05:42 -07:00
nnf.h
nnf_params.pyg
pull_quant.cpp disable test in tptp, move to native lambdas 2026-06-02 10:38:51 -07:00
pull_quant.h