diff options
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; + } +} |