From: Aldy Hernandez Date: Wed, 19 Oct 2016 13:52:43 +0000 (+0000) Subject: Wvla-1.c: Rename to... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b70f0b0cc3134537d56b2115289cb94c3eb7a4e4;p=gcc.git Wvla-1.c: Rename to... * gcc.dg/Wvla-1.c: Rename to... * gcc.dg/Wvla-larger-than-1.c: ...this. * gcc.dg/Wvla-2.c: Rename to... * gcc.dg/Wvla-larger-than-2.c: ...this. * gcc.dg/Wvla-3.c: Rename to... * gcc.dg/Walloca-11.c.: ...this. * gcc.dg/wvla-[1-7].c: Rename to: * gcc.dg/Wvla-[1-7].c: ...this. From-SVN: r241344 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a2707003931..d3d269d159b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2016-10-19 Aldy Hernandez + + * gcc.dg/Wvla-1.c: Rename to... + * gcc.dg/Wvla-larger-than-1.c: ...this. + * gcc.dg/Wvla-2.c: Rename to... + * gcc.dg/Wvla-larger-than-2.c: ...this. + * gcc.dg/Wvla-3.c: Rename to... + * gcc.dg/Walloca-11.c.: ...this. + * gcc.dg/wvla-[1-7].c: Rename to: + * gcc.dg/Wvla-[1-7].c: ...this. + 2016-10-19 Bin Cheng PR tree-optimization/78005 diff --git a/gcc/testsuite/gcc.dg/Walloca-11.c b/gcc/testsuite/gcc.dg/Walloca-11.c new file mode 100644 index 00000000000..5124476d71f --- /dev/null +++ b/gcc/testsuite/gcc.dg/Walloca-11.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Walloca -O2" } */ + +// Make sure we don't warn on VLA with -Walloca. + +void f (void*); + +void h1 (unsigned n) +{ + int a [n]; + f (a); +} diff --git a/gcc/testsuite/gcc.dg/Wvla-1.c b/gcc/testsuite/gcc.dg/Wvla-1.c index 384c930c995..d2e3cb57d4f 100644 --- a/gcc/testsuite/gcc.dg/Wvla-1.c +++ b/gcc/testsuite/gcc.dg/Wvla-1.c @@ -1,24 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wvla-larger-than=100 -O2" } */ +/* { dg-options "-std=c89 -Wvla" } */ -typedef __SIZE_TYPE__ size_t; - -extern void useit (char *); - -int num; - -void test_vlas (size_t num) -{ - char str2[num]; /* { dg-warning "unbounded use" } */ - useit(str2); - - num = 98; - for (int i=0; i < 1234; ++i) { - char str[num]; // OK, VLA in a loop, but it is a - // known size *AND* the compiler takes - // care of cleaning up between - // iterations with - // __builtin_stack_restore. - useit(str); - } -} +extern void +func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/gcc/testsuite/gcc.dg/Wvla-2.c b/gcc/testsuite/gcc.dg/Wvla-2.c index 96814dcaac0..92c67ed639f 100644 --- a/gcc/testsuite/gcc.dg/Wvla-2.c +++ b/gcc/testsuite/gcc.dg/Wvla-2.c @@ -1,70 +1,5 @@ /* { dg-do compile } */ -/* { dg-require-effective-target stdint_types } */ -/* { dg-options "-O2 -Wvla-larger-than=40" } */ +/* { dg-options "-std=c99 -Wvla" } */ -#include - -void f0 (void *); -void -f1 (__SIZE_TYPE__ a) -{ - if (a <= 10) - { - // 10 * 4 bytes = 40: OK! - uint32_t x[a]; - f0 (x); - } -} - -void -f2 (__SIZE_TYPE__ a) -{ - if (a <= 11) - { - // 11 * 4 bytes = 44: Not OK. - uint32_t x[a]; // { dg-warning "array may be too large" } - // { dg-message "note:.*argument may be as large as 44" "note" { target *-*-* } 25 } - f0 (x); - } -} - -void -f3 (__SIZE_TYPE__ a, __SIZE_TYPE__ b) -{ - if (a <= 5 && b <= 3) - { - // 5 * 3 * 4 bytes = 60: Not OK. - uint32_t x[a][b]; // { dg-warning "array may be too large" } - f0 (x); - } -} - -void -f4 (__SIZE_TYPE__ a, __SIZE_TYPE__ b) -{ - if (a <= 5 && b <= 2) - { - // 5 * 2 * 4 bytes = 40 bytes: OK! - uint32_t x[a][b]; - f0 (x); - } -} - -void -f5 (__SIZE_TYPE__ len) -{ - // Test that a direct call to __builtin_alloca_with_align is not - // confused with a VLA. - void *p = __builtin_alloca_with_align (len, 8); - f0 (p); -} - -void -f6 (unsigned stuff) -{ - int n = 7000; - do { - char a[n]; // { dg-warning "variable-length array is too large" } - f0 (a); - } while (stuff--); -} +extern void +func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/gcc/testsuite/gcc.dg/Wvla-3.c b/gcc/testsuite/gcc.dg/Wvla-3.c index 5124476d71f..45132fa6b18 100644 --- a/gcc/testsuite/gcc.dg/Wvla-3.c +++ b/gcc/testsuite/gcc.dg/Wvla-3.c @@ -1,12 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Walloca -O2" } */ +/* { dg-options "-pedantic-errors -std=c89 -Wvla" } */ -// Make sure we don't warn on VLA with -Walloca. - -void f (void*); - -void h1 (unsigned n) -{ - int a [n]; - f (a); -} +extern void +func (int i, int array[i]); /* { dg-error "ISO C90 forbids variable.* array 'array'" } */ diff --git a/gcc/testsuite/gcc.dg/Wvla-4.c b/gcc/testsuite/gcc.dg/Wvla-4.c new file mode 100644 index 00000000000..ae2e0b064a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wvla-4.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c99 -Wvla" } */ + +extern void +func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/gcc/testsuite/gcc.dg/Wvla-5.c b/gcc/testsuite/gcc.dg/Wvla-5.c new file mode 100644 index 00000000000..919b8dc201b --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wvla-5.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c89 -Wno-vla" } */ + +extern void +func (int i, int array[i]); diff --git a/gcc/testsuite/gcc.dg/Wvla-6.c b/gcc/testsuite/gcc.dg/Wvla-6.c new file mode 100644 index 00000000000..694a4cc16ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wvla-6.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -Wvla" } */ + +extern void +func (int i, int [i]); /* { dg-warning "ISO C90 forbids variable length array" } */ diff --git a/gcc/testsuite/gcc.dg/Wvla-7.c b/gcc/testsuite/gcc.dg/Wvla-7.c new file mode 100644 index 00000000000..4c264f0d8a3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wvla-7.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c89 -Wvla" } */ + +extern void +func (int i, int [i]); /* { dg-error "ISO C90 forbids variable" } */ diff --git a/gcc/testsuite/gcc.dg/Wvla-larger-than-1.c b/gcc/testsuite/gcc.dg/Wvla-larger-than-1.c new file mode 100644 index 00000000000..384c930c995 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wvla-larger-than-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-Wvla-larger-than=100 -O2" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void useit (char *); + +int num; + +void test_vlas (size_t num) +{ + char str2[num]; /* { dg-warning "unbounded use" } */ + useit(str2); + + num = 98; + for (int i=0; i < 1234; ++i) { + char str[num]; // OK, VLA in a loop, but it is a + // known size *AND* the compiler takes + // care of cleaning up between + // iterations with + // __builtin_stack_restore. + useit(str); + } +} diff --git a/gcc/testsuite/gcc.dg/Wvla-larger-than-2.c b/gcc/testsuite/gcc.dg/Wvla-larger-than-2.c new file mode 100644 index 00000000000..96814dcaac0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wvla-larger-than-2.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -Wvla-larger-than=40" } */ + +#include + +void f0 (void *); +void +f1 (__SIZE_TYPE__ a) +{ + if (a <= 10) + { + // 10 * 4 bytes = 40: OK! + uint32_t x[a]; + f0 (x); + } +} + +void +f2 (__SIZE_TYPE__ a) +{ + if (a <= 11) + { + // 11 * 4 bytes = 44: Not OK. + uint32_t x[a]; // { dg-warning "array may be too large" } + // { dg-message "note:.*argument may be as large as 44" "note" { target *-*-* } 25 } + f0 (x); + } +} + +void +f3 (__SIZE_TYPE__ a, __SIZE_TYPE__ b) +{ + if (a <= 5 && b <= 3) + { + // 5 * 3 * 4 bytes = 60: Not OK. + uint32_t x[a][b]; // { dg-warning "array may be too large" } + f0 (x); + } +} + +void +f4 (__SIZE_TYPE__ a, __SIZE_TYPE__ b) +{ + if (a <= 5 && b <= 2) + { + // 5 * 2 * 4 bytes = 40 bytes: OK! + uint32_t x[a][b]; + f0 (x); + } +} + +void +f5 (__SIZE_TYPE__ len) +{ + // Test that a direct call to __builtin_alloca_with_align is not + // confused with a VLA. + void *p = __builtin_alloca_with_align (len, 8); + f0 (p); +} + +void +f6 (unsigned stuff) +{ + int n = 7000; + do { + char a[n]; // { dg-warning "variable-length array is too large" } + f0 (a); + } while (stuff--); +} diff --git a/gcc/testsuite/gcc.dg/wvla-1.c b/gcc/testsuite/gcc.dg/wvla-1.c deleted file mode 100644 index d2e3cb57d4f..00000000000 --- a/gcc/testsuite/gcc.dg/wvla-1.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-std=c89 -Wvla" } */ - -extern void -func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/gcc/testsuite/gcc.dg/wvla-2.c b/gcc/testsuite/gcc.dg/wvla-2.c deleted file mode 100644 index 92c67ed639f..00000000000 --- a/gcc/testsuite/gcc.dg/wvla-2.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-std=c99 -Wvla" } */ - -extern void -func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/gcc/testsuite/gcc.dg/wvla-3.c b/gcc/testsuite/gcc.dg/wvla-3.c deleted file mode 100644 index 45132fa6b18..00000000000 --- a/gcc/testsuite/gcc.dg/wvla-3.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-pedantic-errors -std=c89 -Wvla" } */ - -extern void -func (int i, int array[i]); /* { dg-error "ISO C90 forbids variable.* array 'array'" } */ diff --git a/gcc/testsuite/gcc.dg/wvla-4.c b/gcc/testsuite/gcc.dg/wvla-4.c deleted file mode 100644 index ae2e0b064a9..00000000000 --- a/gcc/testsuite/gcc.dg/wvla-4.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-pedantic-errors -std=c99 -Wvla" } */ - -extern void -func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/gcc/testsuite/gcc.dg/wvla-5.c b/gcc/testsuite/gcc.dg/wvla-5.c deleted file mode 100644 index 919b8dc201b..00000000000 --- a/gcc/testsuite/gcc.dg/wvla-5.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-pedantic-errors -std=c89 -Wno-vla" } */ - -extern void -func (int i, int array[i]); diff --git a/gcc/testsuite/gcc.dg/wvla-6.c b/gcc/testsuite/gcc.dg/wvla-6.c deleted file mode 100644 index 694a4cc16ca..00000000000 --- a/gcc/testsuite/gcc.dg/wvla-6.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-std=c89 -Wvla" } */ - -extern void -func (int i, int [i]); /* { dg-warning "ISO C90 forbids variable length array" } */ diff --git a/gcc/testsuite/gcc.dg/wvla-7.c b/gcc/testsuite/gcc.dg/wvla-7.c deleted file mode 100644 index 4c264f0d8a3..00000000000 --- a/gcc/testsuite/gcc.dg/wvla-7.c +++ /dev/null @@ -1,5 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-pedantic-errors -std=c89 -Wvla" } */ - -extern void -func (int i, int [i]); /* { dg-error "ISO C90 forbids variable" } */