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

    <tr>
        <th>Summary</th>
        <td>
            clang 17.0.2: No "unreachable code" warning if source file included in another source file
        </td>
    </tr>

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

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

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

<pre>
    When compiling unreachable_warning.cpp (with the content below) using option -Wunreachable-code-break, a warning is triggered as expected:
```c++
void f(int i)
{
    switch (i)
    {
 case 3: return; break;
    }
}
```
The warning emitted:
```console
[user@host]$ clang++ -c -Wunreachable-code-break unreachable_warning.cpp
unreachable_warning.cpp:5:25: warning: 'break' will never be executed [-Wunreachable-code-break]
        case 3: return; break;
                        ^~~~~
1 warning generated.
```

However if unreachable_warning.cpp is wrapped in another source file (as is frequently done in "unity builds" or "jumbo builds") then the warning is no longer emitted:
```
[user@host]$ cat unity_build.cpp
#include "unreachable_warning.cpp"

[user@host]$ clang++ -c -Wunreachable-code-break unity_build.cpp
[user@host]$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE2P4jgQ_TXOpQRKKuTrkAMsi_a0p5XmOHLsSuIZY2f90Uxf-revDJmmtwWrlcayDJQf5Vevns29V5Mh6ll1YNUx4zHM1vXLd9012WDla_9lJgPCnhellZkgGkdczHzQ9PXCnVFm2oplAYbtRYUZwkwgrAlkAgyk7YVhB9Gnv9olKGtg8-VDjo2wkjaDI_6d4W_AYc0JykNwaprIkQTugX4sJAJJVu5ZfmT5ntX5bQqGhzSv0RerJIwMW2UCKIbdCm7WfQAAf1FBzInxHZDid5DgnqBk5R4chegMKw9w41gePuKPP7MfP3G6_fxrpvd66KzCY_rWeKtpjVaH6MmxXT5bH1h1ZLgDobmZbkXCRjzV71lrbpmfbZb7ipV7TMtPrukrw2ZtSgMXpTUYeiEHAwH9IBEDSWDV4Wkrq-NdpjT-n6CPBqt-f3t7e7uBinc5JzLkeCC5faj8bf3DXq6s1fjUtsrDxfFlIQnKADc2zOTA2-gEwag0JZtwn3Cjo78jmaBfQVpDCc8Qo1HhFYaotPQMEaxL0W_xPNh7NN2BkO5R-OAI5cFY0NZM5J7b4798wQNcj_96Pejea4alMkJHSTeGjzuP-FGrX3TeIxYPMn4qLpN9Kbuy4xn1Rd21HWK1a7O573Z1U4h6lKLNm3rohq4csZGC2hqbmmSmesyxLIoci7yqdu1WtpUcx6Go27GteINsl9OZK73V-uW8tW7KlPeR-qbId3Wm-UDaXx89xLVKTO-f6xN-M8TJs12ulQ_-niGooKm_wqFotvkWk6P_tJ9UhqRM8sJ7p8d_OWrtzTPHZdHpfg5h8ckNeGJ4mlSY47AV9szwlOisH5vF2W8kAsPTtTrP8HQt8J8AAAD__4LNznA">