[llvm-branch-commits] [clang] 735ab86 - PR47474: Add test for Clang's current behavior.
Richard Smith via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 16 12:05:18 PST 2020
Author: Richard Smith
Date: 2020-12-16T12:01:00-08:00
New Revision: 735ab86b811e40f1533ced98dfc4b7a0c09c545b
URL: https://github.com/llvm/llvm-project/commit/735ab86b811e40f1533ced98dfc4b7a0c09c545b
DIFF: https://github.com/llvm/llvm-project/commit/735ab86b811e40f1533ced98dfc4b7a0c09c545b.diff
LOG: 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.
Added:
Modified:
clang/test/SemaCXX/cxx2a-destroying-delete.cpp
Removed:
################################################################################
diff --git a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
index 015d11e65526..46e5228ec6be 100644
--- a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
+++ b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
@@ -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}}
+}
More information about the llvm-branch-commits
mailing list