[clang] [Clang][Sema] qualifier should be transformed (PR #94725)
Qizhi Hu via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 22 03:00:40 PDT 2024
jcsxky wrote:
@mizvekov After looking into the code, I think we should transform qualifier in TST. Consider the following code:
```cpp
template <typename T>
t1<T>::template t2<T> f1();
void f2() {
f1<bool>();
}
```
`TemplateSpecializationType` of `t2` whose `Template` is a `QualifiedTemplateName`(`t1<T>::`) will be dependent if we didn't transform the qualifier since its qualifier and `DeclContext` are both dependent and it wouldn't be specialized in `Sema::CheckTemplateIdType` due to its name dependency. Transform the qualifier and rebuild the `TemplateName` as a `DependentTemplateName` is also consistent with what it is before cpp20(`t2` is a `DependentTemplateName`) which needs a `typename` keyword(`typename t1<T>::template t2<T>`).
> The fact that this change somehow affects program semantics is still unexpected and unexplained.
The case in `clang/test/SemaCXX/many-template-parameter-lists.cpp` is affected is because the qualifier didn't be transformed and we can't find the instantiation of the declaration(`X`) which will not happen after this patch. This case is also accepted by gcc. The other cases are expected or explained in the comments.
>If I had to take a guess, there is something wrong in the dependency computation for the NNS. Have you checked that?
I didn't find some problems in dependency computation for the NNS.
https://github.com/llvm/llvm-project/pull/94725
More information about the cfe-commits
mailing list