[clang] Initial implementation of P2719 (PR #113510)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 25 10:00:22 PDT 2024


================
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s          -std=c++17 -fcxx-type-aware-allocators
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DNO_TAA -std=c++17 -fno-cxx-type-aware-allocators
+
+namespace std {
+  template <class T> struct type_identity {};
+  enum class align_val_t : __SIZE_TYPE__ {};
+  struct destroying_delete_t { explicit destroying_delete_t() = default; };
+}
+
+using size_t = __SIZE_TYPE__;
+
+struct TestType {};
+template <typename T> struct TemplateTestType {};
+
+// Valid free declarations
+void *operator new(std::type_identity<int>, size_t);
+void *operator new(std::type_identity<int>, size_t, std::align_val_t);
+void *operator new(std::type_identity<int>, size_t, TestType&);
+template <typename T> void *operator new(std::type_identity<T>, size_t);
+template <typename T> void *operator new(std::type_identity<T>, size_t, TestType&);
+template <typename T> void *operator new(std::type_identity<TemplateTestType<T>>, size_t, TestType&);
+template <typename T, typename U> void *operator new(std::type_identity<T>, size_t, TemplateTestType<U>&);
+template <template <typename> class T> void *operator new(std::type_identity<T<int>>, size_t); 
+#if defined(NO_TAA)
+//expected-error at -9 {{type aware allocation operators are disabled}}
+//expected-error at -9 {{type aware allocation operators are disabled}}
+//expected-error at -9 {{type aware allocation operators are disabled}}
+//expected-error at -9 {{type aware allocation operators are disabled}}
+//expected-error at -9 {{type aware allocation operators are disabled}}
+//expected-error at -9 {{type aware allocation operators are disabled}}
+//expected-error at -9 {{type aware allocation operators are disabled}}
+//expected-error at -9 {{type aware allocation operators are disabled}}
+#endif
+
+void operator delete(std::type_identity<int>, void *);
+void operator delete(std::type_identity<int>, void *, std::align_val_t);
+void operator delete(std::type_identity<int>, void *, size_t);
+void operator delete(std::type_identity<int>, void *, size_t, std::align_val_t);
+#if defined(NO_TAA)
+//expected-error at -5 {{type aware allocation operators are disabled}}
----------------
erichkeane wrote:

This diagnostic should mention the flag so folks know how to fix this.

https://github.com/llvm/llvm-project/pull/113510


More information about the cfe-commits mailing list