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

    <tr>
        <th>Summary</th>
        <td>
            clang does not handle _Static_assert() in switch statement
        </td>
    </tr>

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

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

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

<pre>
    Any _Static_assert() in leg of switch statement generates error from expected: expression. This works with gcc.

Example:
$ cat switch-assert-bug.c 
/* Simple program to show that clang cant do Static_assert in switch */
unsigned foo(unsigned x)
{
        unsigned m = 0;

        _Static_assert(1, "assert in function works");
        if (x == 1) {
                _Static_assert(1, "assert in if works");
                m |= 1;
        }
        switch (x) {
        case 2:
        case 3:
                _Static_assert(1, "assert in switch works");
                m |= 2;
                break;
        default:
                m |= 4;
        }
        return m;
}
$ clang -c switch-assert-bug.c
switch-assert-bug.c:14:3: error: expected expression
                _Static_assert(1, "assert in switch works");
                ^
1 error generated.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE9vuzgQ_TTDZZQIbAhw4JA2zRfo3itjBvAW7Mg2m_Tbrwzkz2ZbqdIvhwAe-70343kjnFOdJqoge4HsEInJ98ZWrqdxVLojG9Wm-ar2-gs_3r3wSn4I58h6YAWwEpXGgTo0Lbqz8rJH54WnkbTHjjRZ4ckhWWssttaMSJcTSU8N8H14t-ScMnqLf_XK4dnYT4dn5XvspNxCfIB4v_y_XcR4Ggj4-g0sRSn8yrpZNG3qqdtKvO44Atvjuwrn8GRNZ8WI3qDrzRl9LzzKQegOpdAeG4P_SS8ktmYEbMaaQSc9l6vB1hhgxe3zAqxcafOXq-7yFh4R-AFj4C-POUFc_q-mCbBXBMbuKtpJS6-MXqoDjAWqO1CpWgRWXAJDIEnCrTyK-B2Lan_Ch7gcEfLXBfwxkB9u77dSFZdnfikcIbtf3LrCH1d-p3El-YVO9hSoLYnPx7WGWjEN_knD7Xz6U56W_GQ1jvf4LRgacu6njfyuK5dd3wX4PkmB7_lsieCU1RuzTx5MsiDg0-_P6vaMBtnbEkhW015N3KxujJqKNyUvRURVkscZ36U7VkZ9VbA8L0rJd1yWSdbWXCY8YVnC4yLO6jSLVMVilsZJsotjxtNyy-WuzWsSRZLxJC1zSGMahRq2w_DPuDW2i5RzE1V5wZI8GkRNg7uOKVuFTaGADtJ4UM67-zGv_EDVchmNIYfaeOyFbgb6cYg9T69oskPVe39yoUfCKDl2yvdTvZVmBHYMZOtjc7Lmb5Ie2HEW7IAdZ83_BgAA__-Jz5Wp">