Krystian Stasiowski 29bd78b2f6
[Clang][Sema] Diagnose friend function specialization definitions (#72863)
Per [[class.friend]p6](http://eel.is/c++draft/class.friend#6) a friend
function shall not be defined if its name isn't unqualified. A
_template-id_ is not a name, meaning that a friend function
specialization does not meet this criteria and cannot be defined.

GCC, MSVC, and EDG all consider friend function specialization
definitions to be invalid de facto explicit specializations and diagnose
them as such.

Instantiating a dependent friend function specialization definition
[currently sets off an assert](https://godbolt.org/z/Krqdq95hY) in
`FunctionDecl::setFunctionTemplateSpecialization`. This happens because
we do not set the `TemplateSpecializationKind` of the `FunctionDecl`
created by template argument deduction to `TSK_ExplicitSpecialization`
for friend functions
[here](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplate.cpp#L9600).
I changed the assert condition because I believe this is the correct
behavior.
2023-12-11 06:35:57 -08:00
..
2023-07-25 11:23:36 -04:00
2023-12-06 07:49:03 -05:00
2023-07-10 11:15:48 -04:00
2023-06-14 13:08:07 +01:00
2023-08-18 23:36:04 -07:00

See llvm/docs/README.txt