diff options
Diffstat (limited to 'compilerplugins/clang/test/redundantcast.cxx')
-rw-r--r-- | compilerplugins/clang/test/redundantcast.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx index be34a57729c6..a876fae6e4b3 100644 --- a/compilerplugins/clang/test/redundantcast.cxx +++ b/compilerplugins/clang/test/redundantcast.cxx @@ -392,6 +392,20 @@ void testArrayDecay() { (void) reinterpret_cast<char const *>(u8""); } +void testNew() { + class A {}; + class B : public A {}; + A* p = static_cast<A*>(new B); // expected-error {{redundant static_cast from 'B *' to 'A *' [loplugin:redundantcast]}} + (void)p; + // no warning expected for resolving-ambiguity cast + class C : public A {}; + class D : public B, public C {}; + p = static_cast<B*>(new D); + // no warning expected for down-cast + auto p2 = static_cast<B*>(p); + (void)p2; +} + int main() { testConstCast(); testStaticCast(); |