<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99901>99901</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang doesn't warn on some cases of `-Wimplicit-fallthrough` that GCC catches
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
clang,
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ilovepi
</td>
</tr>
</table>
<pre>
When building LLD with GCC @4vtomat found that we don't emit diagnostics for certain types of nested switch statements. This was addressed in source in #99762, but I think we should probably catch this in Clang. If this is an intentional difference due to interpretation of some standard, then we should probably document that somehow.
The following godbolt example illustrates this https://godbolt.org/z/eGETvo5jq
clang -c example.cpp -Werror -Wimplicit-fallthrough
```c++
// The following run lines will succeed in clang and fail w/ gcc
// RUN: clang -c example.cpp -Werror -Wimplicit-fallthrough
// RUN: gcc -c example.cpp -Werror -Wimplicit-fallthrough
enum color { Blue, Red };
bool foo(color a, color b) {
bool different = false;
switch (a) {
case Blue:
switch (b) {
case Blue:
return different;
case Red:
different = true;
return different;
};
case Red:
switch (b) {
case Blue:
return different;
case Red:
different = true;
return different;
};
};
return different;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU2PozgQ_TXmUkpETAjhwCHd2YxGGu2h1as-G7sAzxqbtcvJ9v76lSEz3en52FWfJkIE7HqvXpXxswhB9xaxYeUdK4-ZiDQ432jjzjjprHXquXka0EIbtVHa9vDp0xEumgb4cH8PbJtvz-RGQdC5aBXQIAguCMpZxisCHDWB0qK3LpCWATrnQaInoS3Q84QBXAcWA6GCcNEkBwgkCEe0FNbwOOgAFxFAKOUxBFSgLQQXvcT0xHhR19WOM34PbST4CDRo-2eSEAYXjYLJu1a05hmkSOSUCLWFeyNsv4aP3XUkgLCgLaEl7awwoHTXoUcrEVREIDfP-skjiRSSdAc3YpJrlfAqSaDUqu_kVk7GVNHSnwQb3GXN8iPLD8v9cUDonDHukprcO9U6Q4B_i3EyCNqYGMgLwrDoHYimwIoD4yfGT9fwtfM946d_GD_hh98ez678_NfrHDLVDCv5hXYtpwlWT-i987B60uNktNS06oQxNHgX--EK3-XLJRm_S9cyOueGW-U-WjDaYoCLNgZClBKXRVuyC6ugE9rAJWF7KW-4Hv74nRUHeL_QG5peyneRzHe0cQTpjPPAqju4MxHTCj-gAlYdWXFtQuucgc45xvdLsEhRy2PLeJ3ASyQAwBz95csiYMUROmECfqVLQddtwPhefEMgRcBFS3F4Gb1FfZv258j080jR2xdpN4K-wh9QfRd9WxH5-Kqg_2R-3c2fZvpVK_xfSd5W-fb9h8gUeLsJM9UUqi5qkWGzqfhmt9vzcpsNTVt2vCu2G8nFPhd8L8t9JbEr93xb1JVSmW54zrd5xfmm2uRlsc5VV6lObips63JTbdg2x1FoszbmPCY7yXQIEZu6rvNNZkSLJsxHBedt7BlPvss4n_frm7fi8Mr201x5zHyTeFdt7APb5kYHCi-ZSJPBZvZlUA7DcoBchLfg7GK1aYnmA4Pt8h_s4F2-eGw6nWbHx5BFb5o3hqlpiO1aupHxU1Jw_VtN3n1GSYyf5sID46el9nPD_w0AAP__jzYxlA">