[llvm-bugs] [Bug 32648] New: Incorrect clang syntax warning with -Wgcc-compat
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 12 15:53:58 PDT 2017
http://bugs.llvm.org/show_bug.cgi?id=32648
Bug ID: 32648
Summary: Incorrect clang syntax warning with -Wgcc-compat
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: cmtice at google.com
CC: llvm-bugs at lists.llvm.org
When I compile the test file below (taken from a larger real program) clang
raises the following warning unless gcc-compat is disabled:
clang_gcc_compat.c:17:13: warning: 'break' is bound to current loop, GCC binds
it to the enclosing loop [-Wgcc-compat]
} while(__m(1));
^
clang_gcc_compat.c:8:3: note: expanded from macro '__m'
break; \
^
1 warning generated.
/usr/x86_64-cros-linux-gnu/usr/lib/../lib64/Scrt1.o:function _start: error:
undefined reference to 'main'
clang-4.0: error: linker command failed with exit code 1 (use -v to see
invocation)
Since the break statement is clearly part of the switch construct and not in
any way, shape or form referring to the loop, this is an erroneous, confusing
warning.
The source code for clang_gcc_compat.c is below:
/* x86_64-cros-linux-gnu-clang tmp/clang_gcc_compat.c */
#define __m(x) \
({ \
switch (x) { \
case 1: \
{ \
break; \
} \
} \
42; \
})
void f() {
for (;;) {
do {
} while(__m(1));
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170412/4d01b89d/attachment.html>
More information about the llvm-bugs
mailing list