Bug 1814798 - pt 1. Add bool to enable/disable PHC at runtime r=glandium
[gecko.git] / build / clang-plugin / tests / TestRefCountedCopyConstructor.cpp
blobd3bd73084c462a230162e27978effa00e2eaf049
1 // Implicit copy construct which is unused
2 class RC1 {
3 void AddRef();
4 void Release();
5 int mRefCnt;
6 };
8 // Explicit copy constructor which is used
9 class RC2 {
10 public:
11 RC2();
12 RC2(const RC2&);
13 private:
14 void AddRef();
15 void Release();
16 int mRefCnt;
19 void f() {
20 RC1* r1 = new RC1();
21 RC1* r1p = new RC1(*r1); // expected-error {{Invalid use of compiler-provided copy constructor on refcounted type}} expected-note {{The default copy constructor also copies the default mRefCnt property, leading to reference count imbalance issues. Please provide your own copy constructor which only copies the fields which need to be copied}}
23 RC2* r2 = new RC2();
24 RC2* r2p = new RC2(*r2);