<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60084>60084</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang++ rejects specialization of template class that shadows a variable template
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ADKaster
      </td>
    </tr>
</table>

<pre>
    In the following creduced example https://gcc.godbolt.org/z/h34K8G4zM

```c++
namespace A {
template <typename T> T E;

template <typename> struct Formatter;
template <typename, typename> struct BetterResult;
}

template <typename T, typename E>
struct A::Formatter<A::BetterResult<T, E>> {
  void format(BetterResult<T, E>);
};
```

clang++ since version 11.0.0 (including main) rejects the use of the template parameter `E` in the declaration of the member function `format` of `struct A::Formatter<A::BetterResult<T, E>>`.

```
<source>:10:31: error: use of variable template 'E' requires template arguments
  void format(BetterResult<T, E>);
 ^
<source>:2:25: note: template is declared here
template <typename T> T E;
~~~~~~~~~~~~~~~~~~~~~ ^
```

This reproduces in C++14, C++17, C++20 and C++2a modes.

g++ trunk and msvc latest (per godbolt) accept the class template specialization.

It appears that clang is not recognizing that the template parameter `E` should shadow the variable template in namespace `A` of the same name. The error diagnostic does not reproduce if the namespace is not present.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVcvO4jYUfhqzOZrIcW6wyIKfH6rRqJuKFzD2IXHr2KntMJ1_0WevbAKEDtWoLQqJL-f6nc_H3HvVGcSWVG-kel_xKfTWtdv3L9wHdKuTld_azwZCj3C2WtuvynQgHMpJoAT8gw-jRuhDGD0ptoQdCDt0QmSdlSerQ2ZdR9jhg7BDX5Rf1j-VHz8T-k7odn7X9PoIwt7ik1YNH9CPXCBsgTTzYsBh1DwgkGIXvo0YheBIij0cYU-Kt6XZV7JR0gc3iQAH6wYeArq72ksFtoMXym8YNX9BP-nwcNu8_8g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