[clang] [Clang] [Sema] Fix a crash when a `friend` function is redefined as deleted (PR #135679)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 17 11:08:20 PDT 2025


================
@@ -271,3 +271,33 @@ void operators() {
   if (to_int_int) {} // expected-error {{attempt to use a deleted function: deleted (TO<int, int>, operator bool)}}
   static_cast<bool>(to_int_int); // expected-error {{static_cast from 'TO<int, int>' to 'bool' uses deleted function: deleted (TO<int, int>, operator bool)}}
 };
+
+namespace gh135506 {
+struct a {
+  // FIXME: We currently don't diagnose these invalid redeclarations if the
+  // second declaration is defaulted or deleted. This probably needs to be
+  // handled in ParseCXXInlineMethodDef() after parsing the defaulted/deleted
+  // body.
+  friend consteval int f() { return 3; }
+  friend consteval int f() = delete("foo");
+
+  friend consteval int g() { return 3; }
----------------
shafik wrote:

We should also test `constexpr` as well.

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


More information about the cfe-commits mailing list