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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Fails to diagnose `return;` in non-void function in class template
        </td>
    </tr>

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

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

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

<pre>
    ## Program
```cpp
template <class T> struct S {
  T f;
  S() : f() {}
  S foo() {
    return;
  }
};

int main() {
    S<int> f,g;
}
```
Repro: https://godbolt.org/z/cf7oTvqfa
✅ GCC correctly rejects with a diagnostic.
❌ Clang accepts, unless the function is called.
When the return type of function `foo` is changed from `S` to `int`, Clang does reject the code.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxkUk2PnDoQ_DXNpbUj03wfOMwyy7s-vVnp5eoxBhwZm9hmos2vjwwz2lUiIWh1u5qqcnHv1WSkbKF4heKS8C3M1rXfjOI2udnhowXKgDL819nJ8QXYGUp2PGJdgZ2DXFbNg0TIOqG59_gO2Rv64DYR8IpQvQI7I77jCNlRXoFqoAYhO-P4rKtXqC7HGEdrv7RjD9HJsDnzXHGcje-9AeysTMCFK_MX8ApZp0yIpEagbnogjgVPLcDO_8nV2UhpDmH1kJ2BeqB-ssPN6nCybgLqfwH1Yqzs-_3HyOOCN4Kmg7rAf7oOhXVOiqA_0MnvUgSPP1WYkeOg-GSsD0qcnqAL1B12mpsJuRByDR6ow81o6T2GWeK4GRGUNag8Cq61HCL2_1mafXz4geFjlWjHz9NQsmhfyXbczM0kBxydXeLkGvvBxjJaUrL4z4PEYKV_0N73CzvIUzK02dBkDU9km1ZFVjV1zZpkbkWaVjQ2rKIir6v8xinPmzG9lelANSOWqJYYFayiJs2JsfpUpvmY5SyXmczLLE0hZ3LhSp-0vi_R3UR5v8k2LdK0KBPNb1L7PZZEIjIEophQ10bAy22bPORMKx_854qggt6zvGuC4oI9V9pHyY8rkFH7Z5aiTQaNNS93q4Yvnhs8wvyMd7I53f6RDBXm7XYSdgHqI4XH52V1NtoI1O-SPFD_UHVv6XcAAAD__154ByI">