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

    <tr>
        <th>Summary</th>
        <td>
            Code rejected with `error: 'nodiscard' attribute cannot be applied to types`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    The following code is accepted by GCC but is rejected by clang with the error `error: 'nodiscard' attribute cannot be applied to types`.

```C++
class C;

namespace N {
__attribute__((visibility("default"))) [[nodiscard]] C frob();
}
```

If the function `frob` is moved outside of the namespace `N` then both compilers accept it.  Swapping the order of `__attribute__((visibility("default")))` and `[[nodiscard]]` also makes both compilers happy.

https://godbolt.org/z/GhGYq8dxd

Versions 3.3 - 17.0.1 of clang are affected.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU8lu2zAQ_RrqMohAkdF20CG24aCXXFoU6MngMrKYUqJKUnHdry8ou3ES9FQUILTM-uYNnwjBHCfEjpQbUu4yscTB-U5IiefnTDp97r4MCL2z1p3MdATlNIIJIJTCOaIGeYbH7RbkEpPZ4zOqq1lZMR3hZOIAcUBA750HUtH1g_AHIKyenDZBCa8Jq0HE6I1cIoIS0-QiSAQxz9aghuggnmcMpKI5oTtCH67Pil7OlrBNOqtVWRECbAnfvI2dxIhhFgrhCUh9dR0Or20PB8IawpoXE4w01sTz-s809mKxkTBGWHs5sPK1ucEvd6TcwRZ67-Sa1d6a17sPWN-C-tSv7PTLpKJxUyJorVHRxOfoXlCDW2IwGsFdYm9zkIo-pcg44ATSxQGUG2dj0f_ZEJiYA3w-iXlO60vpzmv0qRap6L9Nn1qKSacCf-Vh9dvgYBTfMXwENoh5Pr9b4hDjHAh_IGxP2P7otHQ25s4fCdv_Imz_ODx--9Hon_pt0lf0wbgpAM853EFR5zQv0liXeyc8guj79Ta-a5bpjuuWtyLDrqhpwYuiKVk2dJXSVDY93ouy0bShXNaK1qrSFdeiKovMdIwyXhScUsZrzvK651i1teCqbgrVtuSe4iiMza19GRP-zISwYFfzpqWZFRJtWJXG2IQnWJ2J13KX-S7l3MnlGMg9tSbEcKsSTbTYbZP0XgW26uo_qClbvO0-LMDEYZG5ciNh-wTi-rqbvUvdCduv0ANh-3W03wEAAP__qYRS7Q">