PR47474: Add test for Clang's current behavior.

Our current behavior rejects the example, following the current language
rules, but it's likely the rules will be revised to allow this example.
This commit is contained in:
Richard Smith 2020-12-16 11:59:57 -08:00
parent 30d292ddbb
commit 735ab86b81
1 changed files with 26 additions and 0 deletions

View File

@ -141,3 +141,29 @@ namespace templated {
void operator delete(typename id_struct<D>::type *, std::destroying_delete_t); // expected-error {{use 'D<T> *'}}
};
}
namespace dtor_access {
struct S {
void operator delete(S *p, std::destroying_delete_t);
private:
~S(); // expected-note {{here}}
};
// FIXME: PR47474: GCC accepts this, and it seems somewhat reasonable to
// allow, even though [expr.delete]p12 says this is ill-formed.
void f() { delete new S; } // expected-error {{calling a private destructor}}
struct T {
void operator delete(T *, std::destroying_delete_t);
protected:
virtual ~T(); // expected-note {{here}}
};
struct U : T {
void operator delete(void *);
private:
~U() override;
};
void g() { delete (T *)new U; } // expected-error {{calling a protected destructor}}
}