mirror of
https://github.com/Z3Prover/z3
synced 2026-07-27 09:22:41 +00:00
Test PR for disabling semicolon warnings (#10169)
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. https://github.com/Z3Prover/z3/pull/10020 deleted a number of unnecessary (and, by a strict interpretation, illegal) semicolons. These were detected by adding -Wextra-semi to CLANG_ONLY_WARNINGS during testing. The PR did not eliminate all such unnecessary/illegal semi-colons; Nikolaj Bjorner argued that some IDEs would be confused by doing so for macro invocations, which otherwise look like function calls. So it left those, and did not include adding -Wextra-semi to CLANG_ONLY_WARNINGS in the PR. I'm worried that not having -Wextra-semi will allow instances of the semis we'd like to eliminate to creep back in. This PR introduces a mechanism to disable the warnings for regions with such macro invocations, and uses that mechanism for one file. If accepted, a subsequent PR would use this mechanism in all the remaining places, so that there is a clean clang build with -Wextra-semi. I verified that: * It compiles cleanly for if the enable/disable macros have null definitions, as they would for non-clang compilations. * It compiles cleanly for a clang build without -Wextra-semis. * It compiles successfully, albeit with *many* warnings, for a clang build with-Wextra-semis -- but none of those errors are for the regions in ast.h where the warning is disabled.
This commit is contained in:
parent
ae190b8b88
commit
e2df18faaf
2 changed files with 65 additions and 0 deletions
60
src/util/manage_warnings.h
Normal file
60
src/util/manage_warnings.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*++
|
||||
Copyright (c) 2006 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
build_warnings.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Macros to control compiler build warnings.
|
||||
|
||||
Author:
|
||||
|
||||
Dave Detlefs 2026-07-20.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#pragma once
|
||||
|
||||
// #define PRAGMA_MACRO(s) _Pragma(s)
|
||||
|
||||
// In some cases, we wish to be able to terminate macros with semicolons,
|
||||
// even when the semi is (strictly speaking) illegal when following the
|
||||
// expansion of the macro. (The macro invocations can look like function
|
||||
// invocations to some IDE's, and the lack of a trailing semi can confuse them.)
|
||||
// In those cases, we add this DUMMY_DECL to the macro; it "consumes" the trailing
|
||||
// semi, making it legal.
|
||||
|
||||
// Standard preprocessor concatenation gymnastics
|
||||
#define CONCAT_IMPL(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_IMPL(x, y)
|
||||
|
||||
#define DUMMY_DECL using CONCAT(__dummy_decl_, __COUNTER__) = int
|
||||
|
||||
#define DO_PRAGMA(x) _Pragma(#x)
|
||||
|
||||
#ifdef __clang__
|
||||
|
||||
#define START_DISABLE_WARNING(s) \
|
||||
_Pragma("clang diagnostic push") \
|
||||
DO_PRAGMA(clang diagnostic ignored #s)
|
||||
|
||||
|
||||
#define END_DISABLE_WARNING \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
DUMMY_DECL
|
||||
|
||||
#define START_DISABLE_EXTRA_SEMI_WARNING START_DISABLE_WARNING(-Wextra-semi)
|
||||
|
||||
#else
|
||||
|
||||
#define START_DISABLE_EXTRA_SEMI_WARNING
|
||||
#define END_DISABLE_WARNING
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue