Issue 71397
Summary `-Wimplicit-fallthrough` suggests to use a macro from a random third-party library instead of `[[fallthrough]]`
Labels new issue
Assignees
Reporter HolyBlackCat
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to