summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-03-28 17:34:58 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-03-28 23:27:28 +0200
commit1e84c0b8d161e05c19c3aa227cbf7de15cc363a3 (patch)
tree5dc530560ad1fd29a6b764a67b92c1fa06b4c7ad /compilerplugins
parent43cff69eed2657c3287221b4f37a2543eb1b6f98 (diff)
-Werror,-Wunused-but-set-variable
...which was apparently meant as a "Possible debugger breakpoint" in DBG_UTIL-only sw_DebugRedline. The obvious fix is to mark nDummy as volatile, but increment of a volatile variable is deprecated, so replace those with reads of the variable, but which triggered false loplugin:casttovoid so fix that too. Change-Id: I07376e665caa4fd9befaba06d261a50df7a63a10 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132237 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/casttovoid.cxx6
-rw-r--r--compilerplugins/clang/test/casttovoid.cxx2
2 files changed, 8 insertions, 0 deletions
diff --git a/compilerplugins/clang/casttovoid.cxx b/compilerplugins/clang/casttovoid.cxx
index 63f1efdd85a5..bddfcb4da503 100644
--- a/compilerplugins/clang/casttovoid.cxx
+++ b/compilerplugins/clang/casttovoid.cxx
@@ -202,6 +202,9 @@ public:
if (var == nullptr) {
return true;
}
+ if (var->getType().isVolatileQualified()) {
+ return true;
+ }
auto & usage = vars_[var->getCanonicalDecl()];
if (!castToVoid_.empty() && castToVoid_.top().sub == expr) {
usage.castToVoid.push_back(castToVoid_.top().cast);
@@ -506,6 +509,9 @@ private:
if (var == nullptr) {
return;
}
+ if (var->getType().isVolatileQualified()) {
+ return;
+ }
auto & usage = vars_[var->getCanonicalDecl()];
if (usage.firstConsumption != nullptr) {
return;
diff --git a/compilerplugins/clang/test/casttovoid.cxx b/compilerplugins/clang/test/casttovoid.cxx
index c3b5eee17c96..3d8c22b49c7e 100644
--- a/compilerplugins/clang/test/casttovoid.cxx
+++ b/compilerplugins/clang/test/casttovoid.cxx
@@ -115,6 +115,8 @@ int main() {
int n8 = 0;
ASSERT(USE(USE(n8 == 0)));
(void) n8;
+ int volatile n9 = 0;
+ (void) n9;
return n1 // expected-note 8 {{first consumption is here [loplugin:casttovoid]}}
+ n2 // expected-note {{first consumption is here [loplugin:casttovoid]}}
+ n3;