type_is_ok(), used to calculate the base type of enums, has a bug related to UB when doing a full width rshift. Add a testcase for this. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- validation/bug-rshift-ub.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 validation/bug-rshift-ub.c diff --git a/validation/bug-rshift-ub.c b/validation/bug-rshift-ub.c new file mode 100644 index 000000000..3a5f3a577 --- /dev/null +++ b/validation/bug-rshift-ub.c @@ -0,0 +1,17 @@ +enum a { + A = ~0ULL, +}; + +static enum a a = A; + +/* + * check-name: bug-rshift-ub + * check-known-to-fail + * check-description: + * This test trigger(ed) a bug on x86 caused by a + * full width shift (which is UB), expecting to get + * 0 but giving the unshifted value and as result + * the type is invalid: + * warning: incorrect type in initializer (invalid types) + * expected bad type enum a static [toplevel] a + */ -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html