1 static enum ENUM_TYPE_A
{ VALUE_A
} var_a
;
2 static enum ENUM_TYPE_B
{ VALUE_B
} var_b
;
3 static enum /* anon. */ { VALUE_C
} anon_enum_var
;
6 static void take_enum_of_type_a(enum ENUM_TYPE_A arg_enum
)
11 static void take_int(int arg_int
)
16 static void always_ok(void)
20 var_a
= (enum ENUM_TYPE_A
) VALUE_B
;
21 var_b
= (enum ENUM_TYPE_B
) i
;
23 anon_enum_var
= VALUE_C
;
27 var_a
= (enum ENUM_TYPE_A
) 0;
28 anon_enum_var
= (__typeof__(anon_enum_var
)) 0;
29 anon_enum_var
= (__typeof__(anon_enum_var
)) VALUE_A
;
34 take_enum_of_type_a(var_a
);
35 take_enum_of_type_a(VALUE_A
);
38 switch (anon_enum_var
) {
41 take_int(anon_enum_var
);
51 static void trigger_enum_mismatch(void)
57 take_enum_of_type_a(var_b
);
58 take_enum_of_type_a(VALUE_B
);
61 switch (anon_enum_var
) {
64 take_enum_of_type_a(anon_enum_var
);
65 take_enum_of_type_a(VALUE_C
);
68 // this has been already working in sparse 0.4.1
70 var_b
= anon_enum_var
;
71 anon_enum_var
= var_a
;
73 // implemented after sparse 0.4.1
76 anon_enum_var
= VALUE_A
;
79 static void trigger_int_to_enum_conversion(void)
84 take_enum_of_type_a(i
);
85 take_enum_of_type_a(7);
91 var_a
= (int) VALUE_A
;
92 var_a
= (int) VALUE_B
;
95 static void trigger_enum_to_int_conversion(void)
109 * check-name: enum-common
110 * check-description: common part of the test for -Wenum-mismatch, -Wenum-to-int and -Wint-to-enum
111 * check-command: sparse -Wno-enum-mismatch -Wno-int-to-enum $file