<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/71397>71397</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`-Wimplicit-fallthrough` suggests to use a macro from a random third-party library instead of `[[fallthrough]]`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
HolyBlackCat
</td>
</tr>
</table>
<pre>
Here's the code:
```cpp
#define FMT_FALLTHROUGH [[fallthrough]]
void a();
void b(int x)
{
switch (x)
{
case 1:
a();
case 2:
a();
}
}
```
When compiled with Clang 17 (or trunk), it says:
```none
<source>:11:7: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
11 | case 2:
| ^
<source>:11:7: note: insert 'FMT_FALLTHROUGH;' to silence this warning
11 | case 2:
| ^
| FMT_FALLTHROUGH;
<source>:11:7: note: insert 'break;' to avoid fall-through
11 | case 2:
| ^
| break;
```
Notice how it suggests using `FMT_FALLTHROUGH` instead of `[[fallthrough]]`, presumably because it finds a macro that expands to this attribute.
Now this is clever in theory, but in my case, the macro comes from a third-party library (libfmt in this case), and I wouldn't want to use their internal macro in my code.
I suggest that this warning should suggest always suggest `[[fallthrough]]`, never a macro.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVVGPmzgQ_jXOyygRmATCAw_ZtLmt1OtJp576eBpgAr41dmQPS_PvTwaSTbNbbU8XoWBmhpnv-2Zs0HvVGKJCbB7E5sMCe26tKx6tPj9orJ72yIvS1ufikRwJmXnglqCyNYlkJ6IPItqJNJqu6nSaLTKp6agMweH3r38fdp8_f33884-_fnuEscrDEbXm1tm-acXmQ7im18b_Z6tqQCG3QuYieXjlKoXcKsPwPfgnZzZHAQD4QXHVgpDbl4Bg_yEIoEJPEF85wPy7rzvFyffjxgoXHtfFRZnp8VtLBirbnZSmGgbFLew1mgbiLOC1Dtj15inklXtQ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