summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/test/unusedfields.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/test/unusedfields.cxx')
-rw-r--r--compilerplugins/clang/test/unusedfields.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/unusedfields.cxx b/compilerplugins/clang/test/unusedfields.cxx
index fe81c88ed205..a6b1ec625ec3 100644
--- a/compilerplugins/clang/test/unusedfields.cxx
+++ b/compilerplugins/clang/test/unusedfields.cxx
@@ -10,6 +10,7 @@
#include <vector>
#include <ostream>
#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
struct Foo
// expected-error@-1 {{read m_foo1 [loplugin:unusedfields]}}
@@ -172,4 +173,28 @@ struct ReadOnlyAnalysis3
}
};
+// Verify the special logic for container fields that only contains mutations that
+// add elements.
+struct ReadOnlyAnalysis4
+// expected-error@-1 {{read m_readonly [loplugin:unusedfields]}}
+// expected-error@-2 {{read m_readwrite [loplugin:unusedfields]}}
+// expected-error@-3 {{write m_readwrite [loplugin:unusedfields]}}
+// expected-error@-4 {{read m_readonlyCss [loplugin:unusedfields]}}
+{
+ std::vector<int> m_readonly;
+ std::vector<int> m_readwrite;
+ css::uno::Sequence<sal_Int32> m_readonlyCss;
+
+ void func1()
+ {
+ int x = m_readonly[0];
+ (void)x;
+ *m_readonly.begin() = 1;
+
+ m_readwrite.push_back(0);
+
+ x = m_readonlyCss.getArray()[0];
+ }
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */