George Karpenkov | a393e68 | 2018-08-29 20:29:17 +0000 | [diff] [blame] | 1 | // RUN: %clang_analyze_cc1 -w -x c++ -analyzer-checker=core -analyzer-output=text -verify %s |
Artem Dergachev | 2064e82 | 2017-09-27 09:33:37 +0000 | [diff] [blame] | 2 | |
| 3 | namespace pr34731 { |
| 4 | int b; |
| 5 | class c { |
| 6 | class B { |
| 7 | public: |
| 8 | double ***d; |
| 9 | B(); |
| 10 | }; |
| 11 | void e(double **, int); |
| 12 | void f(B &, int &); |
| 13 | }; |
| 14 | |
| 15 | // Properly track the null pointer in the array field back to the default |
| 16 | // constructor of 'h'. |
| 17 | void c::f(B &g, int &i) { |
| 18 | e(g.d[9], i); // expected-warning{{Array access (via field 'd') results in a null pointer dereference}} |
| 19 | // expected-note@-1{{Array access (via field 'd') results in a null pointer dereference}} |
| 20 | B h, a; // expected-note{{Value assigned to 'h.d'}} |
| 21 | a.d == __null; // expected-note{{Assuming the condition is true}} |
Csaba Dabis | d1f0ec3 | 2019-05-29 20:29:02 +0000 | [diff] [blame] | 22 | a.d != h.d; // expected-note{{Assuming 'a.d' is equal to 'h.d'}} |
Artem Dergachev | 2064e82 | 2017-09-27 09:33:37 +0000 | [diff] [blame] | 23 | f(h, b); // expected-note{{Calling 'c::f'}} |
| 24 | } |
| 25 | } |