xref: /llvm-project/clang/test/CXX/drs/cwg412.cpp (revision ed128c7df9b4e60bfd814dc9fd22de1dde4a2c1c)
1 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT="throw()" -DBAD_ALLOC="throw(std::bad_alloc)"
2 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
3 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
4 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
5 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
6 // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
7 // RUN: %clang_cc1 -std=c++2c %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
8 
9 // cwg412: 3.4
10 // lwg404: yes
11 // lwg2340: yes
12 
13 // FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
14 __extension__ typedef __SIZE_TYPE__ size_t;
15 namespace std { struct bad_alloc {}; }
16 
17 inline void* operator new(size_t) BAD_ALLOC;
18 // expected-error@-1 {{replacement function 'operator new' cannot be declared 'inline'}}
19 inline void* operator new[](size_t) BAD_ALLOC;
20 // expected-error@-1 {{replacement function 'operator new[]' cannot be declared 'inline'}}
21 inline void operator delete(void*) NOEXCEPT;
22 // expected-error@-1 {{replacement function 'operator delete' cannot be declared 'inline'}}
23 inline void operator delete[](void*) NOEXCEPT;
24 // expected-error@-1 {{replacement function 'operator delete[]' cannot be declared 'inline'}}
25 #ifdef __cpp_sized_deallocation
26 inline void operator delete(void*, size_t) NOEXCEPT;
27 // expected-error@-1 {{replacement function 'operator delete' cannot be declared 'inline'}}
28 inline void operator delete[](void*, size_t) NOEXCEPT;
29 // expected-error@-1 {{replacement function 'operator delete[]' cannot be declared 'inline'}}
30 #endif
31