[clang] [Clang] Ensure default arguments in friend declarations are only allowed in defining declarations to prevent multiple reachable declarations (PR #113777)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 6 09:16:32 PST 2024
================
@@ -4694,6 +4694,15 @@ bool Sema::InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD,
ParmVarDecl *Param) {
assert(Param->hasUninstantiatedDefaultArg());
+ // C++ [dcl.fct.default]p4
+ // If a friend declaration D specifies a default argument expression, that
+ // declaration shall be a definition and there shall be no other declaration
+ // of the function or function template which is reachable from D or from
+ // which D is reachable.
----------------
mizvekov wrote:
```suggestion
// declaration shall be a definition ...
```
This only concerns that first part of the rules. Though it's not exactly enforcing it, that's implemented somewhere else. So it might be worth pointing out that we are avoiding error recovery in this case due to implementation difficulties.
https://github.com/llvm/llvm-project/pull/113777
More information about the cfe-commits
mailing list