diff options
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-1-lib.c | 27 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-1.c | 57 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr119291.c | 33 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr120630.c | 29 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr120677.c | 31 |
5 files changed, 177 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-1-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-1-lib.c new file mode 100644 index 0000000..4403235 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-1-lib.c @@ -0,0 +1,27 @@ +extern void abort (void); + +void * +memcpy (void *dst, const void *src, __SIZE_TYPE__ n) +{ + const char *srcp; + char *dstp; + + srcp = src; + dstp = dst; + + if (dst < src) + { + if (dst + n > src) + abort (); + } + else + { + if (src + n > dst) + abort (); + } + + while (n-- != 0) + *dstp++ = *srcp++; + + return dst; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-1.c new file mode 100644 index 0000000..0a12b0f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-1.c @@ -0,0 +1,57 @@ +extern void abort (void); +extern void exit (int); +struct s { unsigned char a[256]; }; +union u { struct { struct s b; int c; } d; struct { int c; struct s b; } e; }; +static union u v; +static union u v0; +static struct s *p = &v.d.b; +static struct s *q = &v.e.b; + +struct outers +{ + struct s inner; +}; + +static inline struct s rp (void) { return *p; } +static inline struct s rq (void) { return *q; } +static void pq (void) +{ + struct outers o = {rq () }; + *p = o.inner; +} +static void qp (void) +{ + struct outers o = {rp () }; + *q = o.inner; +} + +static void +init (struct s *sp) +{ + int i; + for (i = 0; i < 256; i++) + sp->a[i] = i; +} + +static void +check (struct s *sp) +{ + int i; + for (i = 0; i < 256; i++) + if (sp->a[i] != i) + abort (); +} + +void +main_test (void) +{ + v = v0; + init (p); + qp (); + check (q); + v = v0; + init (q); + pq (); + check (p); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr119291.c b/gcc/testsuite/gcc.c-torture/execute/pr119291.c new file mode 100644 index 0000000..41eadf0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr119291.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/119291 */ + +int a; +long c; + +__attribute__((noipa)) void +foo (int x) +{ + if (x != 0) + __builtin_abort (); + a = 42; +} + +int +main () +{ + int e = 1; +lab: + if (a < 2) + { + int b = e; + _Bool d = a != 0; + _Bool f = b != 0; + unsigned long g = -(d & f); + unsigned long h = c & g; + unsigned long i = ~c; + e = -(i & h); + c = e != 0; + a = ~e + b; + foo (e); + goto lab; + } +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr120630.c b/gcc/testsuite/gcc.c-torture/execute/pr120630.c new file mode 100644 index 0000000..46cfac9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr120630.c @@ -0,0 +1,29 @@ +/* PR middle-end/120630 */ + +__attribute__((noipa)) int +foo (const char *x, ...) +{ + return *x; +} + +int a, b, c; +unsigned d = 1; + +int +main () +{ + if (a) + foo ("0"); + int e = -1; + if (a < 1) + { + e = c; + if (c) + while (1) + ; + } + b = (~e + 0UL) / -1; + if (d > b) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr120677.c b/gcc/testsuite/gcc.c-torture/execute/pr120677.c new file mode 100644 index 0000000..3cff04e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr120677.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/120677 */ +/* { dg-do run { target int32plus } } */ + +unsigned a; +int b, e; + +int +foo (int d) +{ + switch (d) + { + case 0: + case 2: + return 0; + default: + return 1; + } +} + +int +main () +{ + for (b = 8; b; b--) + if (a & 1) + a = a >> 1 ^ 20000000; + else + a >>= 1; + e = foo (0); + if (e || a) + __builtin_abort (); +} |