[clang] [clang] Substitute alias templates from correct context (PR #75069)

Jordan Rupprecht via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 19:38:30 PST 2023


rupprecht wrote:

Thanks to @MaskRay for handling the revert.

A reduction for the second `typename` breakage looks similar, so may be the same underlying issue. But here it is anyway, in case it ends up being a second bug in the patch:

```c++
class Foo {};

template <class T>
struct Ptr {};

template <class X, class Y = void>
class Data;

template <class Unused>
struct Data<Foo, Unused> {
  using Type = int;
  void func();
};

template <class T>
using Alias = Data<Foo, T>;

template <class T>
void Alias<T>::func() {
  auto x = Ptr<Alias<T>::Type>();
  (void)x;
}
```

Results in:

```c++
<source>:20:16: error: template argument for template type parameter must be a type; did you forget 'typename'?
   20 |   auto x = Ptr<Alias<T>::Type>();
      |                ^
      |                typename 
```

Live link, until compiler explorer catches up to the revert: https://godbolt.org/z/zvT4jzqbv

I'd be happy to just add `typename` in this case if the language says it's supposed to be necessary here, but I'd be just as happy to not need to make any code changes :)

https://github.com/llvm/llvm-project/pull/75069


More information about the cfe-commits mailing list