You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use of __builtin_unreachable(); where a break; would otherwise be used should suppress a missing break in switch statement warning.
Environment
Operation system name and version: macOS 10.12
OCLint version: 0.13
How OCLint is installed: homebrew install
Reproduction Steps
This came to my attention because the korn shell project has had to inset quite a few __builtin_unreachable(); statements to silence static analysis warnings. This is a consequence of its errormsg() interface not returning, executing a longjmp() instead, when certain arguments are used.
Sample code
case '?': {
errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
__builtin_unreachable();
}
Expected Behavior
Using __builtin_unreachable();, or function call with an equivalent annotation, as the last statement in a case: block should inhibit the warning about a missing break statement.
Actual Behavior
Warnings such as src/cmd/ksh93/bltins/cd_pwd.c:328:9: missing break in switch statement [convention|P2].
Even Better
Feel free to clone https://github.com/att/ast/, configure the build with meson -C build, then run oclint over all the code via bin/lint all. It's a gold mine of bad practices 😄
The text was updated successfully, but these errors were encountered:
Also, goto a_label; as the last statement in a case block should be treated as equivalent to break;. Personally I would never write code like that but there are quite a few instances in the ksh source where they use it as an early exit. It's usually this pattern:
int a_fun() {
for(...) {
switch (n) {
case 1:
goto done;
case 2:
// stuff
break;
}
}
done:
// stuff
return n;
}
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment.
The ksh project I was contributing to was killed a year ago and I'm currently working with the Go language so this is no longer an issue for me. Hopefully this has either already been resolved or this issue will serve as a starting point for someone else who would benefit from the feature.
Issue Summary
Use of
__builtin_unreachable();
where abreak;
would otherwise be used should suppress amissing break in switch statement
warning.Environment
Reproduction Steps
This came to my attention because the korn shell project has had to inset quite a few
__builtin_unreachable();
statements to silence static analysis warnings. This is a consequence of itserrormsg()
interface not returning, executing alongjmp()
instead, when certain arguments are used.Sample code
Expected Behavior
Using
__builtin_unreachable();
, or function call with an equivalent annotation, as the last statement in acase:
block should inhibit the warning about a missingbreak
statement.Actual Behavior
Warnings such as
src/cmd/ksh93/bltins/cd_pwd.c:328:9: missing break in switch statement [convention|P2]
.Even Better
Feel free to clone https://github.com/att/ast/, configure the build with
meson -C build
, then run oclint over all the code viabin/lint all
. It's a gold mine of bad practices 😄The text was updated successfully, but these errors were encountered: