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

    <tr>
        <th>Summary</th>
        <td>
            Clang c++ compiles error with struct in template class and < operator
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Please consider the following code:

```c++
template<class T>
class confused{};

template<class T>
class test
{
    void foo() {
        if(this->b.confused < 1);
    };

    struct bar
 {
        int confused;
    } b;
};
```
Clang rejects it by giving such considerably puzzling output:

```c++
<source>:8:32: error: expected '>'
    8 |         if(this->b.confused < 1);
      | ^
<source>:8:29: note: to match this '<'
 8 |         if(this->b.confused < 1);
      | ^
<source>:8:32: error: expected unqualified-id
    8 | if(this->b.confused < 1);
      | ^
<source>:8:33: warning: if statement has empty body [-Wempty-body]
 8 |         if(this->b.confused < 1);
      | ^
<source>:8:33: note: put the semicolon on a separate line to silence this warning
1 warning and 2 errors generated.
Compiler returned: 1
```

We suppose that's because the compiler has found incorrect local variable name of `confused` by confusing the global template class declared above with the integer member variable declared in the nested class `bar` inside `test`

Please check [https://godbolt.org/z/7afqsvEvo](https://godbolt.org/z/7afqsvEvo).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8Vc2SozYQfhr50mUXSLaBAwfbMz7nkKo9C9GAEiGx-vFk9ulTDWY8M5utbKWSuChMi_7_uj9kCLq3iDU7nNnhaSNTHJyvX6TtG5cfNo1rX-tfDMqAoJwNukUPcUDonDHuRdselGuRiRPLnli23o_ZcinGz3TNpxHHyciITFyUkSHAr0w8L68WWTnbpYAtK86seGLi_N7n31pHDPFuUNwtAQBuTrfQOcd4yXgFH97RT3eMl3HQYcvEc7NbcwAmLpAzXr2lQcrfp0WnIfqkIjTS38--D2Ljo7pPDqF5uH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