diff options
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
20 files changed, 490 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/20100609-1.c b/gcc/testsuite/gcc.c-torture/compile/20100609-1.c new file mode 100644 index 00000000000..8e1175faa32 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20100609-1.c @@ -0,0 +1,8 @@ +extern unsigned long int strtoul (__const char *__restrict __nptr, char **__restrict __endptr, int __base); +int find_reloads (int i, char *p) +{ + int c; + while ((c = *p++)) + return strtoul (p - 1, &p, 10); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44707.c b/gcc/testsuite/gcc.c-torture/compile/pr44707.c new file mode 100644 index 00000000000..9031f0042c9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44707.c @@ -0,0 +1,14 @@ +extern struct { int a, b, c, d; } v; +extern int w; + +void +foo (void) +{ + int e1 = v.a; + int e2 = w; + int e3 = v.b; + int e4 = v.c; + int e5 = v.d; + __asm__ volatile ("/* %0 %1 %2 %3 %4 */" : : "nro" (e1), "nro" (e2), "nro" (e3), "nro" (e4), "nro" (e5)); +} + diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44784.c b/gcc/testsuite/gcc.c-torture/compile/pr44784.c new file mode 100644 index 00000000000..54d531a3dff --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44784.c @@ -0,0 +1,47 @@ +typedef struct rtx_def *rtx; +enum rtx_code { SUBREG }; +typedef union rtunion_def { + long rtint; + unsigned long rtuint; + rtx rtx; +} rtunion; +struct rtx_def { + enum rtx_code code: 8; + rtunion fld[1]; +}; +typedef struct simple_bitmap_def { + unsigned long long elms[1]; +} *sbitmap; +struct df_link { + struct df_link *next; + rtx reg; +}; +typedef enum { UNDEFINED, CONSTANT, VARYING } latticevalue; +typedef struct { + latticevalue lattice_val; +} value; +static value *values; +static sbitmap ssa_edges; +void defs_to_varying (struct df_link *start) +{ + struct df_link *currdef; + for (currdef = start; + currdef; + currdef = currdef->next) + { + rtx reg = currdef->reg; + if (values[(reg->code == SUBREG + ? reg->fld[0].rtx + : reg)->fld[0].rtuint].lattice_val != VARYING) + ssa_edges->elms [(reg->code == SUBREG + ? reg->fld[0].rtx + : reg)->fld[0].rtuint / 64] + |= ((unsigned long long) 1 + << (reg->code == SUBREG + ? reg->fld[0].rtx + : reg)->fld[0].rtuint % 64); + values[(reg->code == SUBREG + ? reg->fld[0].rtx + : reg)->fld[0].rtuint].lattice_val = VARYING; + } +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44788.c b/gcc/testsuite/gcc.c-torture/compile/pr44788.c new file mode 100644 index 00000000000..99dc7982394 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44788.c @@ -0,0 +1,8 @@ +void joint_decode(float* mlt_buffer1, int t) { + int i; + float decode_buffer[1060]; + foo(decode_buffer); + for (i=0; i<10 ; i++) { + mlt_buffer1[i] = i * decode_buffer[t]; + } +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44831.c b/gcc/testsuite/gcc.c-torture/compile/pr44831.c new file mode 100644 index 00000000000..5539583deb0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44831.c @@ -0,0 +1,15 @@ +typedef unsigned char UCHAR, *PUCHAR; +typedef void *HANDLE; +typedef struct _NCB { + UCHAR ncb_reserve[10]; +} NCB, *PNCB; +struct NBCmdQueue { + PNCB head; +}; +PNCB *NBCmdQueueFindNBC(struct NBCmdQueue *queue, PNCB ncb) +{ + PNCB *ret = &queue->head; + while (ret && *ret != ncb) + ret = (PNCB *)((*ret)->ncb_reserve + sizeof(HANDLE)); +} + diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44891.c b/gcc/testsuite/gcc.c-torture/compile/pr44891.c new file mode 100644 index 00000000000..145b1446903 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44891.c @@ -0,0 +1,26 @@ +struct S +{ + float f; + long l; +}; + +extern int gi; +extern float gf; + +long foo (long p) +{ + struct S s; + float *pf; + + s.l = p; + + pf = &s.f; + + pf++; + pf--; + + gf = *pf + 3.3; + gi = *((int *)pf) + 2; + + return s.l + 6; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44941.c b/gcc/testsuite/gcc.c-torture/compile/pr44941.c new file mode 100644 index 00000000000..7d9cc8372fc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44941.c @@ -0,0 +1,8 @@ +struct S { }; + +extern void bar(struct S); + +void foo (int i) +{ + bar (*(struct S *)&i); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44946.c b/gcc/testsuite/gcc.c-torture/compile/pr44946.c new file mode 100644 index 00000000000..7b230124585 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44946.c @@ -0,0 +1,27 @@ +struct A +{ + int i; + long l; +}; + +struct B +{ + int i; +}; + +struct C +{ + int i; + struct B b; +}; + +struct B foo (struct A a) +{ + struct C *c = (struct C *) &a; + return c->b; +} +void bar (struct A a, struct B b) +{ + struct C *c = (struct C *) &a; + c->b = b; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44988.c b/gcc/testsuite/gcc.c-torture/compile/pr44988.c new file mode 100644 index 00000000000..317eafdf7c8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44988.c @@ -0,0 +1,13 @@ +struct S +{ + int i; +}; + +extern void bar (struct S); + +void +foo (void) +{ + int i = 0; + bar (*(struct S *) &i); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr45047.c b/gcc/testsuite/gcc.c-torture/compile/pr45047.c new file mode 100644 index 00000000000..f37955a0372 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr45047.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/45047 */ + +void +foo (const unsigned short *w, char *x, int y, int z) +{ + int i; + for (i = 0; i < y; i++) + x[i] = w[i] == z; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20100316-1.c b/gcc/testsuite/gcc.c-torture/execute/20100316-1.c new file mode 100644 index 00000000000..8367d7273d2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20100316-1.c @@ -0,0 +1,24 @@ +struct Foo { + int i; + unsigned precision : 10; + unsigned blah : 3; +} f; + +int __attribute__((noinline,noclone)) +foo (struct Foo *p) +{ + struct Foo *q = p; + return (*q).precision; +} + +extern void abort (void); + +int main() +{ + f.i = -1; + f.precision = 0; + f.blah = -1; + if (foo (&f) != 0) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20100416-1.c b/gcc/testsuite/gcc.c-torture/execute/20100416-1.c new file mode 100644 index 00000000000..8b5a6f45e87 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20100416-1.c @@ -0,0 +1,40 @@ +void abort(void); + +int +movegt(int x, int y, long long a) +{ + int i; + int ret = 0; + for (i = 0; i < y; i++) + { + if (a >= (long long) 0xf000000000000000LL) + ret = x; + else + ret = y; + } + return ret; +} + +struct test +{ + long long val; + int ret; +} tests[] = { + { 0xf000000000000000LL, -1 }, + { 0xefffffffffffffffLL, 1 }, + { 0xf000000000000001LL, -1 }, + { 0x0000000000000000LL, -1 }, + { 0x8000000000000000LL, 1 }, +}; + +int +main() +{ + int i; + for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) + { + if (movegt (-1, 1, tests[i].val) != tests[i].ret) + abort (); + } + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20100708-1.c b/gcc/testsuite/gcc.c-torture/execute/20100708-1.c new file mode 100644 index 00000000000..590a94a70b7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20100708-1.c @@ -0,0 +1,29 @@ +/* PR middle-end/44843 */ +/* Verify that we don't use the alignment of struct S for inner accesses. */ + +struct S +{ + double for_alignment; + struct { int x, y, z; } a[16]; +}; + +void f(struct S *s) __attribute__((noinline)); + +void f(struct S *s) +{ + unsigned int i; + + for (i = 0; i < 16; ++i) + { + s->a[i].x = 0; + s->a[i].y = 0; + s->a[i].z = 0; + } +} + +int main (void) +{ + struct S s; + f (&s); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr40657.c b/gcc/testsuite/gcc.c-torture/execute/pr40657.c new file mode 100644 index 00000000000..e6d8dda9f99 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr40657.c @@ -0,0 +1,23 @@ +/* Verify that that Thumb-1 epilogue size optimization does not clobber the + return value. */ + +long long v = 0x123456789abc; + +__attribute__((noinline)) void bar (int *x) +{ + asm volatile ("" : "=m" (x) ::); +} + +__attribute__((noinline)) long long foo() +{ + int x; + bar(&x); + return v; +} + +int main () +{ + if (foo () != v) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr44468.c b/gcc/testsuite/gcc.c-torture/execute/pr44468.c new file mode 100644 index 00000000000..c4bd492656d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr44468.c @@ -0,0 +1,60 @@ +#include <stddef.h> + +struct S { + int i; + int j; +}; +struct R { + int k; + struct S a; +}; +struct Q { + float k; + struct S a; +}; +struct Q s; +int __attribute__((noinline,noclone)) +test1 (void *q) +{ + struct S *b = (struct S *)((char *)q + sizeof (int)); + s.a.i = 0; + b->i = 3; + return s.a.i; +} +int __attribute__((noinline,noclone)) +test2 (void *q) +{ + struct S *b = &((struct R *)q)->a; + s.a.i = 0; + b->i = 3; + return s.a.i; +} +int __attribute__((noinline,noclone)) +test3 (void *q) +{ + s.a.i = 0; + ((struct S *)((char *)q + sizeof (int)))->i = 3; + return s.a.i; +} +extern void abort (void); +int +main() +{ + if (sizeof (float) != sizeof (int) + || offsetof (struct R, a) != sizeof (int) + || offsetof (struct Q, a) != sizeof (int)) + return 0; + s.a.i = 1; + s.a.j = 2; + if (test1 ((void *)&s) != 3) + abort (); + s.a.i = 1; + s.a.j = 2; + if (test2 ((void *)&s) != 3) + abort (); + s.a.i = 1; + s.a.j = 2; + if (test3 ((void *)&s) != 3) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr44683.x b/gcc/testsuite/gcc.c-torture/execute/pr44683.x new file mode 100644 index 00000000000..20413409a20 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr44683.x @@ -0,0 +1,6 @@ +if { [istarget "sh*-*-*"] } { + # SH require -mieee for this test. + set additional_flags "-mieee" +} + +return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr44828.c b/gcc/testsuite/gcc.c-torture/execute/pr44828.c new file mode 100644 index 00000000000..93837344b2d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr44828.c @@ -0,0 +1,19 @@ +extern void abort (void); + +static signed char +foo (signed char si1, signed char si2) +{ + return si1 * si2; +} + +int a = 0x105F61CA; + +int +main (void) +{ + int b = 0x0332F5C8; + if (foo (b, a) > 0) + abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/pr44852.c b/gcc/testsuite/gcc.c-torture/execute/pr44852.c new file mode 100644 index 00000000000..440653e5f17 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr44852.c @@ -0,0 +1,22 @@ +__attribute__ ((__noinline__)) +char *sf(char *s, char *s0) +{ + asm (""); + while (*--s == '9') + if (s == s0) + { + *s = '0'; + break; + } + ++*s++; + return s; +} + +int main() +{ + char s[] = "999999"; + char *x = sf (s+2, s); + if (x != s+1 || __builtin_strcmp (s, "199999") != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr44942.c b/gcc/testsuite/gcc.c-torture/execute/pr44942.c new file mode 100644 index 00000000000..3ef0830220d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr44942.c @@ -0,0 +1,70 @@ +/* PR target/44942 */ + +#include <stdarg.h> + +void +test1 (int a, int b, int c, int d, int e, int f, int g, long double h, ...) +{ + int i; + va_list ap; + + va_start (ap, h); + i = va_arg (ap, int); + if (i != 1234) + __builtin_abort (); + va_end (ap); +} + +void +test2 (int a, int b, int c, int d, int e, int f, int g, long double h, int i, + long double j, int k, long double l, int m, long double n, ...) +{ + int o; + va_list ap; + + va_start (ap, n); + o = va_arg (ap, int); + if (o != 1234) + __builtin_abort (); + va_end (ap); +} + +void +test3 (double a, double b, double c, double d, double e, double f, + double g, long double h, ...) +{ + double i; + va_list ap; + + va_start (ap, h); + i = va_arg (ap, double); + if (i != 1234.0) + __builtin_abort (); + va_end (ap); +} + +void +test4 (double a, double b, double c, double d, double e, double f, double g, + long double h, double i, long double j, double k, long double l, + double m, long double n, ...) +{ + double o; + va_list ap; + + va_start (ap, n); + o = va_arg (ap, double); + if (o != 1234.0) + __builtin_abort (); + va_end (ap); +} + +int +main () +{ + test1 (0, 0, 0, 0, 0, 0, 0, 0.0L, 1234); + test2 (0, 0, 0, 0, 0, 0, 0, 0.0L, 0, 0.0L, 0, 0.0L, 0, 0.0L, 1234); + test3 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0L, 1234.0); + test4 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0L, 0.0, 0.0L, + 0.0, 0.0L, 0.0, 0.0L, 1234.0); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr45017.c b/gcc/testsuite/gcc.c-torture/execute/pr45017.c new file mode 100644 index 00000000000..37ff286cc72 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr45017.c @@ -0,0 +1,22 @@ +int tester(char *bytes) +{ + union { + struct { + unsigned int r1:4; + unsigned int r2:4; + } fmt; + char value[1]; + } ovl; + + ovl.value[0] = bytes[0]; + return ovl.fmt.r1; +} +extern void abort (void); +int main() +{ + char buff = 0x2f; + if (tester(&buff) != 0x0f) + abort (); + return 0; +} + |