Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- validation/vla-sizeof0.c | 20 ++++++++++++++++++++ validation/vla-sizeof1.c | 22 ++++++++++++++++++++++ validation/vla-sizeof2.c | 22 ++++++++++++++++++++++ validation/vla-sizeof3.c | 22 ++++++++++++++++++++++ validation/vla-sizeof4.c | 23 +++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 validation/vla-sizeof0.c create mode 100644 validation/vla-sizeof1.c create mode 100644 validation/vla-sizeof2.c create mode 100644 validation/vla-sizeof3.c create mode 100644 validation/vla-sizeof4.c diff --git a/validation/vla-sizeof0.c b/validation/vla-sizeof0.c new file mode 100644 index 000000000..a58fd300f --- /dev/null +++ b/validation/vla-sizeof0.c @@ -0,0 +1,20 @@ +#define N 2 +#define T int + +static unsigned int foo(int x) +{ + T a[(1,N)]; + + return sizeof(a) == (N * sizeof(T)); +} + +/* + * check-name: vla-sizeof cte,cte + * check-command: test-linearize -Wvla $file + * + * check-output-ignore + * check-output-contains: ret\\.32 *\\$1 + * + * check-error-start + * check-error-end + */ diff --git a/validation/vla-sizeof1.c b/validation/vla-sizeof1.c new file mode 100644 index 000000000..f0e32b7c1 --- /dev/null +++ b/validation/vla-sizeof1.c @@ -0,0 +1,22 @@ +#define N 2 +#define T int + +static unsigned int foo(int x) +{ + T a[(x,N)]; + + return sizeof(a) == (N * sizeof(T)); +} + +/* + * check-name: vla-sizeof var,cte + * check-command: test-linearize -Wvla $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\.32 *\\$1 + * + * check-error-start +vla-sizeof1.c:6:15: warning: Variable length array is used. + * check-error-end + */ diff --git a/validation/vla-sizeof2.c b/validation/vla-sizeof2.c new file mode 100644 index 000000000..b0b79a031 --- /dev/null +++ b/validation/vla-sizeof2.c @@ -0,0 +1,22 @@ +#define N 2 +#define T int + +static unsigned long foo(int x) +{ + T a[x]; + + return sizeof(a) == (x * sizeof(T)); +} + +/* + * check-name: vla-sizeof var + * check-command: test-linearize -Wvla $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$1 + * + * check-error-start +vla-sizeof2.c:6:13: warning: Variable length array is used. + * check-error-end + */ diff --git a/validation/vla-sizeof3.c b/validation/vla-sizeof3.c new file mode 100644 index 000000000..b9cb6acc2 --- /dev/null +++ b/validation/vla-sizeof3.c @@ -0,0 +1,22 @@ +#define N 2UL +#define T int + +static unsigned long foo(int x) +{ + T a[x][N]; + + return sizeof(a) == (N * x * sizeof(T)); +} + +/* + * check-name: vla-sizeof var X cte + * check-command: test-linearize -Wvla $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$1 + * + * check-error-start +vla-sizeof3.c:6:13: warning: Variable length array is used. + * check-error-end + */ diff --git a/validation/vla-sizeof4.c b/validation/vla-sizeof4.c new file mode 100644 index 000000000..4b50fb2cb --- /dev/null +++ b/validation/vla-sizeof4.c @@ -0,0 +1,23 @@ +#define N 2 +#define T int + +static unsigned long foo(int x, int y) +{ + T a[x][y]; + + return sizeof(a) == (x * (y * sizeof(T))); +} + +/* + * check-name: vla-sizeof var X var + * check-command: test-linearize -Wvla $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$1 + * + * check-error-start +vla-sizeof4.c:6:16: warning: Variable length array is used. +vla-sizeof4.c:6:13: warning: Variable length array is used. + * check-error-end + */ -- 2.16.2 -- 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