[clang] [Clang] Add tests for ref-qualified operator new (PR #215644)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 12 04:57:22 PDT 2026
https://github.com/nehaGautam07 updated https://github.com/llvm/llvm-project/pull/215644
>From 52d4e377b6729cb91e4eefc0f7a6cbd44b3cb8f1 Mon Sep 17 00:00:00 2001
From: neharaj <neharajgautam07 at gmail.com>
Date: Tue, 11 Aug 2026 18:57:13 +0000
Subject: [PATCH 1/3] Add tests for ref-qualified operator new
---
clang/test/SemaCXX/function-type-qual.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/clang/test/SemaCXX/function-type-qual.cpp b/clang/test/SemaCXX/function-type-qual.cpp
index f4906f58abbae..af2ef9a7f5d73 100644
--- a/clang/test/SemaCXX/function-type-qual.cpp
+++ b/clang/test/SemaCXX/function-type-qual.cpp
@@ -54,4 +54,11 @@ struct B {
void operator delete(void*) volatile; //expected-error {{static member function cannot have 'volatile' qualifier}}
void operator delete[](void*) volatile; //expected-error {{static member function cannot have 'volatile' qualifier}}
};
-}
+ struct RefQualifierLValue {
+ void* operator new(size_t bytes) &; // expected-error {{static member function cannot have '&' qualifier}}
+ };
+
+ struct RefQualifierRValue {
+ void* operator new(size_t bytes) &&; // expected-error {{static member function cannot have '&&' qualifier}}
+ };
+ } // namespace GH79748
\ No newline at end of file
>From 22c76d0bbbef628df8f9e285aae0d01758b7f52d Mon Sep 17 00:00:00 2001
From: neharaj <neharajgautam07 at gmail.com>
Date: Wed, 12 Aug 2026 11:27:01 +0000
Subject: [PATCH 2/3] Add newline at end of file
---
clang/test/SemaCXX/function-type-qual.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/SemaCXX/function-type-qual.cpp b/clang/test/SemaCXX/function-type-qual.cpp
index af2ef9a7f5d73..854d694048667 100644
--- a/clang/test/SemaCXX/function-type-qual.cpp
+++ b/clang/test/SemaCXX/function-type-qual.cpp
@@ -61,4 +61,4 @@ struct B {
struct RefQualifierRValue {
void* operator new(size_t bytes) &&; // expected-error {{static member function cannot have '&&' qualifier}}
};
- } // namespace GH79748
\ No newline at end of file
+ } // namespace GH79748
>From db05ebaa8cd075ecee9b62482c85eb28379593e9 Mon Sep 17 00:00:00 2001
From: neharaj <neharajgautam07 at gmail.com>
Date: Wed, 12 Aug 2026 11:53:29 +0000
Subject: [PATCH 3/3] Fix alignment in ref-qualified operator new tests
---
clang/test/SemaCXX/function-type-qual.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/clang/test/SemaCXX/function-type-qual.cpp b/clang/test/SemaCXX/function-type-qual.cpp
index 854d694048667..37500c0315d3d 100644
--- a/clang/test/SemaCXX/function-type-qual.cpp
+++ b/clang/test/SemaCXX/function-type-qual.cpp
@@ -54,11 +54,11 @@ struct B {
void operator delete(void*) volatile; //expected-error {{static member function cannot have 'volatile' qualifier}}
void operator delete[](void*) volatile; //expected-error {{static member function cannot have 'volatile' qualifier}}
};
- struct RefQualifierLValue {
- void* operator new(size_t bytes) &; // expected-error {{static member function cannot have '&' qualifier}}
- };
+struct RefQualifierLValue {
+ void* operator new(size_t bytes) &; // expected-error {{static member function cannot have '&' qualifier}}
+};
- struct RefQualifierRValue {
- void* operator new(size_t bytes) &&; // expected-error {{static member function cannot have '&&' qualifier}}
- };
- } // namespace GH79748
+struct RefQualifierRValue {
+ void* operator new(size_t bytes) &&; // expected-error {{static member function cannot have '&&' qualifier}}
+};
+} // namespace GH79748
More information about the cfe-commits
mailing list