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

    <tr>
        <th>Summary</th>
        <td>
            clang wrong diagnostic for unused-local-typedef
        </td>
    </tr>

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

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

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

<pre>
    Minimal repro code:
```cpp
template< typename T >
struct A
{};

template< template<typename> class TT >
void
f()
{
   struct inner
   {
      using foo = int;

      foo bar() const
      {
         return {};
 }
   };
}

int main()
{
    f< A >();
}
```

Building with clang 14 gives a wrong diagnostic:
```
$ clang++ -Wall -Werror test.cpp
test.cpp:11:13: error: unused type alias 'foo' [-Werror,-Wunused-local-typedef]
 using foo = int;
            ^
1 error generated.
```
Notice that the `foo` type is clearly used as a return type of the `bar` member function. But even if it was not, it should be considered part of the public interface and the diagnostic should not be emitted. Interestingly, removing the template-template parameter `TT` makes the issue go away.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VMGO8jgMfppwsUBtSgs99AAzP9Iedk8jzdlt3Da7aVIlLoh9-lVauqCZfxAKdmx_9mc7YAi6s0SVyM8if9_gxL3zlcH-htj8u6mduld_aqsHNOBp9A4ap0hkJ5G8i-QkimT5NuO43DANo0Emkb0B30eyOBB8gMh-LfbAfmoY1vjDWRzeRXZ-qN8hnvKKJrJf0BgMAT5ecK9Oq0VqhTwKWT4TzAIAPFJra8n_f_nqAABT0LaD1jkQ2Ttoy19qW7yivUa_JILG2cCv5i-YAOCJJ2_hC12IyrOQlz6s98upLcOA2v5EDNrYqtPcjMXlO9A6qFfc86SNinxvmvvYU9tBuodOXykAws0724HS2FkXWDffp_5Q5X4JFvIs5Bm2n2gMbD_Je-eBKfDuZT0eWnZK03hkIjvB7BmFyU6B1Lw4gEZjACEPrXNCHkDk5wemkG_bz8V1a1yDZhsDFLUiX_v58xzh5SPyx_akSwnQkSWPTGr3W6Z_OdYNAffIwD2BKJJYXJEsFesAjSH05g4zDYxdfIx-dnDtGha3p0hgoKEmD-1kG9bO7uA8MdCVLOgWNMMNA1jHQr5FLfRuMgpqmldOK_KkYETPK_A41UY3kS75FhsCtGo2PIe4gljHEYgGzZEu_BFjKLC2nbnHfJ4Gd41NjPHrM9yuQkyLAzH5yObjYyaD_1CY3XUIE0HnAG94321UlakyK3FDVVocZFKUUhabvlJl1pZlXjf7GlPKDsekzpJjVmZZq9qkyTe6komUqZRFmu8TWeyObY7lsc7TPD2qNknEPqEBtdkZcx12znebOXWVl4ek2BisyYT1v81X0WlbT10Q-8TowOEZxpoNVcsT-Lr30DoPv1u3zeRN1TOPIT4NeRHy0mnup3rXuEHIS0R__GxH7_6mhoW8zBUGIS9zkf8FAAD__x9Jpxw">