[clang] [Clang] diagnose deleted/default redeclaration of defined friend functions (PR #136717)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 24 06:16:16 PDT 2025


================
@@ -142,6 +142,14 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(
       SkipUntil(tok::semi);
     }
 
+    if (FunctionDecl *FD =
+            dyn_cast_if_present<FunctionDecl>(FnD->getPreviousDecl())) {
+      if (isa<CXXRecordDecl>(FD->getLexicalDeclContext()) ||
+          Actions.getDefaultedFunctionKind(FD).asComparison() ==
+              Sema::DefaultedComparisonKind::None)
----------------
zyn0217 wrote:

> and adding a similar check for deleted functions... not sure about this alternative

I strongly prefer/would like to see some exploration in this direction because it aligns with our overall design.

> however, it appears to skip over = default and = delete cases without any specific handling

Skipping over (did you mean never built any AST nodes for them? That's suspicious!) these functions at the parser level is IMO wrong, as it hurts source fidelity.


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


More information about the cfe-commits mailing list