Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- validation/sizeof-incomplete-type.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 validation/sizeof-incomplete-type.c diff --git a/validation/sizeof-incomplete-type.c b/validation/sizeof-incomplete-type.c new file mode 100644 index 000000000..9fba00b38 --- /dev/null +++ b/validation/sizeof-incomplete-type.c @@ -0,0 +1,27 @@ +struct s { + char a; + char b[sizeof(struct s)]; + char c; + char d[sizeof(struct s)]; + int j:sizeof(struct s); +}; + +static int array[] = { + [0] = 0, + [sizeof(array)] = 1, + [2] = 0, + [sizeof(array)] = 2, +}; + +/* + * check-name: sizeof incomplete type + * + * check-known-to-fail + * check-error-start +sizeof-incomplete-type.c:3:16: error: invalid application of 'sizeof' to incomplete type 'struct s' +sizeof-incomplete-type.c:5:16: error: invalid application of 'sizeof' to incomplete type 'struct s' +sizeof-incomplete-type.c:6:16: error: invalid application of 'sizeof' to incomplete type 'struct s' +sizeof-incomplete-type.c:11:17: error: invalid application of 'sizeof' to incomplete type 'int[]' +sizeof-incomplete-type.c:13:17: error: invalid application of 'sizeof' to incomplete type 'int[]' + * check-error-end + */ -- 2.14.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