Currently, type_difference() doesn't make a distinction between enums & ints. Add some testcases for this and mark the test as 'known-to-fail'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- validation/typediff-enum.c | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 validation/typediff-enum.c diff --git a/validation/typediff-enum.c b/validation/typediff-enum.c new file mode 100644 index 000000000..4c97bcf6c --- /dev/null +++ b/validation/typediff-enum.c @@ -0,0 +1,83 @@ +enum num { ZERO, ONE, MANY, }; +typedef enum num num; + +extern int v; +num v = 0; + +extern num w; +int w = 0; + +int foo(void); +num foo(void) { return ZERO; } + +num bar(void); +int bar(void) { return ZERO; } + +void baz(int a); +void baz(num a) { } + +void qux(num a); +void qux(int a) { } + +void pin(int *a); +void pin(num *a) { } + +void pni(num *a); +void pni(int *a) { } + + +static num oprn(void) { return ZERO; } +static int opri(void) { return ZERO; } + +static void opai(int a) { }; +static void opan(num a) { }; + + +struct ops { + int (*opri)(void); + num (*oprn)(void); + void (*opai)(int); + void (*opan)(num); +}; + +static struct ops ops_ok = { + .opri = opri, + .oprn = oprn, + .opai = opai, + .opan = opan, +}; + +static struct ops ops_ko = { + .opri = oprn, + .oprn = opri, + .opai = opan, + .opan = opai, +}; + +/* + * check-name: typediff-enum + * check-known-to-fail + * + * check-error-start +typediff-enum.c:5:5: error: symbol 'v' redeclared with different type (originally declared at typediff-enum.c:4) - different base types +typediff-enum.c:8:5: error: symbol 'w' redeclared with different type (originally declared at typediff-enum.c:7) - different base types +typediff-enum.c:11:5: error: symbol 'foo' redeclared with different type (originally declared at typediff-enum.c:10) - different base types +typediff-enum.c:14:5: error: symbol 'bar' redeclared with different type (originally declared at typediff-enum.c:13) - different base types +typediff-enum.c:17:6: error: symbol 'baz' redeclared with different type (originally declared at typediff-enum.c:16) - incompatible argument 1 (different base types) +typediff-enum.c:20:6: error: symbol 'qux' redeclared with different type (originally declared at typediff-enum.c:19) - incompatible argument 1 (different base types) +typediff-enum.c:23:6: error: symbol 'pin' redeclared with different type (originally declared at typediff-enum.c:22) - incompatible argument 1 (different base types) +typediff-enum.c:26:6: error: symbol 'pni' redeclared with different type (originally declared at typediff-enum.c:25) - incompatible argument 1 (different base types) +typediff-enum.c:51:17: warning: incorrect type in initializer (different base types) +typediff-enum.c:51:17: expected int ( *opri )( ... ) +typediff-enum.c:51:17: got enum num ( *<noident> )( ... ) +typediff-enum.c:52:17: warning: incorrect type in initializer (different base types) +typediff-enum.c:52:17: expected enum num ( *oprn )( ... ) +typediff-enum.c:52:17: got int ( *<noident> )( ... ) +typediff-enum.c:53:17: warning: incorrect type in initializer (incompatible argument 1 (different base types)) +typediff-enum.c:53:17: expected void ( *opai )( ... ) +typediff-enum.c:53:17: got void ( *<noident> )( ... ) +typediff-enum.c:54:17: warning: incorrect type in initializer (incompatible argument 1 (different base types)) +typediff-enum.c:54:17: expected void ( *opan )( ... ) +typediff-enum.c:54:17: got void ( *<noident> )( ... ) + * check-error-end + */ -- 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