[all-commits] [llvm/llvm-project] 29bd78: [Clang][Sema] Diagnose friend function specializat...
Krystian Stasiowski via All-commits
all-commits at lists.llvm.org
Mon Dec 11 06:36:10 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 29bd78b2f61e638f6c26bc417ae476754b91e985
https://github.com/llvm/llvm-project/commit/29bd78b2f61e638f6c26bc417ae476754b91e985
Author: Krystian Stasiowski <sdkrystian at gmail.com>
Date: 2023-12-11 (Mon, 11 Dec 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/AST/Decl.cpp
M clang/lib/Sema/SemaDeclCXX.cpp
M clang/test/CXX/class.access/class.friend/p6.cpp
M clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
M clang/test/SemaCXX/friend.cpp
Log Message:
-----------
[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.
More information about the All-commits
mailing list