summaryrefslogtreecommitdiffstats
path: root/ConfigureChecks.cmake
diff options
context:
space:
mode:
authorAnoop C S <anoopcs@redhat.com>2017-07-15 20:54:06 +0530
committerAndreas Schneider <asn@samba.org>2017-07-27 09:54:58 +0200
commitceb17676cba178f56d00d21189c3f1765e5c2ae0 (patch)
treec9a627a4a7b54388d63477d089043790d753399e /ConfigureChecks.cmake
parent908834465e11736796e418dfdee6425f71959590 (diff)
downloadsocket_wrapper-ceb17676cba178f56d00d21189c3f1765e5c2ae0.tar.gz
socket_wrapper-ceb17676cba178f56d00d21189c3f1765e5c2ae0.tar.xz
socket_wrapper-ceb17676cba178f56d00d21189c3f1765e5c2ae0.zip
swrap: Suppress intentional fall through warning
-Wimplicit-fallthrough compiler flag introduced with gcc v7 results in the following warning during compilation: [ 7%] Building C object src/CMakeFiles/socket_wrapper.dir/socket_wrapper.c.o src/socket_wrapper.c: In function ‘sockaddr_convert_to_un’: src/socket_wrapper.c:1846:18: warning: this statement may fall through [-Wimplicit-fallthrough=] case AF_UNSPEC: { ^ /src/socket_wrapper.c:1866:2: note: here case AF_INET: ^~~~ Default level for -Wimplicit-fallthrough(which is 3) allows us to get rid of the above warning using specific comments made within switch cases matching the regular expressions outlined in gcc docs[1]. But for us the presence of preprocessor directives in the vicinity of such comments nullifies its effect[2]. So our best bet would be to make use of the reliable fallthrough attribute and supress such warnings in future. [1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77817 Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'ConfigureChecks.cmake')
-rw-r--r--ConfigureChecks.cmake27
1 files changed, 27 insertions, 0 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 0691c8a..cb2ea92 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -198,6 +198,33 @@ int main(void) {
}" HAVE_DESTRUCTOR_ATTRIBUTE)
check_c_source_compiles("
+#define FALL_THROUGH __attribute__((fallthrough))
+
+enum direction_e {
+ UP = 0,
+ DOWN,
+};
+
+int main(void) {
+ enum direction_e key = UP;
+ int i = 10;
+ int j = 0;
+
+ switch (key) {
+ case UP:
+ i = 5;
+ FALL_THROUGH;
+ case DOWN:
+ j = i * 2;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}" HAVE_FALLTHROUGH_ATTRIBUTE)
+
+check_c_source_compiles("
__thread int tls;
int main(void) {