diff options
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CXX/drs/dr2xx.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/unavailable_aligned_allocation.cpp | 67 |
2 files changed, 69 insertions, 2 deletions
diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp index 4e745ef2f4d..b69c014b587 100644 --- a/clang/test/CXX/drs/dr2xx.cpp +++ b/clang/test/CXX/drs/dr2xx.cpp @@ -718,7 +718,7 @@ namespace dr261 { // dr261: no A() {} }; - // FIXME: These are ill-formed, with a required diagnostic, for the same + // FIXME: This is ill-formed, with a required diagnostic, for the same // reason. struct B { inline void operator delete(void*) __attribute__((unused)); @@ -726,7 +726,7 @@ namespace dr261 { // dr261: no }; struct C { inline void operator delete(void*) __attribute__((unused)); - virtual ~C() {} + virtual ~C() {} // expected-warning {{'operator delete' was marked unused but was used}} }; struct D { diff --git a/clang/test/SemaCXX/unavailable_aligned_allocation.cpp b/clang/test/SemaCXX/unavailable_aligned_allocation.cpp index 2000e0b6a31..3c746c38c6f 100644 --- a/clang/test/SemaCXX/unavailable_aligned_allocation.cpp +++ b/clang/test/SemaCXX/unavailable_aligned_allocation.cpp @@ -124,6 +124,73 @@ void testOveralignedCheckOS() { // expected-note@-20 2 {{if you supply your own aligned allocation functions}} #endif +// Test that diagnostics are produced when an unavailable aligned deallocation +// function is called from a deleting destructor. +struct alignas(256) OveralignedS2 { + int a[4]; + virtual ~OveralignedS2(); +}; + +OveralignedS2::~OveralignedS2() {} + +#ifdef NO_ERRORS +// expected-no-diagnostics +#else +#if defined(IOS) +// expected-error@-6 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on iOS 11 or newer}}} +// expected-note@-7 {{if you supply your own aligned allocation functions}} +#elif defined(TVOS) +// expected-error@-9 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on tvOS 11 or newer}}} +// expected-note@-10 {{if you supply your own aligned allocation functions}} +#elif defined(WATCHOS) +// expected-error@-12 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}} +// expected-note@-13 {{if you supply your own aligned allocation functions}} +#else +// expected-error@-15 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}} +// expected-note@-16 {{if you supply your own aligned allocation functions}} +#endif +#endif + +void testExplicitOperatorNewDelete() { + void *p = operator new(128); + operator delete(p); + p = operator new[](128); + operator delete[](p); + p = __builtin_operator_new(128); + __builtin_operator_delete(p); +} + +void testExplicitOperatorNewDeleteOveraligned() { + void *p = operator new(128, (std::align_val_t)64); + operator delete(p, (std::align_val_t)64); + p = operator new[](128, (std::align_val_t)64); + operator delete[](p, (std::align_val_t)64); + p = __builtin_operator_new(128, (std::align_val_t)64); + __builtin_operator_delete(p, (std::align_val_t)64); +} + +#ifdef NO_ERRORS +// expected-no-diagnostics +#else +// expected-error@-11 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}} +// expected-note@-12 {{if you supply your own aligned allocation functions}} + +// expected-error@-13 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}} +// expected-note@-14 {{if you supply your own aligned allocation functions}} + +// expected-error@-15 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}} +// expected-note@-16 {{if you supply your own aligned allocation functions}} + +// expected-error@-17 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}} +// expected-note@-18 {{if you supply your own aligned allocation functions}} + +// expected-error@-19 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}} +// expected-note@-20 {{if you supply your own aligned allocation functions}} + +// expected-error@-21 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}} +// expected-note@-22 {{if you supply your own aligned allocation functions}} +#endif + // No errors if user-defined aligned allocation functions are available. void *operator new(std::size_t __sz, std::align_val_t) { static char array[256]; |

