aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2017-08-25 10:00:08 +0200
committerAndreas Schneider <asn@cryptomilk.org>2017-08-25 10:06:00 +0200
commita9846ccc0d559af3db6dba07f2183219c846b617 (patch)
tree90522feecd55e4f24fc11c2db19a7189e2bfd7de
parent7204d2f48556210e3e6894aebb20db24819a3e86 (diff)
downloadlibssh-a9846ccc0d559af3db6dba07f2183219c846b617.tar.gz
libssh-a9846ccc0d559af3db6dba07f2183219c846b617.tar.xz
libssh-a9846ccc0d559af3db6dba07f2183219c846b617.zip
cmake: Add check for fallthrough attribute
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--ConfigureChecks.cmake27
-rw-r--r--config.h.cmake2
2 files changed, 29 insertions, 0 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index f5645807..3e497dcb 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -243,6 +243,33 @@ int main(void) {
}" HAVE_MSC_THREAD_LOCAL_STORAGE)
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("
#include <string.h>
int main(void)
diff --git a/config.h.cmake b/config.h.cmake
index 3f34f09b..f8869df7 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -167,6 +167,8 @@
#cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1
#cmakedefine HAVE_MSC_THREAD_LOCAL_STORAGE 1
+#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
+
#cmakedefine HAVE_GCC_VOLATILE_MEMORY_PROTECTION 1
#cmakedefine HAVE_GCC_NARG_MACRO 1