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

    <tr>
        <th>Summary</th>
        <td>
            clang mixes up `namespace` with `class`  in inheritance and `using namespace`
        </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>
    The following code is rejected by clang by ambiguous reference to `X`:

```c++
namespace X{
    struct X{

 };
}
using namespace X;
struct Y:X{};
//OK
//struct Y:X::X{};
```
The diagnostic is quite unreasonable:

```c++
<source>:7:10: error: reference to 'X' is ambiguous
    7 | struct Y:X{};
      |          ^
<source>:1:11: note: candidate found by name lookup is 'X'
    1 | namespace X{
 |           ^
<source>:2:12: note: candidate found by name lookup is 'X::X'
    2 |     struct X{
      |            ^
1 error generated.
```

There should not be any ambiguity because namespace `X` definitely cannot be treated as a candidate base type of struct `Y`, and the reference to `X` in `Y:X`  is clearly `X::X`.

As a comparison, directly using `X::X` without `using namespace` does not cause any error.

GCC and MSVC both accept the code.

[https://godbolt.org/z/xWxYMbMYs](https://godbolt.org/z/xWxYMbMYs)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU1v4zYT_jX0ZbAGRdqSfdDBsdfv4UVQoC3a5EhRY4ktTbr82I3764uR5ETeusWigqJQ1AzneZ75sIrRdA6xZusntj4sVE69D_WPOfYFF1IuGt9e6597hJO31n81rgPtWwQTIeBvqBO20FxBW-U6WqhzY7rsM30-YUCnEZIHVvIXVnImd4wfGL89Sz7emoknuoddp84YL0ojvLBq2gMAiClknWab0ydWHZi8bVWHcZEjQZ0fdTOZjnllcjccNfcWRyaOP_x__nZnLnePvG4sxlcSqzWqcz4mo0moP7JJCNkFVNE71Vj8Lh2Y3Eefg0YmPzO5q5jcFaQgYAg-0OJeYlG9MFFRwPckfIhXAav28C_cYbjI6P1i688PkRT0Rw9wPhEX0Mq1plWJyiS7oSJIerDe_54vBGlC9xGrGGI9zPUdiH9EIQiF-A8opiTOwYj3mH8rsge6zDAVYzKgQ4dBJWyXD2vivTICQux9ti2BhgZBuVvPmHSFBrXKEWeyTI0DLZ6MMwntlWhOzikgxQQVQc3YNyoipOsFwZ9uhFjJXwmO2INyLaQeHzYoGDeakkIlBxJNW1TBXkeTSbySL-fMdgMAf76oYKJ3FKU1AXWyVxg78d4ZvprU-zzA-qZTB7Ie4yDQqAZpNMh8F_N_-5HK80-_7KHxqQelNV7SwI1m1J01Wz_1KV0iYRj6uvNt421a-tAxcfyTiePbr2-vz83za2TrAxOb7zcX20Vby3Yrt2qBdVEJIVdVUfFFX0u-beQGTyiLpqmE5lWplBRivd5shFDVwtSCixWvJC_kqiz4Elcr0W7balPyRha8YiuOZ2Xs0tovZwq_MDFmrAteFJvtwqoGbRzGtxDDFGZC0CQPNTl8anIX2YpbE1P8OCKZZLEeh_bZvGGEfKFc3GWBckSb2qoYx2JwYFyPwSRFZUPqP0zgIgdbf6OfSX1ultqfmTgSjunfp0vw9DPCxHHgFZk4TtS-1OKvAAAA__902-5J">