[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation
Nathan Chancellor via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 18 06:05:23 PST 2019
nathanchance added a comment.
As a follow up to my previous post, I have sent patches to clean up all of the warnings that I see in the Linux kernel. However, I found one that I do believe is a false positive:
../drivers/staging/uwb/allocator.c:353:3: warning: misleading indentation; statement is not part of the previous 'else' [-Wmisleading-indentation]
alloc_found:
^
../drivers/staging/uwb/allocator.c:350:2: note: previous statement is here
else
^
1 warning generated.
Corresponding to https://github.com/torvalds/linux/blob/2187f215ebaac73ddbd814696d7c7fa34f0c3de0/drivers/staging/uwb/allocator.c#L346-L353.
Simplified:
$ cat test.c
int a(int b, int c) {
if (b)
goto label;
if (c)
return 0;
label:
return 1;
}
$ clang -Wmisleading-indentation -o /dev/null -c test.c
test.c:8:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
label:
^
test.c:5:2: note: previous statement is here
if (c)
^
1 warning generated.
goto labels are unaffected by indentation so there should be no warning here. While I think that the labels should be unindented for style, the driver is marked as obsolete and is scheduled to be deleted so I am not sure such a patch would be welcomed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70638/new/
https://reviews.llvm.org/D70638
More information about the cfe-commits
mailing list