Issue 129060
Summary [Clang][diagnostics] The location marking that structured binding shadows template parameter is not clear
Labels clang
Assignees
Reporter zwuis
    ```cpp
template <typename T> void test1() {
  using arr = int[1];
  auto [T] = arr{};
}
```

Current diagnostics:

```txt
<source>:3:8: error: declaration of 'T' shadows template parameter
    3 |   auto [T] = arr{};
 |        ^
<source>:1:20: note: template parameter is declared here
 1 | template <typename T> void test1() {
      | ^
```

Expected diagnostics:

```txt
<source>:3:9: error: declaration of 'T' shadows template parameter
    3 |   auto [T] = arr{};
      | ^
<source>:1:20: note: template parameter is declared here
    1 | template <typename T> void test1() {
      |                    ^
```

It becomes more obvious if we add new line characters between '[' and ']':

```cpp
template <typename T> void test2() {
  using arr = int[1];
 auto [
    T
  ] = arr{};
}
```

Current diagnostics:

```txt
<source>:8:8: error: declaration of 'T' shadows template parameter
    8 |   auto [
      |        ^
<source>:6:20: note: template parameter is declared here
    6 | template <typename T> void test2() {
      |                    ^
```

Expected diagnostics:

```txt
<source>:9:5: error: declaration of 'T' shadows template parameter
    9 |     T
      |     ^
<source>:6:20: note: template parameter is declared here
    6 | template <typename T> void test2() {
      |                    ^
```

Compiler Explorer: <https://godbolt.org/z/oEPdWaabK>

I believe this can be a good-first-issue.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to