[clang] [Clang][AST] Add Test Cases for Reference Qualifiers in Opr Overload (PR #102878)

Muhammad Abdul via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 12 03:46:09 PDT 2024


https://github.com/0xzre created https://github.com/llvm/llvm-project/pull/102878

Follow up of issue #102422 


>From 11b625354ff05c4384603932e6acca347df2132b Mon Sep 17 00:00:00 2001
From: 0xzre <alilo.ghazali at gmail.com>
Date: Mon, 12 Aug 2024 17:42:37 +0700
Subject: [PATCH] [Clang][AST] Add Test Cases for Reference Qualifiers in
 Operator Overloads

---
 clang/test/SemaCXX/function-type-qual.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/clang/test/SemaCXX/function-type-qual.cpp b/clang/test/SemaCXX/function-type-qual.cpp
index f4906f58abbae0..a46b774dc57e69 100644
--- a/clang/test/SemaCXX/function-type-qual.cpp
+++ b/clang/test/SemaCXX/function-type-qual.cpp
@@ -54,4 +54,18 @@ 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 C {
+  void* operator new(size_t bytes) &;  //expected-error {{static member function cannot have '&' qualifier}}
+  void* operator new[](size_t bytes) &;  //expected-error {{static member function cannot have '&' qualifier}}
+
+  void* operator new(size_t bytes) &&;  //expected-error {{static member function cannot have '&&' qualifier}}
+  void* operator new[](size_t bytes) &&;  //expected-error {{static member function cannot have '&&' qualifier}}
+
+  void operator delete(void*) &;  //expected-error {{static member function cannot have '&' qualifier}}
+  void operator delete[](void*) &;  //expected-error {{static member function cannot have '&' qualifier}}
+
+  void operator delete(void*) &&;  //expected-error {{static member function cannot have '&&' qualifier}}
+  void operator delete[](void*) &&;  //expected-error {{static member function cannot have '&&' qualifier}}
+};
 }



More information about the cfe-commits mailing list