diff options
Diffstat (limited to 'compilerplugins/clang/test/unusedfields.cxx')
-rw-r--r-- | compilerplugins/clang/test/unusedfields.cxx | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/compilerplugins/clang/test/unusedfields.cxx b/compilerplugins/clang/test/unusedfields.cxx index 6ff9189eab27..c936460bbea5 100644 --- a/compilerplugins/clang/test/unusedfields.cxx +++ b/compilerplugins/clang/test/unusedfields.cxx @@ -6,14 +6,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "config_clang.h" -// CLANG_VERSION = older versions of clang need something different in getParentFunctionDecl -// WIN32 = TODO, see corresponding TODO in compilerplugins/clang/unusedfields.cxx -#if CLANG_VERSION < 110000 || defined _WIN32 +#if defined _WIN32 // TODO, see corresponding TODO in compilerplugins/clang/unusedfields.cxx // expected-no-diagnostics #else +#include <map> #include <memory> #include <vector> #include <ostream> @@ -380,6 +378,49 @@ namespace TouchFromOutsideAnalysis1 }; }; +namespace WriteOnlyAnalysis4 +{ + struct ImplTabCtrlData + // expected-error@-1 {{read maLayoutLineToPageId [loplugin:unusedfields]}} + // expected-error@-2 {{outside maLayoutLineToPageId [loplugin:unusedfields]}} + { + std::map< int, int > maLayoutLineToPageId; + }; + class TabControl + // expected-error@-1 {{read mpTabCtrlData [loplugin:unusedfields]}} + // expected-error@-2 {{outside-constructor mpTabCtrlData [loplugin:unusedfields]}} + { + std::unique_ptr<ImplTabCtrlData> mpTabCtrlData; + + void foo(int nLine, int& rPageId) + { + rPageId = mpTabCtrlData->maLayoutLineToPageId[ nLine ]; + } + }; +} + +namespace WriteOnlyAnalysis5 +{ + struct ImplTabCtrlData + // expected-error@-1 {{read maLayoutLineToPageId [loplugin:unusedfields]}} + // expected-error@-2 {{write maLayoutLineToPageId [loplugin:unusedfields]}} + // expected-error@-3 {{outside maLayoutLineToPageId [loplugin:unusedfields]}} + { + std::map< int, int > maLayoutLineToPageId; + }; + class TabControl + // expected-error@-1 {{read mpTabCtrlData [loplugin:unusedfields]}} + // expected-error@-2 {{outside-constructor mpTabCtrlData [loplugin:unusedfields]}} + { + std::unique_ptr<ImplTabCtrlData> mpTabCtrlData; + + void foo(int nLine, int nPageId) + { + mpTabCtrlData->maLayoutLineToPageId[ nLine ] = nPageId; + } + }; +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |