aboutsummaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-06-16 08:28:52 +0200
committerGitHub <noreply@github.com>2025-06-16 08:28:52 +0200
commit4f9e6bad8438f4440bfd68be2f0ebdca0d588d47 (patch)
treeada4e90e1396c37acf3fed1f6b752c30bc578962 /clang/test/AST/ByteCode
parent4ea616d072d126a31149174ca2efdbdace9ce568 (diff)
downloadllvm-4f9e6bad8438f4440bfd68be2f0ebdca0d588d47.zip
llvm-4f9e6bad8438f4440bfd68be2f0ebdca0d588d47.tar.gz
llvm-4f9e6bad8438f4440bfd68be2f0ebdca0d588d47.tar.bz2
[clang][bytecode] Fix calling operator new with nothrow/align parameter (#144271)
Discard all the parameters we don't care about.
Diffstat (limited to 'clang/test/AST/ByteCode')
-rw-r--r--clang/test/AST/ByteCode/new-delete.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp
index 1ee41a9..9c293e5 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s
-// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -verify=expected,both %s
-// RUN: %clang_cc1 -triple=i686-linux-gnu -std=c++20 -fexperimental-new-constant-interpreter -verify=expected,both %s
-// RUN: %clang_cc1 -verify=ref,both %s
-// RUN: %clang_cc1 -std=c++20 -verify=ref,both %s
-// RUN: %clang_cc1 -triple=i686-linux-gnu -std=c++20 -verify=ref,both %s
+// RUN: %clang_cc1 -verify=expected,both -fexperimental-new-constant-interpreter %s
+// RUN: %clang_cc1 -std=c++20 -verify=expected,both -fexperimental-new-constant-interpreter %s
+// RUN: %clang_cc1 -std=c++20 -verify=expected,both -triple=i686-linux-gnu -fexperimental-new-constant-interpreter %s
+// RUN: %clang_cc1 -verify=ref,both %s
+// RUN: %clang_cc1 -std=c++20 -verify=ref,both %s
+// RUN: %clang_cc1 -std=c++20 -verify=ref,both -triple=i686-linux-gnu %s
#if __cplusplus >= 202002L
@@ -1012,6 +1012,16 @@ constexpr int no_deallocate_nonalloc = (std::allocator<int>().deallocate((int*)&
// both-note {{in call}} \
// both-note {{declared here}}
+namespace OpNewNothrow {
+ constexpr int f() {
+ 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'}}
+ operator delete(v, std::align_val_t(2), std::nothrow);
+ return 1;
+ }
+ static_assert(f()); // both-error {{not an integral constant expression}} \
+ // both-note {{in call to}}
+}
+
#else
/// Make sure we reject this prior to C++20
constexpr int a() { // both-error {{never produces a constant expression}}