<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64082>64082</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang incorrectly parses template type parameter as a concept name
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
danakj
</td>
</tr>
</table>
<pre>
When specializing a class from another namespace, if a type parameter has the same name as a concept in that namespace, Clang mistakenly parses the type parameter name as being the concept name.
For `m` below, the specialization is in the same namespace, the bug does not occur. `MTypeParam` is parsed as the type parameter.
For `n` below, the specialization is outside of the namespace, and `NTypeParam` is treated as the `n::NTypeParam` concept instead of the specialization's `NTypeParam` type parameter in the function parameter list.
https://godbolt.org/z/47ahesrbn
```cpp
template <class T>
concept C = true;
namespace m {
template <class T>
struct M;
template <class T>
concept MTypeParam = true;
template <C MTypeParam>
struct M<MTypeParam> {
static void f(const MTypeParam&) {}
};
}
namespace n {
template <class T>
struct N;
template <class T>
concept NTypeParam = true;
}
template <C NTypeParam>
struct n::N<NTypeParam> {
static void f(const NTypeParam&) {} // error: expected 'auto' or 'decltype(auto)' after concept name
};
int main() {
m::M<int>::f(2);
n::N<int>::f(2);
}
```
Broken on Clang 16 and HEAD.
Works on GCC and MSVC.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlUGPozgThn-NuZQmIoYAOXBIk8n3XTpaaUc758JUgqfBRraZ2Z5fvzKEBrLpVq8UJQpl3nrqdbmM1sqrIsrZ7ontjgH2rtYmr1Dhy4-g1NVr_r0mBbYjIbGRv6W6AoJo0Fq4GN0CKu1qMqCwJduhIMYLkBdAcK8dQYcGW3JkoEYLriaw2NKwGtB6Ka0EdQ6kAlejW-sUDaortNI6fCHVvHo5S6POnfykWJJH9AsmZR_ZsPDIwsP4fdIGWBK2LAmhpEb_8qkGtKlKdFIrkHakWjC_kfmnZX-FSpMFp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