Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wnonnull7.C

raw
1 /* PR c++/96003 - spurious -Wnonnull calling a member on the result
2 of static_cast
3 { dg-do compile }
4 { dg-options "-Wall" } */
5
6 struct D;
7 struct B
8 {
9 B* next;
10 D* Next ();
11 };
12
13 struct D: B
14 {
15 virtual ~D ();
16 };
17
18 struct Iterator
19 {
20 D* p;
21 void advance ()
22 {
23 p = static_cast<B*>(p)->Next (); // { dg-bogus "\\\[-Wnonnull" }
24 }
25 };
26
27 // Test case from comment #11.
28
29 struct S1 { virtual ~S1 (); };
30 struct S2 { virtual ~S2 (); };
31 struct S3: S1, S2 { void f (); };
32
33 void f (S2 *p)
34 {
35 static_cast<S3 *>(p)->f (); // { dg-bogus "\\\[-Wnonnull" }
36 }