3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-13 12:25:37 +00:00
z3/cmake
davedets e05ebe8bef
Towards clean z3 build in clang-tidy: Eliminate zero-length-array warnings. (#9800)
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 one concerns "-Wzero-length-array". Many classes in Z3 use the
"trailing array" idiom: the last field of the class C is a zero-length
array of some type T, and the allocation of an instance adds extra space
for some number of T's (usually the number is held in some other field
of C).

When the flag -Wzero-length-array is used, this gives warnings like:
```
warning: zero size arrays are an extension [-Wzero-length-array]
```
This PR first adds -Wzero-length-array to the CLANG_ONLY_WARNINGS
defined in compiler_warnings.cmake. This causes the warnings to occur in
a normal clang Z3 build. We then make a trailing_array.h, that defines a
TRAILING_ARRAY(type, field) macro. This is defined, on per-comnpiler
basis, to disable such warnings if they're enabled. I chose this route
because the use of the idiom is baked deeply into Z3, so it didn't seem
feasable to consider alternative patterns (like, for example, having the
trailing field be a pointer to a separately allocated array).

The rest of the changes in the PR are uses of this include file and
macro in place of "raw" zero-length arrays.

With these changes, all instances of this warning are removed.
2026-06-11 23:10:42 -07:00
..
modules Bump dotnet example target framework from netcoreapp2.0 to net8.0 (#9531) 2026-05-14 15:17:41 -07:00
check_link_atomic.cmake github action: add riscv64/aarch64/powerpc64 cross compile (#5897) 2022-03-16 07:30:20 -07:00
cmake_uninstall.cmake.in [CMake] Move CMake files into their intended location so the 2017-06-12 11:59:00 +01:00
compiler_lto.cmake clean up CMake code (#5182) 2021-04-14 10:29:15 -07:00
compiler_warnings.cmake Towards clean z3 build in clang-tidy: Eliminate zero-length-array warnings. (#9800) 2026-06-11 23:10:42 -07:00
cxx_compiler_flags_overrides.cmake [CMake] Move CMake files into their intended location so the 2017-06-12 11:59:00 +01:00
git_utils.cmake Use '--tags' rather than '--long' for git describe. Closes #6823 (#7833) 2025-08-29 14:15:38 -07:00
msvc_legacy_quirks.cmake clean up CMake code (#5182) 2021-04-14 10:29:15 -07:00
target_arch_detect.cmake Change from BINARY_DIR to PROJECT_BINARY_DIR 2019-05-15 11:25:40 -07:00
target_arch_detect.cpp set ARM64 if detected under OSX 2022-04-07 08:35:56 +02:00
z3_add_component.cmake cmake: Use FindPython3. (#7019) 2023-11-27 11:20:21 +01:00
z3_add_cxx_flag.cmake [CMake] Change the WARNINGS_AS_ERRORS option from BOOL to STRING 2017-07-09 14:34:30 +01:00
z3_append_linker_flag_list_to_target.cmake mux 2019-06-05 09:06:17 +01:00
Z3Config.cmake.in Fix Z3Config.cmake.in when generating a static library (#5555) 2021-09-17 18:03:10 +01:00