gcc/testsuite/g++.dg/analyzer/dyncast-1.C
raw| 1 | #include "../../gcc.dg/analyzer/analyzer-decls.h" |
| 2 | |
| 3 | struct base |
| 4 | { |
| 5 | virtual ~base () {} |
| 6 | }; |
| 7 | struct sub : public base |
| 8 | { |
| 9 | int m_field; |
| 10 | }; |
| 11 | |
| 12 | int |
| 13 | test_1 (base *p) |
| 14 | { |
| 15 | if (sub *q = dynamic_cast <sub*> (p)) |
| 16 | { |
| 17 | __analyzer_dump_path (); // { dg-message "path" } |
| 18 | return q->m_field; |
| 19 | } |
| 20 | return 0; |
| 21 | } |