summaryrefslogtreecommitdiffstats
path: root/test/Analysis/diagnostics/dtors.cpp
blob: 094917e432f02182fef8abdd7b35d51a0869057a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,cplusplus -verify %s

// expected-no-diagnostics

namespace no_crash_on_delete_dtor {
// We were crashing when producing diagnostics for this code.
struct S {
  void foo();
  ~S();
};

struct smart_ptr {
  int x;
  S *s;
  smart_ptr(S *);
  S *get() {
    return (x || 0) ? nullptr : s;
  }
};

void bar(smart_ptr p) {
  delete p.get();
  p.get()->foo();
}
} // namespace no_crash_on_delete_dtor