[clang] [Sema] Fix friend inline redeclarations treated as overloads (PR #199239)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Mon May 25 02:42:55 PDT 2026
================
@@ -689,11 +689,24 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old,
(New->isInlineSpecified() ||
New->getFriendObjectKind() == Decl::FOK_None)) {
// C++11 [dcl.fcn.spec]p4:
- // If the definition of a function appears in a translation unit before its
- // first declaration as inline, the program is ill-formed.
- Diag(New->getLocation(), diag::err_inline_decl_follows_def) << New;
- Diag(Def->getLocation(), diag::note_previous_definition);
- Invalid = true;
+ // If the definition of a function appears in a translation unit before
+ // its first declaration as inline, the program is ill-formed.
+ //
+ // Exception: a friend inline redeclaration of a function that takes the
+ // enclosing class as a parameter is valid. The class was incomplete at the
+ // point of the original definition, so it could not have been declared
+ // inline there.
----------------
cor3ntin wrote:
This seems to match the behavior of other implementations - however where is the wording specifying this behavior?
https://github.com/llvm/llvm-project/pull/199239
More information about the cfe-commits
mailing list