From 214726519d4977e22856bfea1dde5c4778297ed9 Mon Sep 17 00:00:00 2001 From: davedets Date: Fri, 31 Jul 2026 10:21:17 -0700 Subject: [PATCH] Add -Wignored-qualifiers in clang build, and fix one resulting warning. (#10325) 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. (Only 4 more warnings after this one!) This PR adds -Wignored-qualifiers. It detects only one violation: a function whose by-value return type (unsigned) has a const qualifier. Here is the error message: ``` /Users/daviddetlefs/z3/src/math/lp/dioph_eq.cpp:1518:9: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] 1518 | const unsigned sub_index(unsigned k) const { | ^~~~~ ``` Seems worth fixing. --- cmake/compiler_warnings.cmake | 1 + src/math/lp/dioph_eq.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/compiler_warnings.cmake b/cmake/compiler_warnings.cmake index 7a68711bc6..ebabc71dba 100644 --- a/cmake/compiler_warnings.cmake +++ b/cmake/compiler_warnings.cmake @@ -27,6 +27,7 @@ set(CLANG_ONLY_WARNINGS "-Wcast-qual" "-Wimplicit-fallthrough" "-Wextra-semi" + "-Wignored-qualifiers" ) set(MSVC_WARNINGS "/W3") diff --git a/src/math/lp/dioph_eq.cpp b/src/math/lp/dioph_eq.cpp index ba38d2227f..68aafaab6c 100644 --- a/src/math/lp/dioph_eq.cpp +++ b/src/math/lp/dioph_eq.cpp @@ -1515,7 +1515,7 @@ namespace lp { return ret; } - const unsigned sub_index(unsigned k) const { + unsigned sub_index(unsigned k) const { return m_k2s[k]; }