summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr59322.c16
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr59362.c21
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20131127-1.c34
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr59014-2.c23
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr59014.c25
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr59229.c29
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr59358.c44
7 files changed, 192 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr59322.c b/gcc/testsuite/gcc.c-torture/compile/pr59322.c
new file mode 100644
index 00000000000..918d6bdb18e
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr59322.c
@@ -0,0 +1,16 @@
+
+int a, b, d;
+short c;
+
+int
+foo ()
+{
+ for (b = 0; b; b = a)
+ for (c = 18; c < 10; c++)
+ {
+ d = c;
+ if (d)
+ return 0;
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr59362.c b/gcc/testsuite/gcc.c-torture/compile/pr59362.c
new file mode 100644
index 00000000000..3e78f76bc5f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr59362.c
@@ -0,0 +1,21 @@
+/* PR tree-optimization/59362 */
+
+char *
+foo (char *r, int s)
+{
+ r = __builtin___stpcpy_chk (r, "abc", __builtin_object_size (r, 1));
+ if (s)
+ r = __builtin___stpcpy_chk (r, "d", __builtin_object_size (r, 1));
+ return r;
+}
+
+char *a;
+long int b;
+
+void
+bar (void)
+{
+ b = __builtin_object_size (0, 0);
+ a = __builtin___stpcpy_chk (0, "", b);
+ b = __builtin_object_size (a, 0);
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20131127-1.c b/gcc/testsuite/gcc.c-torture/execute/20131127-1.c
new file mode 100644
index 00000000000..8ec49657741
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20131127-1.c
@@ -0,0 +1,34 @@
+/* PR middle-end/59138 */
+/* Testcase by John Regehr <regehr@cs.utah.edu> */
+
+extern void abort (void);
+
+#pragma pack(1)
+
+struct S0 {
+ int f0;
+ int f1;
+ int f2;
+ short f3;
+};
+
+short a = 1;
+
+struct S0 b = { 1 }, c, d, e;
+
+struct S0 fn1() { return c; }
+
+void fn2 (void)
+{
+ b = fn1 ();
+ a = 0;
+ d = e;
+}
+
+int main (void)
+{
+ fn2 ();
+ if (a != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c b/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c
new file mode 100644
index 00000000000..18da0059eab
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c
@@ -0,0 +1,23 @@
+/* PR tree-optimization/59014 */
+
+__attribute__((noinline, noclone)) long long int
+foo (long long int x, long long int y)
+{
+ if (((int) x | (int) y) != 0)
+ return 6;
+ return x + y;
+}
+
+int
+main ()
+{
+ if (sizeof (long long) == sizeof (int))
+ return 0;
+ int shift_half = sizeof (int) * __CHAR_BIT__ / 2;
+ long long int x = (3LL << shift_half) << shift_half;
+ long long int y = (5LL << shift_half) << shift_half;
+ long long int z = foo (x, y);
+ if (z != ((8LL << shift_half) << shift_half))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59014.c b/gcc/testsuite/gcc.c-torture/execute/pr59014.c
new file mode 100644
index 00000000000..10bf81a462f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr59014.c
@@ -0,0 +1,25 @@
+/* PR tree-optimization/59014 */
+
+int a = 2, b, c, d;
+
+int
+foo ()
+{
+ for (;; c++)
+ if ((b > 0) | (a & 1))
+ ;
+ else
+ {
+ d = a;
+ return 0;
+ }
+}
+
+int
+main ()
+{
+ foo ();
+ if (d != 2)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59229.c b/gcc/testsuite/gcc.c-torture/execute/pr59229.c
new file mode 100644
index 00000000000..d2a776778de
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr59229.c
@@ -0,0 +1,29 @@
+int i;
+
+__attribute__((noinline, noclone)) void
+bar (char *p)
+{
+ if (i < 1 || i > 6)
+ __builtin_abort ();
+ if (__builtin_memcmp (p, "abcdefg", i + 1) != 0)
+ __builtin_abort ();
+ __builtin_memset (p, ' ', 7);
+}
+
+__attribute__((noinline, noclone)) void
+foo (char *p, unsigned long l)
+{
+ if (l < 1 || l > 6)
+ return;
+ char buf[7];
+ __builtin_memcpy (buf, p, l + 1);
+ bar (buf);
+}
+
+int
+main ()
+{
+ for (i = 0; i < 16; i++)
+ foo ("abcdefghijklmnop", i);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59358.c b/gcc/testsuite/gcc.c-torture/execute/pr59358.c
new file mode 100644
index 00000000000..674026d6258
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr59358.c
@@ -0,0 +1,44 @@
+/* PR tree-optimization/59358 */
+
+__attribute__((noinline, noclone)) int
+foo (int *x, int y)
+{
+ int z = *x;
+ if (y > z && y <= 16)
+ while (y > z)
+ z *= 2;
+ return z;
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 1; i < 17; i++)
+ {
+ int j = foo (&i, 16);
+ int k;
+ if (i >= 8 && i <= 15)
+ k = 16 + (i - 8) * 2;
+ else if (i >= 4 && i <= 7)
+ k = 16 + (i - 4) * 4;
+ else if (i == 3)
+ k = 24;
+ else
+ k = 16;
+ if (j != k)
+ __builtin_abort ();
+ j = foo (&i, 7);
+ if (i >= 7)
+ k = i;
+ else if (i >= 4)
+ k = 8 + (i - 4) * 2;
+ else if (i == 3)
+ k = 12;
+ else
+ k = 8;
+ if (j != k)
+ __builtin_abort ();
+ }
+ return 0;
+}