[all-commits] [llvm/llvm-project] 7ecfb6: [Clang][Sema] Correctly look up primary template f...
Krystian Stasiowski via All-commits
all-commits at lists.llvm.org
Fri Feb 2 09:53:46 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7ecfb66c77ad77dabbb705cbb1f3b17a3d1391a4
https://github.com/llvm/llvm-project/commit/7ecfb66c77ad77dabbb705cbb1f3b17a3d1391a4
Author: Krystian Stasiowski <sdkrystian at gmail.com>
Date: 2024-02-02 (Fri, 02 Feb 2024)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Sema/Sema.h
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaTemplate.cpp
A clang/test/CXX/dcl.decl/dcl.meaning/dcl.meaning.general/p3.cpp
Log Message:
-----------
[Clang][Sema] Correctly look up primary template for variable template specializations (#80359)
Consider the following:
```
namespace N0 {
namespace N1 {
template<typename T>
int x1 = 0;
}
using namespace N1;
}
template<>
int N0::x1<int>;
```
According to [dcl.meaning.general] p3.3:
> - If the _declarator_ declares an explicit instantiation or a partial
or explicit specialization, the _declarator_ does not bind a name. If it
declares a class member, the terminal name of the _declarator-id_ is not
looked up; otherwise, **only those lookup results that are nominable in
`S` are considered when identifying any function template specialization
being declared**.
In particular, the requirement for lookup results to be nominal in the
lookup context of the terminal name of the _declarator-id_ only applies
to function template specializations -- not variable template
specializations. We currently reject the above declaration, but we do
(correctly) accept it if the using-directive is replaced with a `using`
declaration naming `N0::N1::x1`. This patch makes it so the above
specialization is (correctly) accepted.
More information about the All-commits
mailing list