diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg')
69 files changed, 1326 insertions, 60 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c index 7bf111a50ea..bab91ce3889 100644 --- a/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-18.c @@ -1,11 +1,8 @@ /* { dg-do compile } */ /* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */ -/* Don't warn about an overflow when folding i > 0. The loop analysis - should determine that i does not wrap. - - The test is really bogus, p->a - p->b can be larger than INT_MAX - and thus i can very well wrap. */ +/* Warn about an overflow when folding i > 0, p->a - p->b can be larger + than INT_MAX and thus i can wrap. */ struct c { unsigned int a; unsigned int b; }; extern void bar (struct c *); @@ -17,7 +14,7 @@ foo (struct c *p) for (i = 0; i < p->a - p->b; ++i) { - if (i > 0) /* { dg-bogus "warning" "" } */ + if (i > 0) /* { dg-warning "signed overflow" "" } */ sum += 2; bar (p); } diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c new file mode 100644 index 00000000000..00916446371 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=3" } */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int x, int y) +{ + return x - y < 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ +} diff --git a/gcc/testsuite/gcc.dg/debug/pr35154.c b/gcc/testsuite/gcc.dg/debug/pr35154.c index fa658be2cbe..7f6a6eaa0ec 100644 --- a/gcc/testsuite/gcc.dg/debug/pr35154.c +++ b/gcc/testsuite/gcc.dg/debug/pr35154.c @@ -2,6 +2,7 @@ proper structure. These should be lettered G for the struct that gives the name to the .comm, and should be V or S for .lcomm symbols. */ +__attribute__ ((used)) static char i_outer; struct { char f1; @@ -15,7 +16,7 @@ struct { int main() { - static char i_inner[2]; + static char i_inner[2] __attribute__ ((used)); i_inner[0] = 'a'; i_inner[1] = 'b'; opta.f1 = 'c'; opta.f2 = 'd'; diff --git a/gcc/testsuite/gcc.dg/dfp/wtr-conversion-1.c b/gcc/testsuite/gcc.dg/dfp/wtr-conversion-1.c index 4eff0072590..b85ff3e7c7d 100644 --- a/gcc/testsuite/gcc.dg/dfp/wtr-conversion-1.c +++ b/gcc/testsuite/gcc.dg/dfp/wtr-conversion-1.c @@ -3,7 +3,7 @@ Based on gcc.dg/wtr-conversion-1.c */ /* { dg-do compile } */ -/* { dg-options "-Wtraditional" } */ +/* { dg-options "-Wtraditional-conversion" } */ extern void foo_i (int); extern void foo_f (float); diff --git a/gcc/testsuite/gcc.dg/fold-compare-8.c b/gcc/testsuite/gcc.dg/fold-compare-8.c new file mode 100644 index 00000000000..b6e42fdef10 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-compare-8.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int +foo (int x, int y) +{ + return x - y < 0; +} + +/* { dg-final { scan-tree-dump "x < y" "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc/testsuite/gcc.dg/fstack-protector-strong.c b/gcc/testsuite/gcc.dg/fstack-protector-strong.c index 7c232fff243..da33abb3d7d 100644 --- a/gcc/testsuite/gcc.dg/fstack-protector-strong.c +++ b/gcc/testsuite/gcc.dg/fstack-protector-strong.c @@ -131,4 +131,22 @@ foo10 () return bb.three; } -/* { dg-final { scan-assembler-times "stack_chk_fail" 10 } } */ +struct B +{ + /* Discourage passing this struct in registers. */ + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; +}; + +struct B global3 (void); + +int foo11 () +{ + return global3 ().a1; +} + +void foo12 () +{ + global3 (); +} + +/* { dg-final { scan-assembler-times "stack_chk_fail" 12 } } */ diff --git a/gcc/testsuite/gcc.dg/init-string-1.c b/gcc/testsuite/gcc.dg/init-string-1.c index ace3b34562e..a33f741aea1 100644 --- a/gcc/testsuite/gcc.dg/init-string-1.c +++ b/gcc/testsuite/gcc.dg/init-string-1.c @@ -30,7 +30,7 @@ struct s j = { 1, (L"j") }; /* { dg-bogus "warning" "warning in place of error" } */ -/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 32 } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 31 } */ struct s k = { (("k")), /* { dg-bogus "warning" "warning in place of error" } */ /* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 35 } */ @@ -48,7 +48,7 @@ struct s m = { .c = L"m", .a = ("m") }; /* { dg-bogus "warning" "warning in place of error" } */ -/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 50 } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 49 } */ char *n = (char []){ "n" }; diff --git a/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c b/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c index 54d3e761573..fc7b142afdf 100644 --- a/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c +++ b/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c @@ -1,5 +1,5 @@ /* { dg-do compile { target { { x86_64-*-* && lp64 } || { powerpc*-*-* && lp64 } } } } */ -/* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue" } */ +/* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue -fno-use-caller-save" } */ long __attribute__((noinline, noclone)) foo (long a) @@ -7,7 +7,7 @@ foo (long a) return a + 5; } -static long g; +static long g __attribute__ ((used)); long __attribute__((noinline, noclone)) bar (long a) diff --git a/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c b/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c index ed08494cfa0..2e5a9cfdc29 100644 --- a/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c +++ b/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c @@ -1,5 +1,5 @@ /* { dg-do compile { target { { x86_64-*-* && lp64 } || { powerpc*-*-* && lp64 } } } } */ -/* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue" } */ +/* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue -fno-use-caller-save" } */ long __attribute__((noinline, noclone)) foo (long a) diff --git a/gcc/testsuite/gcc.dg/lto/pr61278_0.c b/gcc/testsuite/gcc.dg/lto/pr61278_0.c new file mode 100644 index 00000000000..36cdabc0f22 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr61278_0.c @@ -0,0 +1,30 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -flto -O0 } } } */ +/* { dg-extra-ld-options " -flto -O1 " } */ + +static unsigned int +fn1 (int p1, int p2) +{ + return 0; +} + +char a, b, c; + +char +foo (char *p) +{ + int i; + for (b = 1 ; b > 0; b++) + { + for (i = 0; i < 2; i++) + ; + for (a = 1; a > 0; a++) + { + char d[1] = { 0 }; + if (*p) + break; + c ^= fn1 (fn1 (fn1 (0, 0), 0), 0); + } + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr61278_1.c b/gcc/testsuite/gcc.dg/lto/pr61278_1.c new file mode 100644 index 00000000000..6e7f0eb7b2e --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr61278_1.c @@ -0,0 +1,10 @@ +extern char foo (char *); + +char d; + +int +main () +{ + foo (&d); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/nonnull-2.c b/gcc/testsuite/gcc.dg/nonnull-2.c index bd36d232d38..d570a467e6a 100644 --- a/gcc/testsuite/gcc.dg/nonnull-2.c +++ b/gcc/testsuite/gcc.dg/nonnull-2.c @@ -6,7 +6,7 @@ extern void func1 () __attribute__((nonnull)); /* { dg-error "without arguments" extern void func2 (char *) __attribute__((nonnull(2))); /* { dg-error "out-of-range operand" } */ -extern void func3 (char *) __attribute__((nonnull(foo))); /* { dg-error "invalid operand number" } */ +extern void func3 (char *) __attribute__((nonnull(foo))); /* { dg-error "invalid operand number|undeclared" } */ extern void func4 (int) __attribute__((nonnull(1))); /* { dg-error "references non-pointer" } */ diff --git a/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c b/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c index 7d557f369c3..6142e55c51d 100644 --- a/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c +++ b/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c @@ -1,6 +1,6 @@ -/* { dg-do compile { target arm*-*-* alpha*-*-* ia64*-*-* x86_64-*-* s390x-*-* powerpc*-*-* rs6000-*-* } } */ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap64 } */ /* { dg-require-effective-target stdint_types } */ -/* { dg-require-effective-target lp64 } */ /* { dg-options "-O2 -fdump-tree-bswap" } */ #include <stdint.h> diff --git a/gcc/testsuite/gcc.dg/optimize-bswapdi-2.c b/gcc/testsuite/gcc.dg/optimize-bswapdi-2.c index 6e2821db990..b8ad2c13c40 100644 --- a/gcc/testsuite/gcc.dg/optimize-bswapdi-2.c +++ b/gcc/testsuite/gcc.dg/optimize-bswapdi-2.c @@ -1,6 +1,6 @@ -/* { dg-do compile { target arm*-*-* alpha*-*-* ia64*-*-* x86_64-*-* s390x-*-* powerpc*-*-* rs6000-*-* } } */ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap64 } */ /* { dg-require-effective-target stdint_types } */ -/* { dg-require-effective-target lp64 } */ /* { dg-options "-O2 -fdump-tree-bswap" } */ #include <stdint.h> diff --git a/gcc/testsuite/gcc.dg/optimize-bswapdi-3.c b/gcc/testsuite/gcc.dg/optimize-bswapdi-3.c new file mode 100644 index 00000000000..0a8bf2e739d --- /dev/null +++ b/gcc/testsuite/gcc.dg/optimize-bswapdi-3.c @@ -0,0 +1,64 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap64 } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-bswap" } */ + +#include <stdint.h> + +unsigned char data[8]; + +struct uint64_st { + unsigned char u0, u1, u2, u3, u4, u5, u6, u7; +}; + +uint64_t read_le64_1 (void) +{ + return (uint64_t) data[0] | ((uint64_t) data[1] << 8) + | ((uint64_t) data[2] << 16) | ((uint64_t) data[3] << 24) + | ((uint64_t) data[4] << 32) | ((uint64_t) data[5] << 40) + | ((uint64_t) data[6] << 48) | ((uint64_t) data[7] << 56); +} + +uint64_t read_le64_2 (struct uint64_st data) +{ + return (uint64_t) data.u0 | ((uint64_t) data.u1 << 8) + | ((uint64_t) data.u2 << 16) | ((uint64_t) data.u3 << 24) + | ((uint64_t) data.u4 << 32) | ((uint64_t) data.u5 << 40) + | ((uint64_t) data.u6 << 48) | ((uint64_t) data.u7 << 56); +} + +uint64_t read_le64_3 (unsigned char *data) +{ + return (uint64_t) *data | ((uint64_t) *(data + 1) << 8) + | ((uint64_t) *(data + 2) << 16) | ((uint64_t) *(data + 3) << 24) + | ((uint64_t) *(data + 4) << 32) | ((uint64_t) *(data + 5) << 40) + | ((uint64_t) *(data + 6) << 48) | ((uint64_t) *(data + 7) << 56); +} + +uint64_t read_be64_1 (void) +{ + return (uint64_t) data[7] | ((uint64_t) data[6] << 8) + | ((uint64_t) data[5] << 16) | ((uint64_t) data[4] << 24) + | ((uint64_t) data[3] << 32) | ((uint64_t) data[2] << 40) + | ((uint64_t) data[1] << 48) | ((uint64_t) data[0] << 56); +} + +uint64_t read_be64_2 (struct uint64_st data) +{ + return (uint64_t) data.u7 | ((uint64_t) data.u6 << 8) + | ((uint64_t) data.u5 << 16) | ((uint64_t) data.u4 << 24) + | ((uint64_t) data.u3 << 32) | ((uint64_t) data.u2 << 40) + | ((uint64_t) data.u1 << 48) | ((uint64_t) data.u0 << 56); +} + +uint64_t read_be64_3 (unsigned char *data) +{ + return (uint64_t) *(data + 7) | ((uint64_t) *(data + 6) << 8) + | ((uint64_t) *(data + 5) << 16) | ((uint64_t) *(data + 4) << 24) + | ((uint64_t) *(data + 3) << 32) | ((uint64_t) *(data + 2) << 40) + | ((uint64_t) *(data + 1) << 48) | ((uint64_t) *data << 56); +} + +/* { dg-final { scan-tree-dump-times "64 bit load in host endianness found at" 3 "bswap" } } */ +/* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 3 "bswap" { xfail alpha*-*-* arm*-*-* } } } */ +/* { dg-final { cleanup-tree-dump "bswap" } } */ diff --git a/gcc/testsuite/gcc.dg/optimize-bswaphi-1.c b/gcc/testsuite/gcc.dg/optimize-bswaphi-1.c new file mode 100644 index 00000000000..65bff98f9f9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/optimize-bswaphi-1.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap16 } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-bswap" } */ +/* { dg-options "-O2 -fdump-tree-bswap -march=z900" { target s390-*-* } } */ + +#include <stdint.h> + +unsigned char data[2]; + +struct uint16_st { + unsigned char u0, u1; +}; + +uint32_t read_le16_1 (void) +{ + return data[0] | (data[1] << 8); +} + +uint32_t read_le16_2 (struct uint16_st data) +{ + return data.u0 | (data.u1 << 8); +} + +uint32_t read_le16_3 (unsigned char *data) +{ + return *data | (*(data + 1) << 8); +} + +uint32_t read_be16_1 (void) +{ + return data[1] | (data[0] << 8); +} + +uint32_t read_be16_2 (struct uint16_st data) +{ + return data.u1 | (data.u0 << 8); +} + +uint32_t read_be16_3 (unsigned char *data) +{ + return *(data + 1) | (*data << 8); +} + +/* { dg-final { scan-tree-dump-times "16 bit load in host endianness found at" 3 "bswap" } } */ +/* { dg-final { scan-tree-dump-times "16 bit bswap implementation found at" 3 "bswap" { xfail alpha*-*-* arm*-*-* } } } */ +/* { dg-final { cleanup-tree-dump "bswap" } } */ diff --git a/gcc/testsuite/gcc.dg/optimize-bswapsi-1.c b/gcc/testsuite/gcc.dg/optimize-bswapsi-1.c index 78238e30955..33d0bb0fa77 100644 --- a/gcc/testsuite/gcc.dg/optimize-bswapsi-1.c +++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-1.c @@ -1,4 +1,5 @@ -/* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* rs6000-*-* x86_64-*-* s390*-*-* } } */ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap32 } */ /* { dg-require-effective-target stdint_types } */ /* { dg-options "-O2 -fdump-tree-bswap" } */ /* { dg-options "-O2 -fdump-tree-bswap -march=z900" { target s390-*-* } } */ diff --git a/gcc/testsuite/gcc.dg/optimize-bswapsi-2.c b/gcc/testsuite/gcc.dg/optimize-bswapsi-2.c new file mode 100644 index 00000000000..518b5108378 --- /dev/null +++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-2.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap32 } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-bswap" } */ +/* { dg-options "-O2 -fdump-tree-bswap -march=z900" { target s390-*-* } } */ + +#include <stdint.h> + +extern unsigned char data[4]; + +struct uint32_st { + unsigned char u0, u1, u2, u3; +}; + +uint32_t read_le32_1 (void) +{ + return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); +} + +uint32_t read_le32_2 (struct uint32_st data) +{ + return data.u0 | (data.u1 << 8) | (data.u2 << 16) | (data.u3 << 24); +} + +uint32_t read_le32_3 (unsigned char *data) +{ + return *data | (*(data + 1) << 8) | (*(data + 2) << 16) + | (*(data + 3) << 24); +} + +uint32_t read_be32_1 (void) +{ + return data[3] | (data[2] << 8) | (data[1] << 16) | (data[0] << 24); +} + +uint32_t read_be32_2 (struct uint32_st data) +{ + return data.u3 | (data.u2 << 8) | (data.u1 << 16) | (data.u0 << 24); +} + +uint32_t read_be32_3 (unsigned char *data) +{ + return *(data + 3) | (*(data + 2) << 8) | (*(data + 1) << 16) + | (*data << 24); +} + +/* { dg-final { scan-tree-dump-times "32 bit load in host endianness found at" 3 "bswap" } } */ +/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 3 "bswap" { xfail alpha*-*-* arm*-*-* } } } */ +/* { dg-final { cleanup-tree-dump "bswap" } } */ diff --git a/gcc/testsuite/gcc.dg/pedwarn-init.c b/gcc/testsuite/gcc.dg/pedwarn-init.c new file mode 100644 index 00000000000..12611154bee --- /dev/null +++ b/gcc/testsuite/gcc.dg/pedwarn-init.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wpedantic" } */ +/* { dg-prune-output ".*near initialization for.*" } */ + +typedef unsigned vec __attribute__ ((vector_size (2 * sizeof (int)))); +union u { int a; double d; }; +struct S { int i; char fam[]; }; + +int i; +vec v = { 1, 2, 3 }; /* { dg-warning "17:excess elements in vector initializer" } */ +int a1 = { 1, 2 }; /* { dg-warning "15:excess elements in scalar initializer" } */ +int a2[2] = { 1, 2, 3 }; /* { dg-warning "21:excess elements in array initializer" } */ +int a3[] = { [1 ? 1 : i] = 0 }; /* { dg-warning "15:array index in initializer is not an integer constant expression" } */ +int a4[] = { [1 ... 1 ? 2 : i] = 0 }; /* { dg-warning "15:array index in initializer is not an integer constant expression" } */ +char a5[] = ("lol"); /* { dg-warning "13:array initialized from parenthesized string constant" } */ +char a6[] = { ("foo") }; /* { dg-warning "13:array initialized from parenthesized string constant" } */ +char *a7 = (char []) { ("bar") }; /* { dg-warning "12:array initialized from parenthesized string constant" } */ +union u u = { 1, 1.0 }; /* { dg-warning "18:excess elements in union initializer" } */ +struct S s = { 1, 2 }; /* { dg-warning "14:initialization of a flexible array member" } */ diff --git a/gcc/testsuite/gcc.dg/pr55570.c b/gcc/testsuite/gcc.dg/pr55570.c index 903bb033df9..5f5555ee47b 100644 --- a/gcc/testsuite/gcc.dg/pr55570.c +++ b/gcc/testsuite/gcc.dg/pr55570.c @@ -1,4 +1,4 @@ /* PR c/55570 */ /* { dg-do compile } */ -char array[16] __attribute__((aligned (SOME_NOT_DEFINED_MACRO))); /* { dg-error "requested alignment is not an integer constant" } */ +char array[16] __attribute__((aligned (SOME_NOT_DEFINED_MACRO))); /* { dg-error "undeclared here" } */ diff --git a/gcc/testsuite/gcc.dg/pr56724-1.c b/gcc/testsuite/gcc.dg/pr56724-1.c new file mode 100644 index 00000000000..4276c3f154b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr56724-1.c @@ -0,0 +1,33 @@ +/* PR c/56724 */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional-conversion" } */ + +extern void foo (int p[2][]); /* { dg-error "array type has incomplete element type" } */ +extern void foo_i (int, int); +extern void foo_u (unsigned int); +extern void foo_f (int, float); +extern void foo_ll (long long); +extern void foo_cd (int, int, __complex__ double); +extern signed char sc; +extern int i; +extern unsigned int u; +extern float f; +extern double d; +extern __complex__ double cd; + +void +fn () +{ + int p[1][1]; + foo (p); /* { dg-error "8:type of formal parameter" } */ + foo_i (1, f); /* { dg-warning "13:passing argument" } */ + foo_i (1, cd); /* { dg-warning "13:passing argument" } */ + foo_cd (1, 2, f); /* { dg-warning "17:passing argument" } */ + foo_f (9, i); /* { dg-warning "13:passing argument" } */ + foo_cd (2, 2, i); /* { dg-warning "17:passing argument" } */ + foo_f (2, cd); /* { dg-warning "13:passing argument" } */ + foo_f (2, d); /* { dg-warning "13:passing argument" } */ + foo_ll (sc); /* { dg-warning "11:passing argument" } */ + foo_u (i); /* { dg-warning "10:passing argument" } */ + foo_i (1, u); /* { dg-warning "13:passing argument" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr56724-2.c b/gcc/testsuite/gcc.dg/pr56724-2.c new file mode 100644 index 00000000000..4abb7d899e7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr56724-2.c @@ -0,0 +1,31 @@ +/* PR c/56724 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat -Wpedantic" } */ + +enum E1 { A }; +enum E2 { B }; +extern void foo_E (enum E1); +extern void foo_v (void *p); +extern void foo_sc (int, int, signed char *); +extern unsigned char *uc; +extern signed char sc; +extern const signed char *csc; +extern float *f; + +void +foo (void) +{ + void (*fp)(void); + const void (*ffp)(void); + foo_v (fp); /* { dg-warning "10:ISO C forbids passing argument" } */ + foo_E (B); /* { dg-warning "10:enum conversion when passing argument" } */ + foo_sc (1, 2, uc); /* { dg-warning "17:pointer targets in passing argument" } */ + foo_sc (1, 2, f); /* { dg-warning "17:passing argument" } */ + foo_sc (1, 2, sc); /* { dg-warning "17:passing argument" } */ + foo_sc (uc, 2, &sc); /* { dg-warning "11:passing argument" } */ + foo_sc (1, 2, csc); /* { dg-warning "17:passing argument" } */ +} + +typedef void (*fp)(void); +typedef void (*nrfp)(void) __attribute__((noreturn)); +void f1 (nrfp); void f2 (fp x) { f1 (x); } extern int e; /* { dg-warning "38:passing argument" } */ diff --git a/gcc/testsuite/gcc.dg/pr60866.c b/gcc/testsuite/gcc.dg/pr60866.c new file mode 100644 index 00000000000..020878d41de --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr60866.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-options "-O -fselective-scheduling -fno-if-conversion -fschedule-insns" } */ + +int n; + +void +foo (int w, int **dnroot, int **dn) +{ + int *child; + int *xchild = xchild; + for (; w < n; w++) + if (!dnroot) + { + dnroot = dn; + for (child = *dn; child; child = xchild) + ; + } +} diff --git a/gcc/testsuite/gcc.dg/pr61045.c b/gcc/testsuite/gcc.dg/pr61045.c new file mode 100644 index 00000000000..1808cdc259f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61045.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-fstrict-overflow" } */ + +int main () +{ + int a = 0; + int b = __INT_MAX__; + int t = (a - 2) > (b - 1); + if (t != 0) + __builtin_abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr61053.c b/gcc/testsuite/gcc.dg/pr61053.c new file mode 100644 index 00000000000..4fd531974f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61053.c @@ -0,0 +1,75 @@ +/* PR c/61053 */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Alignas (char) char cc; +_Alignas (short int) char cs; +_Alignas (int) char ci; +_Alignas (long int) char cl; +_Alignas (long long int) char cll; +_Alignas (float) char cf; +_Alignas (double) char cd; +_Alignas (long double) char cld; + +_Alignas (char) short int sc; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) short int ss; +_Alignas (int) short int si; +_Alignas (long int) short int sl; +_Alignas (long long int) short int sll; +_Alignas (float) short int sf; +_Alignas (double) short int sd; +_Alignas (long double) short int sld; + +_Alignas (char) int ic; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) int is; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) int ii; +_Alignas (long int) int il; +_Alignas (long long int) int ill; +_Alignas (float) int if_; +_Alignas (double) int id; +_Alignas (long double) int ild; + +_Alignas (char) long int lic; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) long int lis; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) long int lii; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (long int) long int lil; +_Alignas (long long int) long int lill; +_Alignas (float) long int lif; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (double) long int lid; +_Alignas (long double) long int lild; + +_Alignas (char) long long int llic; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) long long int llis; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) long long int llii; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (long int) long long int llil; +_Alignas (long long int) long long int llill; +_Alignas (float) long long int llif; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (double) long long int llid; +_Alignas (long double) long long int llild; + +_Alignas (char) float fc; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) float fs; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) float fi; +_Alignas (long int) float fl; +_Alignas (long long int) float fll; +_Alignas (float) float ff; +_Alignas (double) float fd; +_Alignas (long double) float fld; + +_Alignas (char) double dc; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) double ds; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) double di; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (long int) double dl; +_Alignas (long long int) double dll; +_Alignas (float) double df; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (double) double dd; +_Alignas (long double) double dld; + +_Alignas (char) long double ldc; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) long double lds; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) long double ldi; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (long int) long double ldl; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (long long int) long double ldll; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (float) long double ldf; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (double) long double ldd; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (long double) long double ldld; diff --git a/gcc/testsuite/gcc.dg/pr61060.c b/gcc/testsuite/gcc.dg/pr61060.c new file mode 100644 index 00000000000..d2a13650765 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61060.c @@ -0,0 +1,19 @@ +/* PR target/61060 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -ftree-ter" } */ + +typedef __SIZE_TYPE__ size_t; + +extern inline __attribute__ ((gnu_inline, always_inline, artificial)) +void *memset (void *dest, int ch, size_t len) +{ + return __builtin_memset (dest, ch, len); +} + +char buf[10]; + +void +foo (void) +{ + memset (buf, sizeof (buf), 0); +} diff --git a/gcc/testsuite/gcc.dg/pr61077.c b/gcc/testsuite/gcc.dg/pr61077.c new file mode 100644 index 00000000000..c0513f71f70 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61077.c @@ -0,0 +1,12 @@ +/* PR c/61077 */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wall" } */ + +_Atomic int +main (_Atomic int argc, _Atomic char **argv) +/* { dg-warning "qualified return type" "return" { target *-*-* } 6 } */ +/* { dg-warning "qualified parameter type.*int" "parameter" { target *-*-* } 6 } */ +/* { dg-warning "qualified parameter type.*char" "parameter" { target *-*-* } 6 } */ +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr61096-1.c b/gcc/testsuite/gcc.dg/pr61096-1.c new file mode 100644 index 00000000000..3f7d60c0e5d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61096-1.c @@ -0,0 +1,61 @@ +/* PR c/61077 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fshort-enums -fshort-wchar -Wpedantic" } */ +/* { dg-prune-output ".*near initialization for.*" } */ + +typedef enum { A } schar; +extern int e; +struct S +{ + int a[3]; +}; +struct f +{ + int w; + int x[]; +}; +struct g +{ + struct f f; /* { dg-warning "invalid use of structure with flexible array member" } */ +}; + +char w1[] = L"foo"; /* { dg-error "13:char-array initialized from wide string" } */ +__WCHAR_TYPE__ w2[] = "foo"; /* { dg-error "23:wide character array initialized from non-wide string" } */ +__WCHAR_TYPE__ w3[] = U"foo"; /* { dg-error "23:wide character array initialized from incompatible wide string" } */ +schar a1[] = "foo"; /* { dg-error "14:array of inappropriate type initialized from string constant" } */ +int a2[] = (int[]) { 1 }; /* { dg-error "12:array initialized from non-constant array expression" } */ + +int a3 = e; /* { dg-error "10:initializer element is not constant" } */ +int a4 = (e, 1); /* { dg-error "10:initializer element is not constant" } */ +int a5 = a1[0]; /* { dg-error "10:initializer element is not constant" } */ +int a6 = &a3 - &a4; /* { dg-error "10:initializer element is not" } */ +int a7[] = a7; /* { dg-error "12:invalid initializer" } */ + +struct S s = { { 1 }, { 3 } }; /* { dg-error "23:extra brace group at end of initializer" } */ +/* { dg-warning "23:excess elements in struct initializer" "" { target *-*-* } 34 } */ +struct g g1 = { {0, { 1 } } }; /* { dg-error "21:initialization of flexible array member in a nested context" } */ +struct g g2 = { .f[0] = 1 }; /* { dg-error "20:array index in non-array initializer" } */ + +__extension__ int a8 = { }; /* { dg-error "24:empty scalar initializer" } */ +int a9[10] = {[1.2] = 2 }; /* { dg-error "16:array index in initializer not of integer type" } */ +int a10[10] = {[e] = 2 }; /* { dg-error "17:nonconstant array index in initializer" } */ +__extension__ int a11[10] = {[1 ... e] = 1 }; /* { dg-error "31:nonconstant array index in initializer" } */ +int a12 = {[1] = 2 }; /* { dg-error "13:array index in non-array initializer" } */ +int a13[2] = {[-1] = 4 }; /* { dg-error "16:array index in initializer exceeds array bounds" } */ +int a14[2] = {[64] = 4 }; /* { dg-error "16:array index in initializer exceeds array bounds" } */ +__extension__ int a15[10] = {[2 ... 1] = 4 }; /* { dg-error "31:empty index range in initializer" } */ +__extension__ int a16[10] = {[2 ... 100] = 4 }; /* { dg-error "31:array index range in initializer exceeds array bounds" } */ +int a17[] = { .B = 1 }; /* { dg-error "15:field name not in record or union initializer" } */ +int a18[] = { e }; /* { dg-error "15:initializer element is not constant" } */ +char a19[1] = { "x", "x" }; /* { dg-error "22:excess elements in char array initializer" } */ + +void +bar (void) +{ + struct f f = { 2, "c" }; /* { dg-error "21:non-static initialization of a flexible array member" } */ +} + +struct +{ + char *v; +} sx[] = { .v = 0 }; /* { dg-error "12:field name not in record or union initializer" } */ diff --git a/gcc/testsuite/gcc.dg/pr61096-2.c b/gcc/testsuite/gcc.dg/pr61096-2.c new file mode 100644 index 00000000000..fbea4d9db6b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61096-2.c @@ -0,0 +1,10 @@ +/* PR c/61077 */ +/* { dg-do compile } */ + +struct s { char c[1]; }; +extern struct s foo (void); +void +bar (void) +{ + char *t = (foo ()).c; /* { dg-error "13:invalid use of non-lvalue array" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr61158.c b/gcc/testsuite/gcc.dg/pr61158.c new file mode 100644 index 00000000000..d0ba7f3876b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61158.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/61158 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +unsigned long long +foo (unsigned int x) +{ + return ((unsigned long long) x & 0x00ff000000000000ULL) >> 40; +} + +/* { dg-final { scan-tree-dump "return 0;" "original" { target { ilp32 || lp64 } } } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc/testsuite/gcc.dg/pr61162.c b/gcc/testsuite/gcc.dg/pr61162.c new file mode 100644 index 00000000000..00e64b9d758 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61162.c @@ -0,0 +1,12 @@ +/* PR c/61162 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +enum e { A }; +enum e +fn1 (void) +{ + enum e e, q = 0; /* { dg-warning "17:enum conversion in initialization is invalid" } */ + e = 0; /* { dg-warning "5:enum conversion in assignment is invalid" } */ + 1; return 0; /* { dg-warning "6:enum conversion in return is invalid" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr61220.c b/gcc/testsuite/gcc.dg/pr61220.c new file mode 100644 index 00000000000..d45d1c3c9f1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61220.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +int a, c, d, e, f, g, h, i, j, k; + +struct S0 +{ + int f0; + int f1; + int f2; +}; + +struct S1 +{ + int f0; + int f1; + struct S0 f2; +} b; + +void +fn1 (struct S1 p) +{ + for (; k; k++) + h = j ? a : a - 1; + d &= i; +} + +int +main () +{ + int l[5] = { 0 }; + fn1 (b); + for (c = 0; c < 3; c++) + for (g = 0; g < 3; g++) + l[c * 2] = e = l[c]; + if (f) + fn1 (b); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/shrink-wrap-loop.c b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c new file mode 100644 index 00000000000..e72edfa6c44 --- /dev/null +++ b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target { { x86_64-*-* && lp64 } || { arm_thumb2 } } } } */ +/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */ + +int foo (int *p1, int *p2); + +int +test (int *p1, int *p2) +{ + int *p; + + for (p = p2; p != 0; p++) + { + if (!foo (p, p1)) + return 0; + } + + return 1; +} +/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" } } */ +/* { dg-final { cleanup-rtl-dump "pro_and_epilogue" } } */ diff --git a/gcc/testsuite/gcc.dg/sibcall-3.c b/gcc/testsuite/gcc.dg/sibcall-3.c index e02a410e6d9..eafe8dd8456 100644 --- a/gcc/testsuite/gcc.dg/sibcall-3.c +++ b/gcc/testsuite/gcc.dg/sibcall-3.c @@ -5,7 +5,7 @@ Copyright (C) 2002 Free Software Foundation Inc. Contributed by Hans-Peter Nilsson <hp@bitrange.com> */ -/* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */ +/* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */ /* -mlongcall disables sibcall patterns. */ /* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */ /* { dg-options "-O2 -foptimize-sibling-calls" } */ diff --git a/gcc/testsuite/gcc.dg/sibcall-4.c b/gcc/testsuite/gcc.dg/sibcall-4.c index a66ed079862..1e039c66854 100644 --- a/gcc/testsuite/gcc.dg/sibcall-4.c +++ b/gcc/testsuite/gcc.dg/sibcall-4.c @@ -5,7 +5,7 @@ Copyright (C) 2002 Free Software Foundation Inc. Contributed by Hans-Peter Nilsson <hp@bitrange.com> */ -/* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */ +/* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */ /* -mlongcall disables sibcall patterns. */ /* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */ /* { dg-options "-O2 -foptimize-sibling-calls" } */ diff --git a/gcc/testsuite/gcc.dg/tm/wrap-2.c b/gcc/testsuite/gcc.dg/tm/wrap-2.c index 29486335a44..372d666be7f 100644 --- a/gcc/testsuite/gcc.dg/tm/wrap-2.c +++ b/gcc/testsuite/gcc.dg/tm/wrap-2.c @@ -10,7 +10,7 @@ int f7(void); void g1(void) W(f1); void g2(void) W(f2); /* { dg-error "is not compatible" } */ void g3(void) W(i3); /* { dg-error "is not a function" } */ -void g4(void) W(f4); /* { dg-error "is not a function" } */ +void g4(void) W(f4); /* { dg-error "undeclared" } */ void g5(void) W(1); /* { dg-error "not an identifier" } */ void g6(void) W("f1"); /* { dg-error "not an identifier" } */ void g7(void) W(f7); /* { dg-error "is not compatible" } */ diff --git a/gcc/testsuite/gcc.dg/torture/pr61095.c b/gcc/testsuite/gcc.dg/torture/pr61095.c new file mode 100644 index 00000000000..fa584e0353d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr61095.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-require-effective-target lp64 } */ + +extern void __attribute__ ((noreturn)) abort (void); + +int __attribute__ ((noinline, noclone)) +foo (unsigned long addr) { + unsigned long *p = (unsigned long*)((addr & 0xffff83fffffffff8UL) * 4); + unsigned long xxx = (unsigned long)(p + 1); + return xxx >= 0x3c000000000UL; +} + +int +main (void) +{ + if (foo (0)) + abort (); + if (foo (0x7c0000000000UL)) + abort (); + if (!foo (0xfc0000000000UL)) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr61136.c b/gcc/testsuite/gcc.dg/torture/pr61136.c new file mode 100644 index 00000000000..4fc908a25c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr61136.c @@ -0,0 +1,5 @@ +unsigned long long +foo (int a) +{ + return a * 7 & 1ULL << 63; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr61221.c b/gcc/testsuite/gcc.dg/torture/pr61221.c new file mode 100644 index 00000000000..2524382ba1a --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr61221.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +void __assert_fail (void); + +int **a, b, c, e, *j; +short *d, **f; + +int * +foo () +{ + *a = j; + if (!(1 & e)) + __assert_fail (); + return 0; +} + +void +bar () +{ + int *g = &b; + short **h = &d; + if ((f = &d) != h) + for (; b;) + { + int i = 1; + if (i) + g = foo (); + c = 0; + } + if (!g) + __assert_fail (); +} diff --git a/gcc/testsuite/gcc.dg/torture/pr61346.c b/gcc/testsuite/gcc.dg/torture/pr61346.c new file mode 100644 index 00000000000..e27b9cac5b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr61346.c @@ -0,0 +1,162 @@ +/* { dg-do run } */ + +extern void abort (void); + +typedef int int32_t __attribute__ ((mode (SI))); +typedef int int64_t __attribute__ ((mode (DI))); +typedef __SIZE_TYPE__ size_t; + +struct slice +{ + unsigned char *data; + int64_t len; + int64_t cap; +}; + +void fail (int32_t) __attribute__ ((noinline)); +void +fail (int32_t c) +{ + if (c != 0) + abort (); +} + +struct decode_rune_ret +{ + int32_t r; + int64_t width; +}; + +struct decode_rune_ret decode_rune (struct slice) __attribute__ ((noinline)); +struct decode_rune_ret +decode_rune (struct slice s) +{ + struct decode_rune_ret dr; + dr.r = s.data[0]; + dr.width = 1; + return dr; +} + +_Bool is_space (int32_t) __attribute__ ((noinline)); +_Bool +is_space (int32_t r) +{ + return r == ' '; +} + +struct ret +{ + int64_t advance; + struct slice token; +}; + +struct ret scanwords (struct slice, _Bool) __attribute__ ((noinline)); + +struct ret +scanwords (struct slice data, _Bool ateof) +{ + int64_t advance; + struct slice token; + int64_t start = 0; + { + int64_t width; + for (width = 0; start < data.len; start += width) + { + int32_t r = 0; + struct slice s; + if (start > data.cap || start < 0) + fail (3); + s.data = data.data + (size_t) start; + s.len = data.len - start; + s.cap = data.cap - start; + struct decode_rune_ret dr = decode_rune (s); + r = dr.r; + width = dr.width; + if (!is_space (r)) + break; + } + } + _Bool tmp = ateof; + if (tmp != 0) + goto L1; + else + goto L2; + L1: + tmp = data.len == 0; + L2: + if (tmp != 0) + goto L11; + else + goto L12; + L11: + { + struct ret r; + advance = 0; + token.data = 0; + token.len = 0; + token.cap = 0; + r.advance = advance; + r.token = token; + return r; + } + L12:; + int64_t width; + int64_t i; + for (width = 0, i = start; i < data.len; i += width) + { + int32_t r; + struct slice s; + if (i > data.cap || i < 0) + fail (3); + s.data = data.data + i; + s.len = data.len - i; + s.cap = data.cap - i; + struct decode_rune_ret dr = decode_rune (s); + r = dr.r; + width = dr.width; + if (is_space (r)) + { + if (i < start || i > data.cap || i < 0) + fail (3); + if (start > data.cap || start < 0) + fail (3); + struct ret r; + advance = i + width; + token.data = data.data + (size_t) start; + token.len = i - start; + token.cap = data.cap - start; + r.advance = advance; + r.token = token; + return r; + } + } + { + struct ret r; + advance = 0; + token.data = 0; + token.len = 0; + token.cap = 0; + r.advance = advance; + r.token = token; + return r; + } +} + +int +main () +{ + unsigned char buf[1000]; + struct slice s; + __builtin_memset (buf, 0, sizeof (buf)); + buf[0] = ' '; + buf[1] = 'a'; + buf[2] = ' '; + s.data = buf; + s.len = 3; + s.cap = sizeof (buf); + struct ret r; + r = scanwords (s, 1); + if (r.advance != 3 || r.token.data[0] != 'a' || r.token.len != 1) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-33.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-33.c new file mode 100644 index 00000000000..cbc0812a238 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-33.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O -fdump-tree-fre1-details" } */ + +int j; +int main () +{ + int i = 1; + int **p; + j = 0; + p = __builtin_malloc (sizeof (int *)); + *p = &i; + p = __builtin_realloc (p, 2 * sizeof (int *)); + **p = 0; + if (i != 0) + __builtin_abort (); + return j; +} + +/* { dg-final { scan-tree-dump "Replaced j with 0" "fre1" } } */ +/* { dg-final { cleanup-tree-dump "fre1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ivopts-lower_base.c b/gcc/testsuite/gcc.dg/tree-ssa/ivopts-lower_base.c new file mode 100644 index 00000000000..3b2b81f46a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ivopts-lower_base.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ivopts-details" } */ +#include <string.h> +#include <stdlib.h> + +#define MAX_NUM (256) + +void +sort_pointers (size_t n, void **pointers, void **work) +{ + typedef unsigned char digit_t; + unsigned int count[MAX_NUM]; + int big_endian_p; + size_t i; + size_t j; + + if ((sizeof (void *) / sizeof (digit_t)) % 2 != 0) + abort (); + + for (i = 0, j = 0; i < sizeof (size_t); ++i) + { + j *= MAX_NUM; + j += i; + } + + big_endian_p = (((char *)&j)[0] == 0); + for (i = 0; i < sizeof (void *) / sizeof (digit_t); ++i) + { + digit_t *digit; + digit_t *bias; + digit_t *top; + unsigned int *countp; + void **pointerp; + + if (big_endian_p) + j = sizeof (void *) / sizeof (digit_t) - i; + else + j = i; + + memset (count, 0, MAX_NUM * sizeof (unsigned int)); + bias = ((digit_t *) pointers) + j; + top = ((digit_t *) (pointers + n)) + j; + for (digit = bias; + digit < top; + digit += sizeof (void *) / sizeof (digit_t)) + ++count[*digit]; + + for (countp = count + 1; countp < count + MAX_NUM; ++countp) + *countp += countp[-1]; + + for (pointerp = pointers + n - 1; pointerp >= pointers; --pointerp) + work[--count[((digit_t *) pointerp)[j]]] = *pointerp; + + pointerp = pointers; + pointers = work; + work = pointerp; + } +} + +/* { dg-final { scan-tree-dump-not "base \[^\\n\]*&MEM\\\[" "ivopts" } } */ +/* { dg-final { cleanup-tree-dump "ivopts" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-12.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-12.c new file mode 100644 index 00000000000..b52c6d711a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-12.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-phiopt1" } */ + +int f(int a, int b, int c) { + if (c > 5) return c; + if (a == 0) return b; + return a + b; +} + +unsigned rot(unsigned x, int n) { + const int bits = __CHAR_BIT__ * __SIZEOF_INT__; + return (n == 0) ? x : ((x << n) | (x >> (bits - n))); +} + +unsigned m(unsigned a, unsigned b) { + if (a == 0) + return 0; + else + return a & b; +} + +/* { dg-final { scan-tree-dump-times "goto" 2 "phiopt1" } } */ +/* { dg-final { cleanup-tree-dump "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-13.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-13.c new file mode 100644 index 00000000000..3e09c218890 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-13.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +// Division is expensive +long f(long a, long b) { + if (__builtin_expect(b == 1, 1)) return a; + return a / b; +} + +/* { dg-final { scan-tree-dump-times "goto " 2 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21559.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21559.c index 6378d1aa729..a991e049035 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr21559.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21559.c @@ -9,6 +9,7 @@ void foo (void) { int toread; int bytes; + __attribute__ ((used)) static char eof_reached = 0; toread = blocksize; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr23401.c b/gcc/testsuite/gcc.dg/tree-ssa/pr23401.c index 3940692cd6c..1d30ac7519f 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr23401.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr23401.c @@ -19,6 +19,6 @@ int ffff(int i) /* We should not use extra temporaries apart from for i1 + i2. */ -/* { dg-final { scan-tree-dump-times "int" 6 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "int" 5 "gimple" } } */ /* { dg-final { scan-tree-dump-times "int D\\\." 1 "gimple" } } */ /* { dg-final { cleanup-tree-dump "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr27810.c b/gcc/testsuite/gcc.dg/tree-ssa/pr27810.c index 6d0904bb06b..c7da3bd5d06 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr27810.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr27810.c @@ -13,6 +13,6 @@ int qqq (int a) /* We should not use an extra temporary for the result of the function call. */ -/* { dg-final { scan-tree-dump-times "int" 4 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "int" 3 "gimple" } } */ /* { dg-final { scan-tree-dump-times "int D\\\." 1 "gimple" } } */ /* { dg-final { cleanup-tree-dump "gimple" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61090.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61090.c new file mode 100644 index 00000000000..fff289572ac --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61090.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +struct i { + int c; +}; + +static int +p(struct i a) +{ + return 0; +} + +void +h(void) +{ + struct i z[] = {{ 0 }}; + int e[] = {}; + int x; + e[0] = p(z[x]) + z[x].c; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61140.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61140.c new file mode 100644 index 00000000000..2f175cb7e2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61140.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int a[1] = { 1 }, b = 1, c; + +int +main () +{ + for (; c < 1; c++) + if (a[0]) + { + a[0] &= 1; + b = 0; + } + if (b) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61150.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61150.c new file mode 100644 index 00000000000..c11798cace4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61150.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +int a, b, c, d = 1; + +int +main () +{ + int e = d; + for (b = 0; b < 5; b++) + { + for (a = 0; a < 1; a++) + { + if (e) + break; + for (c = 0; c < 1; c++) + ; + } + e |= 1; + } + if (c) + __builtin_abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61197.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61197.c new file mode 100644 index 00000000000..919578b7ff7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61197.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +int a, b = 1, *c = &a; + +int +foo () +{ + if (b) + b |= 1; + else + { + b = 1; + return 0; + } + return 1; +} + +int +main () +{ + *c = foo (); + if (a != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-6.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-6.c index 3d020067ca7..cf496291f8d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-6.c @@ -3,6 +3,7 @@ int foo11 (int c) { + __attribute__ ((used)) static int local1, local2; local1 = 0; local2 += c; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-39.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-39.c new file mode 100644 index 00000000000..a30926caccd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-39.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre1" } */ + +int foo (int i) +{ + int k = i + 1; + int j = i + 1; + if (k != j) + k = k + 1; + if (k != j) + k = k + 1; + k = k - i; + return k; +} + +/* We should be able to value-number the final assignment to k to 1. */ + +/* { dg-final { scan-tree-dump "k_. = 1;" "fre1" } } */ +/* { dg-final { cleanup-tree-dump "fre1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-40.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-40.c new file mode 100644 index 00000000000..577f9fe8e5e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-40.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre1" } */ + +int x; +int foo (int *p) +{ + x = 0; + if (x) + *p = 1; + return x; +} + +/* The final load of x should be replaced as well as the + aliasing store via *p is not reachable. */ + +/* { dg-final { scan-tree-dump-not "= x;" "fre1" } } */ +/* { dg-final { cleanup-tree-dump "fre1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-41.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-41.c new file mode 100644 index 00000000000..82ca746e173 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-41.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre1" } */ + +int x; +int foo (void) +{ + x = 1; + return __builtin_ffs (x); +} + +/* { dg-final { scan-tree-dump-not "ffs" "fre1" } } */ +/* { dg-final { cleanup-tree-dump "fre1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-8.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-8.c index f08ef7fde60..dab57fa391b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-8.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-8.c @@ -17,7 +17,9 @@ foo (__SIZE_TYPE__ i, struct s *array) return 0; } /* We should eliminate two address calculations, and one load. */ +/* We also elimiate the PHI node feeding the return because the case + returning 1 is unreachable. */ /* We used to eliminate a cast but that was before POINTER_PLUS_EXPR was added. */ -/* { dg-final { scan-tree-dump-times "Eliminated: 3" 1 "fre1"} } */ +/* { dg-final { scan-tree-dump-times "Eliminated: 4" 1 "fre1"} } */ /* { dg-final { cleanup-tree-dump "fre1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/struct-aliasing-2.c b/gcc/testsuite/gcc.dg/tree-ssa/struct-aliasing-2.c index c348bdfe25b..66a5442a9ef 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/struct-aliasing-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/struct-aliasing-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-fre1" } */ +/* { dg-options "-O2 -fdump-tree-cddce1" } */ struct S { unsigned f; }; @@ -12,8 +12,8 @@ foo ( struct S *p) } -/* There should only be one load of p->f because fwprop can change - *(int *)&p->f into just (int)p->f. */ -/* { dg-final { scan-tree-dump-times "= \[^\n\]*p_.\\\(D\\\)" 1 "fre1" } } */ -/* { dg-final { cleanup-tree-dump "fre1" } } */ +/* There should only be one load of p->f because FRE removes the redundancy + by realizing it can cast the result of either to the other. */ +/* { dg-final { scan-tree-dump-times "= \[^\n\]*p_.\\\(D\\\)" 1 "cddce1" } } */ +/* { dg-final { cleanup-tree-dump "cddce1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c new file mode 100644 index 00000000000..a84ba8e2903 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ + +void bar (void); +int foo (int i, int j) +{ + int res = 1; + if (i < j) + { + /* We should be able to simplify the following conditional + during propagation. */ + if (i > j) + res = 0; + } + /* And compute res as having a value-range of [1,1]. */ + if (res) + return i; + return j; +} + +/* { dg-final { scan-tree-dump "res_.: \\\[1, 1\\\]" "vrp1" } } */ +/* { dg-final { scan-tree-dump-not "Threaded" "vrp1" } } */ +/* { dg-final { cleanup-tree-dump "vrp1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/writeonly.c b/gcc/testsuite/gcc.dg/tree-ssa/writeonly.c new file mode 100644 index 00000000000..156cf3ef6a8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/writeonly.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ +static struct a {int magic1,b;} a; +volatile int magic2; +static struct b {int a,b,c,d,e,f;} magic3; + +struct b foo(); + +t() +{ + a.magic1 = 1; + magic2 = 1; + magic3 = foo(); +} +/* { dg-final { scan-tree-dump-not "magic1" "optimized"} } */ +/* { dg-final { scan-tree-dump-not "magic3" "optimized"} } */ +/* { dg-final { scan-tree-dump "magic2" "optimized"} } */ +/* { dg-final { scan-tree-dump "foo" "optimized"} } */ + +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/ubsan/float-cast-overflow-bf.c b/gcc/testsuite/gcc.dg/ubsan/float-cast-overflow-bf.c new file mode 100644 index 00000000000..298d0d91849 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/float-cast-overflow-bf.c @@ -0,0 +1,72 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=float-cast-overflow" } */ + +struct +{ + int i:1; +} s; + +struct +{ + unsigned int i:1; +} t; + +int +main (void) +{ + volatile double d; + +#define CHECK_BOUNDARY(VAR, VAL) \ + (VAR) = (VAL) - 1.5; \ + (VAR) = (VAL) - 1.0; \ + (VAR) = (VAL) - 0.5; \ + (VAR) = (VAL) - 0.0000001; \ + (VAR) = (VAL) - 0.0; \ + (VAR) = (VAL); \ + (VAR) = (VAL) + 0.0; \ + (VAR) = (VAL) + 0.0000001; \ + (VAR) = (VAL) + 0.5; \ + (VAR) = (VAL) + 1.0; \ + (VAR) = (VAL) + 1.5; + + /* Signed bit-field. (-1, 0) is valid. */ + d = -1.0; + CHECK_BOUNDARY (s.i, d); + d = 0.0; + CHECK_BOUNDARY (s.i, d); + d = 1.0; + CHECK_BOUNDARY (s.i, d); + + /* Unsigned bit-field. (0, 1) is valid. */ + d = -1.0; + CHECK_BOUNDARY (t.i, d); + d = 0.0; + CHECK_BOUNDARY (t.i, d); + d = 1.0; + CHECK_BOUNDARY (t.i, d); + + return 0; +} + +/* { dg-output "value -2.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -2 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 2 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 2.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -2.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -2 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 2 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*value 2.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/gcc.dg/uninit-13.c b/gcc/testsuite/gcc.dg/uninit-13.c index 631e8de3ada..5e88a8a9454 100644 --- a/gcc/testsuite/gcc.dg/uninit-13.c +++ b/gcc/testsuite/gcc.dg/uninit-13.c @@ -5,6 +5,6 @@ typedef _Complex float C; C foo() { C f; - __imag__ f = 0; /* { dg-warning "is used" "unconditional" } */ - return f; + __imag__ f = 0; + return f; /* { dg-warning "is used" "unconditional" } */ } diff --git a/gcc/testsuite/gcc.dg/uninit-17-O0.c b/gcc/testsuite/gcc.dg/uninit-17-O0.c new file mode 100644 index 00000000000..0eaef053367 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-17-O0.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +typedef _Complex float C; +C foo(int cond) +{ + C f; + __imag__ f = 0; + if (cond) + { + __real__ f = 1; + return f; + } + return f; +} diff --git a/gcc/testsuite/gcc.dg/uninit-17.c b/gcc/testsuite/gcc.dg/uninit-17.c new file mode 100644 index 00000000000..8a95f15c5ae --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-17.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +typedef _Complex float C; +C foo(int cond) +{ + C f; + __imag__ f = 0; + if (cond) + { + __real__ f = 1; + return f; + } + return f; /* { dg-warning "may be used" "unconditional" } */ +} diff --git a/gcc/testsuite/gcc.dg/unused-8a.c b/gcc/testsuite/gcc.dg/unused-8a.c new file mode 100644 index 00000000000..b9b56905156 --- /dev/null +++ b/gcc/testsuite/gcc.dg/unused-8a.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra -Wno-unused" } */ + +void foo(int x) { } diff --git a/gcc/testsuite/gcc.dg/unused-8b.c b/gcc/testsuite/gcc.dg/unused-8b.c new file mode 100644 index 00000000000..5b4b894937c --- /dev/null +++ b/gcc/testsuite/gcc.dg/unused-8b.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wno-unused -Wextra" } */ + +void foo(int x) { } diff --git a/gcc/testsuite/gcc.dg/vect/pr52252-ld.c b/gcc/testsuite/gcc.dg/vect/pr52252-ld.c index 6e3cb52b85d..e37b177f8f3 100644 --- a/gcc/testsuite/gcc.dg/vect/pr52252-ld.c +++ b/gcc/testsuite/gcc.dg/vect/pr52252-ld.c @@ -1,6 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -g -ftree-vectorize -mssse3 -fdump-tree-vect-details" { target { i?86-*-* x86_64-*-* } } } */ - +/* { dg-additional-options "-mssse3" { target { i?86-*-* x86_64-*-* } } } */ #define byte unsigned char void @@ -26,5 +25,5 @@ matrix_mul (byte *in, byte *out, int size) } } -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { i?86-*-* x86_64-*-* } } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr61194.c b/gcc/testsuite/gcc.dg/vect/pr61194.c new file mode 100644 index 00000000000..e10cff4b96c --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr61194.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_cond_mixed } */ +/* { dg-additional-options "-ftree-loop-if-convert-stores" } */ + +#include "tree-vect.h" + +static float x[1024]; +static float y[1024]; +static float z[1024]; +static float w[1024]; + +void __attribute__((noinline,noclone)) barX() +{ + int i; + for (i=0; i<1024; ++i) + z[i] = ((x[i]>0) & (w[i]<0)) ? z[i] : y[i]; +} + +int main() +{ + int i; + + check_vect (); + + for (i = 0; i < 1024; ++i) + { + x[i] = -10 + i; + w[i] = 100 - i; + z[i] = 0.; + y[i] = 1.; + __asm__ volatile ("" : : : "memory"); + } + + barX(); + + for (i = 0; i < 1024; ++i) + if (z[i] != ((x[i]>0 && w[i]<0) ? 0. : 1.)) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect.exp b/gcc/testsuite/gcc.dg/vect/vect.exp index fa11e7e5eea..e8d866b991c 100644 --- a/gcc/testsuite/gcc.dg/vect/vect.exp +++ b/gcc/testsuite/gcc.dg/vect/vect.exp @@ -18,6 +18,7 @@ # Load support procs. load_lib gcc-dg.exp +load_lib clearcap.exp # Set up flags used for tests that don't specify options. global DEFAULT_VECTCFLAGS @@ -41,30 +42,9 @@ if ![check_vect_support_and_set_flags] { # These flags are used for all targets. lappend DEFAULT_VECTCFLAGS "-ftree-vectorize" "-fno-vect-cost-model" "-fno-common" -# If the linker used understands -M <mapfile>, pass it to clear hardware -# capabilities set by the Sun assembler. -# Try mapfile syntax v2 first which is the only way to clear hwcap_2 flags. -set clearcap_ldflags "-Wl,-M,$srcdir/gcc.target/i386/clearcapv2.map" - -if ![check_no_compiler_messages mapfilev2 executable { - int main (void) { return 0; } -} $clearcap_ldflags ] { - # If this doesn't work, fall back to the less capable v1 syntax. - set clearcap_ldflags "-Wl,-M,$srcdir/gcc.target/i386/clearcap.map" - - if ![check_no_compiler_messages mapfile executable { - int main (void) { return 0; } - } $clearcap_ldflags ] { - unset clearcap_ldflags - } -} - -if [info exists clearcap_ldflags] { - lappend DEFAULT_VECTCFLAGS $clearcap_ldflags -} - # Initialize `dg'. dg-init +clearcap-init global VEC_FLAGS set VEC_FLAGS $DEFAULT_VECTCFLAGS @@ -308,4 +288,5 @@ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-tree-sra-bb-slp-*.\[cS\]] set dg-do-what-default ${save-dg-do-what-default} # All done. +clearcap-finish dg-finish diff --git a/gcc/testsuite/gcc.dg/wtr-conversion-1.c b/gcc/testsuite/gcc.dg/wtr-conversion-1.c index 72094c21840..9d2cd999939 100644 --- a/gcc/testsuite/gcc.dg/wtr-conversion-1.c +++ b/gcc/testsuite/gcc.dg/wtr-conversion-1.c @@ -2,7 +2,7 @@ Note, gcc should omit these warnings in system header files. By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 4/09/2001. */ /* { dg-do compile } */ -/* { dg-options "-Wtraditional" } */ +/* { dg-options "-Wtraditional-conversion" } */ extern void foo_i (int); extern void foo_f (float); |