1- // RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -std=c++23 -fexperimental-cxx-type-aware-allocators -fexceptions
1+ // RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -std=c++23 -fexperimental-cxx-type-aware-allocators -fexceptions -fsized-deallocation -faligned-allocation
2+ // RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -std=c++23 -fexperimental-cxx-type-aware-allocators -fexceptions -fno-sized-deallocation -faligned-allocation
3+ // RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -std=c++23 -fexperimental-cxx-type-aware-allocators -fexceptions -fsized-deallocation -fno-aligned-allocation
4+ // RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -std=c++23 -fexperimental-cxx-type-aware-allocators -fexceptions -fno-sized-deallocation -fno-aligned-allocation
25// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -DTADD -std=c++23 -fexperimental-cxx-type-aware-allocators -fexperimental-cxx-type-aware-destroying-delete -fexceptions
36
47namespace std {
@@ -14,6 +17,12 @@ static_assert(__has_feature(cxx_type_aware_destroying_delete));
1417static_assert (!__has_feature(cxx_type_aware_destroying_delete));
1518#endif
1619
20+ #if defined(__cpp_aligned_new)
21+ #define ALLOCATION_ALIGNMENT , std::align_val_t
22+ #else
23+ #define ALLOCATION_ALIGNMENT
24+ #endif
25+
1726using size_t = __SIZE_TYPE__;
1827
1928void *operator new (size_t );
@@ -36,8 +45,8 @@ void *operator new(std::type_identity<UntypedInclassNewOveraligned_NoAlignedAllo
3645void operator delete (std::type_identity<UntypedInclassNewOveraligned_NoAlignedAlloc>, void *, size_t , std::align_val_t ); // #8
3746
3847struct __attribute__ ((aligned(128 ))) UntypedInclassNewOveraligned_AlignedAlloc {
39- void *operator new (size_t , std:: align_val_t ) = delete ; // #9
40- void operator delete (void *, std:: align_val_t ) = delete ; // #10
48+ void *operator new (size_t ALLOCATION_ALIGNMENT ) = delete ; // #9
49+ void operator delete (void * ALLOCATION_ALIGNMENT ) = delete ; // #10
4150};
4251void *operator new (std::type_identity<UntypedInclassNewOveraligned_AlignedAlloc>, size_t , std::align_val_t ); // #11
4352void operator delete (std::type_identity<UntypedInclassNewOveraligned_AlignedAlloc>, void *, size_t , std::align_val_t ); // #12
@@ -327,13 +336,11 @@ void test() {
327336 // expected-error@-1 {{attempt to use a deleted function}}
328337 // expected-note@#33 {{'operator delete' has been explicitly marked deleted here}}
329338
330- // Are these reasonable? Should we ensure that declaration of new vs delete have consistent type
331- // semantics? How do we define consistent?
332339 // Constructor clean up invokes untyped delete if untyped delete was used
333340 InclassNew6 *O10 = new InclassNew6;
334341 // expected-error@-1 {{attempt to use a deleted function}}
335342 // expected-note@#36 {{'operator delete' has been explicitly marked deleted here}}
336- // expected-error@-3 {{mismatched type aware allocation operators for constructor cleanup}}
343+ // expected-error@-3 {{type aware allocation requires matching type aware operator new and type aware operator delete for exception cleanup}}
337344 // expected-note@#34 {{non-type aware 'operator new' declared here}}
338345 // expected-note@#36 {{type aware 'operator delete' declared here}}
339346 delete O10;
@@ -347,13 +354,13 @@ void test() {
347354 // expected-note@#39 {{'operator delete' has been explicitly marked deleted here}}
348355
349356 InclassNew8 *O12 = new InclassNew8;
350- // expected-error@-1 {{mismatched type aware allocation operators for constructor cleanup}}
357+ // expected-error@-1 {{type aware allocation requires matching type aware operator new and type aware operator delete for exception cleanup}}
351358 // expected-note@#40 {{type aware 'operator new' declared here}}
352359 // expected-note@#41 {{non-type aware 'operator delete' declared here}}
353360 delete O12;
354361
355362 InclassNew9 *O13 = new InclassNew9;
356- // expected-error@-1 {{type aware 'operator new' requires matching cleanup 'operator delete' in 'InclassNew9'}}
363+ // expected-error@-1 {{type aware 'operator new' requires there to be a corresponding cleanup 'operator delete' in 'InclassNew9'}}
357364
358365 delete O13;
359366
@@ -403,13 +410,13 @@ void test() {
403410 // expected-note@#59 {{member 'operator delete' declared here}}
404411
405412 SubClass6_1 *O22 = new SubClass6_1;
406- // expected-error@-1 {{type aware 'operator new<SubClass6_1>' requires matching 'operator delete' in 'SubClass6_1'}}
413+ // expected-error@-1 {{type aware 'operator new<SubClass6_1>' requires there to be a corresponding 'operator delete' in 'SubClass6_1'}}
407414 // expected-note@#62 {{type aware 'operator new<SubClass6_1>' found in 'SubClass6_1'}}
408415 // expected-note@#61 {{type aware 'operator delete<SubClass6_1>' found in 'BaseClass6'}}
409416 delete O22;
410417
411418 SubClass6_2 *O23 = new SubClass6_2;
412- // expected-error@-1 {{type aware 'operator new<SubClass6_2>' requires matching 'operator delete' in 'BaseClass6'}}
419+ // expected-error@-1 {{type aware 'operator new<SubClass6_2>' requires there to be a corresponding 'operator delete' in 'BaseClass6'}}
413420 // expected-note@#60 {{type aware 'operator new<SubClass6_2>' found in 'BaseClass6'}}
414421 // expected-note@#63 {{type aware 'operator delete<SubClass6_2>' found in 'SubClass6_2'}}
415422 delete O23;
0 commit comments