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

    <tr>
        <th>Summary</th>
        <td>
            diag::warn_unused_but_set_parameter doesn't work for variables with template type
        </td>
    </tr>

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

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

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

<pre>
    DiagnoseUnusedButSetDecl is only called from SemaDecl while the type is still a dependent type. DiagnoseUnusedDecl is explicitly called after template instantiation, but not DiagnoseUnusedButSetDecl. Looks like the entry in the RefsMinusAssignments map which is needed by DiagnoseUnusedButSetDecl is also cleared before template instantiation.

FWIW, gcc does issue this warning in at least some cases.  https://godbolt.org/z/dod8GT8zf
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1ksGOmzAQhp8GLlYRwUDIgUO20VaV2ku31R6jAQ_gxtjIHjbNPn3HrFarVoqEgWGG398_ns6pW3vSMFoX8JddA6qHlZ6QTtgboYNw1txED8agEoN3s3jCGbbkddIGBU28bgvG2kDaGAFC4YJWoaUtk4l_9d-V8c9idK_pQx8GQi8I58UAsaINBJY0kHY2KT6LbiVhHYl7vJn45twlCKMvb2CM4G-sswU_cAjfNf9yDEGPduZkEDMs0Ug_RSKLqBiju93dIVaBCU70BsHHWhycxzvMWZKfkvz4dn98_vocTYx9L5TDwFJhjZgseQVvtR0jKZBg6UAiuBm5MQFDJsREtIREHpPika_Rqc4ZypwfOXrlpZxqvvxsXocU211dHcq63h12qWqlOsgDpMRtxlaxqygij3HD87qZO3NXzwHpvICHGeMJRDxu-J7E1fmLYIfiBbyGzjD2VdP04TcecLp60_5HyEVrl_Vu5sCYl_fHp8W739gTh5v9wC9V3TRNOrWl7EDm-0KWNRTDrlGylkNTSqgA9sOQpwY6NKFNqoekKHoDNprhmbTE08afkuqU6rbIiyJv8mLXlIcqz5pO1jjUEqCupRqKpMx5gLXJIk7sYOrbjaxbx8BJowOFjyRss4K47cr6sNLkfEtuWdD36Wai3Rz8BXoWI1k">