|
1 |
| -// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s |
2 |
| -// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -verify=expected,both %s |
3 |
| -// RUN: %clang_cc1 -triple=i686-linux-gnu -std=c++20 -fexperimental-new-constant-interpreter -verify=expected,both %s |
4 |
| -// RUN: %clang_cc1 -verify=ref,both %s |
5 |
| -// RUN: %clang_cc1 -std=c++20 -verify=ref,both %s |
6 |
| -// RUN: %clang_cc1 -triple=i686-linux-gnu -std=c++20 -verify=ref,both %s |
| 1 | +// RUN: %clang_cc1 -verify=expected,both -fexperimental-new-constant-interpreter %s |
| 2 | +// RUN: %clang_cc1 -std=c++20 -verify=expected,both -fexperimental-new-constant-interpreter %s |
| 3 | +// RUN: %clang_cc1 -std=c++20 -verify=expected,both -triple=i686-linux-gnu -fexperimental-new-constant-interpreter %s |
| 4 | +// RUN: %clang_cc1 -verify=ref,both %s |
| 5 | +// RUN: %clang_cc1 -std=c++20 -verify=ref,both %s |
| 6 | +// RUN: %clang_cc1 -std=c++20 -verify=ref,both -triple=i686-linux-gnu %s |
7 | 7 |
|
8 | 8 | #if __cplusplus >= 202002L
|
9 | 9 |
|
@@ -1012,6 +1012,16 @@ constexpr int no_deallocate_nonalloc = (std::allocator<int>().deallocate((int*)&
|
1012 | 1012 | // both-note {{in call}} \
|
1013 | 1013 | // both-note {{declared here}}
|
1014 | 1014 |
|
| 1015 | +namespace OpNewNothrow { |
| 1016 | + constexpr int f() { |
| 1017 | + int *v = (int*)operator new(sizeof(int), std::align_val_t(2), std::nothrow); // both-note {{cannot allocate untyped memory in a constant expression; use 'std::allocator<T>::allocate' to allocate memory of type 'T'}} |
| 1018 | + operator delete(v, std::align_val_t(2), std::nothrow); |
| 1019 | + return 1; |
| 1020 | + } |
| 1021 | + static_assert(f()); // both-error {{not an integral constant expression}} \ |
| 1022 | + // both-note {{in call to}} |
| 1023 | +} |
| 1024 | + |
1015 | 1025 | #else
|
1016 | 1026 | /// Make sure we reject this prior to C++20
|
1017 | 1027 | constexpr int a() { // both-error {{never produces a constant expression}}
|
|
0 commit comments