#include // we can't include nsCOMPtr.h here, so let's redefine a basic version template struct nsCOMPtr { nsCOMPtr() = default; template MOZ_IMPLICIT nsCOMPtr(already_AddRefed&& aSrc); template nsCOMPtr& operator=(already_AddRefed&& aSrc); }; using namespace mozilla; struct RefCountedBase { void AddRef(); void Release(); void method_test(); }; struct RefCountedDerived : RefCountedBase {}; struct RefCountedBaseHolder { RefPtr GetRefCountedBase() const { return mRefCountedBase; } private: RefPtr mRefCountedBase = MakeRefPtr(); }; void test_assign_same_type() { RefPtr a = MakeRefPtr(); RefPtr b; b = a.forget(); // expected-warning {{non-standard move assignment}} } void test_assign_implicit_cast() { RefPtr a = MakeRefPtr(); RefPtr b; b = a.forget(); // expected-warning {{non-standard move assignment}} } void test_assign_different_template() { RefPtr a = MakeRefPtr(); nsCOMPtr b; b = a.forget(); // expected-warning {{non-standard move assignment}} } void test_construct_different_template() { RefPtr a = MakeRefPtr(); nsCOMPtr b = a.forget(); // expected-warning {{non-standard move construction}} } void test_assign_already_addrefed() { RefPtr a = MakeRefPtr(); already_AddRefed b; b = a.forget(); } void test_construct_already_addrefed() { RefPtr a = MakeRefPtr(); already_AddRefed b = a.forget(); } void test_construct_same_type() { RefPtr a = MakeRefPtr(); RefPtr b = a.forget(); // expected-warning {{non-standard move construction}} } void test_construct_implicit_cast() { RefPtr a = MakeRefPtr(); RefPtr b = a.forget(); // expected-warning {{non-standard move construction}} } void test_construct_brace_same_type() { RefPtr a = MakeRefPtr(); auto b = RefPtr{a.forget()}; // expected-warning {{non-standard move construction}} } void test_construct_brace_implicit_cast() { RefPtr a = MakeRefPtr(); auto b = RefPtr{a.forget()}; // expected-warning {{non-standard move construction}} } void test_construct_function_style_same_type() { RefPtr a = MakeRefPtr(); auto b = RefPtr(a.forget()); // expected-warning {{non-standard move construction}} } void test_construct_function_style_implicit_cast() { RefPtr a = MakeRefPtr(); auto b = RefPtr(a.forget()); // expected-warning {{non-standard move construction}} } void test_construct_result_type() { RefPtr a = MakeRefPtr(); already_AddRefed b = a.forget(); } void test_construct_implicitly_cast_result_type() { RefPtr a = MakeRefPtr(); already_AddRefed b = a.forget(); } void foo(already_AddRefed&& aArg); void test_call_with_result_type() { RefPtr a = MakeRefPtr(); foo(a.forget()); } void test_call_with_implicitly_cast_result_type() { RefPtr a = MakeRefPtr(); foo(a.forget()); }