diff options
author | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2017-06-02 18:32:58 (GMT) |
---|---|---|
committer | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2017-06-03 06:38:51 (GMT) |
commit | 8d7b3ef5d42c07dffe1f84af14b0055d288e4376 (patch) | |
tree | 5b7a772ab56138a24ada6c3a103e5c37863be32b /Source/Checks | |
parent | 0068224fdd7569f02dffe9fd8de2e6ce0c7abc28 (diff) | |
download | CMake-8d7b3ef5d42c07dffe1f84af14b0055d288e4376.zip CMake-8d7b3ef5d42c07dffe1f84af14b0055d288e4376.tar.gz CMake-8d7b3ef5d42c07dffe1f84af14b0055d288e4376.tar.bz2 |
Provide and use CM_FALLTHROUGH
Diffstat (limited to 'Source/Checks')
-rw-r--r-- | Source/Checks/cm_cxx_attribute_fallthrough.cxx | 11 | ||||
-rw-r--r-- | Source/Checks/cm_cxx_fallthrough.cxx | 11 | ||||
-rw-r--r-- | Source/Checks/cm_cxx_features.cmake | 7 | ||||
-rw-r--r-- | Source/Checks/cm_cxx_gnu_fallthrough.cxx | 11 |
4 files changed, 40 insertions, 0 deletions
diff --git a/Source/Checks/cm_cxx_attribute_fallthrough.cxx b/Source/Checks/cm_cxx_attribute_fallthrough.cxx new file mode 100644 index 0000000..df43625 --- /dev/null +++ b/Source/Checks/cm_cxx_attribute_fallthrough.cxx @@ -0,0 +1,11 @@ +int main(int argc, char* argv[]) +{ + int i = 3; + switch (argc) { + case 1: + i = 0; + __attribute__((fallthrough)); + default: + return i; + } +} diff --git a/Source/Checks/cm_cxx_fallthrough.cxx b/Source/Checks/cm_cxx_fallthrough.cxx new file mode 100644 index 0000000..7b35a5f --- /dev/null +++ b/Source/Checks/cm_cxx_fallthrough.cxx @@ -0,0 +1,11 @@ +int main(int argc, char* argv[]) +{ + int i = 3; + switch (argc) { + case 1: + i = 0; + [[fallthrough]]; + default: + return i; + } +} diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index 76c823c..c3835c3 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -38,6 +38,13 @@ endfunction() cm_check_cxx_feature(auto_ptr) cm_check_cxx_feature(eq_delete) +cm_check_cxx_feature(fallthrough) +if(NOT CMake_HAVE_CXX_FALLTHROUGH) + cm_check_cxx_feature(gnu_fallthrough) + if(NOT CMake_HAVE_CXX_GNU_FALLTHROUGH) + cm_check_cxx_feature(attribute_fallthrough) + endif() +endif() cm_check_cxx_feature(make_unique) if(CMake_HAVE_CXX_MAKE_UNIQUE) set(CMake_HAVE_CXX_UNIQUE_PTR 1) diff --git a/Source/Checks/cm_cxx_gnu_fallthrough.cxx b/Source/Checks/cm_cxx_gnu_fallthrough.cxx new file mode 100644 index 0000000..6021094 --- /dev/null +++ b/Source/Checks/cm_cxx_gnu_fallthrough.cxx @@ -0,0 +1,11 @@ +int main(int argc, char* argv[]) +{ + int i = 3; + switch (argc) { + case 1: + i = 0; + [[gnu::fallthrough]]; + default: + return i; + } +} |