diff options
author | Krystian Stasiowski <sdkrystian@gmail.com> | 2024-04-02 08:35:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 08:35:42 -0400 |
commit | eb08c0f1659d12524f58a01bf174177b8acedf2e (patch) | |
tree | 5633a3172a5b3331d22a20accb16b6b2153aa18a /clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | |
parent | a4798bb0b67533b37d6b34fd5292714aac3b17d9 (diff) | |
download | llvm-eb08c0f1659d12524f58a01bf174177b8acedf2e.zip llvm-eb08c0f1659d12524f58a01bf174177b8acedf2e.tar.gz llvm-eb08c0f1659d12524f58a01bf174177b8acedf2e.tar.bz2 |
[Clang][Sema] Fix explicit specializations of member function templates with a deduced return type (#86817)
Clang erroneously rejects the following:
```
template<typename T>
struct A
{
template<typename U>
auto f();
};
template<>
template<typename U>
auto A<int>::f(); // error: conflicting types for 'f'
```
This happens because the explicit specialization of `f` has its return
type replaced with a dependent `AutoType` in `ActOnFunctionDeclarator`,
but no such replacement occurs for the implicitly instantiated function
template `A<int>::f`. Since the return types don't match, the explicit
specialization is diagnosed as an invalid redeclaration.
This patch moves the replacement of the return type to
`CheckFunctionDeclaration` so it also happens during instantiation.
`setObjectOfFriendDecl` will have been called by then, so the `isFriend
&& CurContext->isDependentContext()` condition is made redundant &
removed (as it already happens in `DeclContext::isDependentContext`).
`Sema::IsOverload` only checks the _declared_ return type (which isn't
changed by the adjustment), so adjusting the return type afterwards
should be safe.
Diffstat (limited to 'clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions