summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-05-31 18:04:22 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-05-31 18:04:22 +0200
commit967e9e6bbb36eb925c14b43b9baff541d82ee4c0 (patch)
tree69d144dceeabb8aa181bc2d2f0c382e1795a9965 /compilerplugins
parent99841f1fd2bf22bca7dcc7e05fc1f91d612d5343 (diff)
Add some loplugin:redundantcast tests
Change-Id: I5c39a745b70655f92953ec785d01a3a52d9ec42b
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/test/redundantcast.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx
index 9b287dac9f2e..53df00ae96ed 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -12,6 +12,13 @@ void f2(char const *) {}
enum Enum1 { X };
+struct S {
+ void f1() { (void)*this; };
+ void f2() const { (void)*this; };
+ void f3() { (void)*this; }
+ void f3() const { (void)*this; };
+};
+
int main() {
char * p1;
char const * p2;
@@ -32,6 +39,12 @@ int main() {
Enum1 e = (Enum1)Enum1::X; // expected-error {{redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast]}}
(void)e;
+
+ S const s;
+ const_cast<S &>(s).f1();
+ const_cast<S &>(s).f2(); // expected-error {{redundant const_cast from 'const S' to 'S', result is implicitly cast to 'const S' [loplugin:redundantcast]}}
+ const_cast<S &>(s).f3();
+ s.f3();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */