Skip to content

No -Wempty-body warning for empty body with a prefix label #19251

@chengniansun

Description

@chengniansun
Bugzilla Link 18877
Version trunk
OS Windows NT
CC @zygoloid,@zhendongsu

Extended Description

For the following statement:
if (i) a:;
Clang does not warn that the body is empty.

$: cat s.c
void f(int i) {
if (i) a:;
}
$: clang-trunk -Wempty-body -c s.c
$: gcc-trunk -Wempty-body -c s.c
s.c: In function ‘f’:
s.c:2:12: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
if (i) a:;
^
$: clang-trunk --version
clang version 3.5 (trunk 201498)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions