mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
cmake: Fix fallthrough attribute detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8c2ad7bdd3)
This commit is contained in:
@@ -267,25 +267,21 @@ int main(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}" HAVE_MSC_THREAD_LOCAL_STORAGE)
|
}" HAVE_MSC_THREAD_LOCAL_STORAGE)
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# For detecting attributes we need to treat warnings as
|
||||||
|
# errors
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-Werror")
|
||||||
|
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#define FALL_THROUGH __attribute__((fallthrough))
|
#define FALL_THROUGH __attribute__((fallthrough))
|
||||||
|
|
||||||
enum direction_e {
|
|
||||||
UP = 0,
|
|
||||||
DOWN,
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
enum direction_e key = UP;
|
int i = 2;
|
||||||
int i = 10;
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (i) {
|
||||||
case UP:
|
case 0:
|
||||||
i = 5;
|
|
||||||
FALL_THROUGH;
|
FALL_THROUGH;
|
||||||
case DOWN:
|
case 1:
|
||||||
j = i * 2;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -332,6 +328,8 @@ int main(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}" HAVE_COMPILER__FUNCTION__)
|
}" HAVE_COMPILER__FUNCTION__)
|
||||||
|
|
||||||
|
# Stop treating warnings as errors
|
||||||
|
unset(CMAKE_REQUIRED_FLAGS)
|
||||||
|
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#define ARRAY_LEN 16
|
#define ARRAY_LEN 16
|
||||||
|
|||||||
Reference in New Issue
Block a user