<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97021>97021</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang fails to parse type alias in explicit calling of template member function with `->template `
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Rush10233
</td>
</tr>
</table>
<pre>
Please consider the following code:
```c++
template <typename T>
struct A {
int a() {
return 42;
}
};
template <typename T>
struct B {
using MUT_1 = A<T>;
int b(MUT_1 *p) {
return p->template MUT_1::a();
}
};
int main() {
A<int> a;
B<int> b;
return b.b(&a);
}
```
Clang rejects it by complaining that:
```c++
<source>:13:28: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
13 | return p->template MUT_1::a();
| ^
<source>:13:33: error: expected ';' after return statement
13 | return p->template MUT_1::a();
| ^
| ;
<source>:13:28: error: no member named 'MUT_1' in 'A<int>'
13 | return p->template MUT_1::a();
| ~ ^
<source>:20:14: note: in instantiation of member function 'B<int>::b' requested here
20 | return b.b(&a);
```
It seems the compiler does not correctly understand the type alias expression of `using MUT_1 = A<T>;`. Directly using `A<T>` without setting up an alias won't trigger any error. Additionally, GCC also accepts this code.
Please check [https://godbolt.org/z/oYre1GEh3](https://godbolt.org/z/oYre1GEh3)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVV-PozYQ_zTOyygRsQOEBx6yyebUh0pVdVXVp8qYCbhnbGqb20sf-tmrISQkq-7etTqEdok9Hv_-zNgyBN1YxJKlTyw9LOQQW-fLn4fQrhMuxKJy9bn8yaAMCMrZoGv0EFuEkzPGvWjbgHI1MrFjyYEl179ZcnkV40_0jqMRu97IiMDEPp57tLJD-MjE82U6RD-oCDtg-bQAAEDbCJLxLePF4wQ9HuPgLWw4E3czLD9MMPLDbeK_QHh63Gn-GgIR_vGXj7-vgYkD7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