[clang] [Clang] Add tests for ref-qualified operator new (PR #215644)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 12 04:43:36 PDT 2026


================
@@ -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
----------------
Fznamznon wrote:

Sorry for not catching this earlier, can we also fix the alignment?
```suggestion
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
```

https://github.com/llvm/llvm-project/pull/215644


More information about the cfe-commits mailing list