aboutsummaryrefslogtreecommitdiff
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/pr89412.c16
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr89655.c15
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr89663-1.c81
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr89663-2.c82
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr89703-1.c13
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr89703-2.c13
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr89998-1.c42
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr89998-2.c4
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr90139.c20
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20190820-1.c111
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20190901-1.c36
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20191023-1.c73
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp2
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr90949.c42
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr91137.c34
15 files changed, 583 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89412.c b/gcc/testsuite/gcc.c-torture/compile/pr89412.c
new file mode 100644
index 00000000000..0d6ddd5db94
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89412.c
@@ -0,0 +1,16 @@
+/* PR middle-end/89412 */
+
+struct S { double a, b; } d;
+int e;
+double f;
+
+void
+foo ()
+{
+ _Complex double h;
+ while (e)
+ {
+ f = h;
+ *(struct S *) &h = d;
+ }
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89655.c b/gcc/testsuite/gcc.c-torture/compile/pr89655.c
new file mode 100644
index 00000000000..f304c673206
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89655.c
@@ -0,0 +1,15 @@
+/* PR middle-end/89655 */
+
+int a, b, d;
+char *c;
+
+void
+foo (void)
+{
+ int f = a;
+ for (;;)
+ {
+ for (f = 0; f < (a > 3 ? : a); f++)
+ b = c[f] ? c[(f + 2 > a - 1 ? a - 1 : 2) * d] : 0;
+ }
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89663-1.c b/gcc/testsuite/gcc.c-torture/compile/pr89663-1.c
new file mode 100644
index 00000000000..4fc2d0d4cb5
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89663-1.c
@@ -0,0 +1,81 @@
+/* PR middle-end/89663 */
+
+int irint ();
+long lrint ();
+long long llrint ();
+int iround ();
+long lround ();
+long long llround ();
+int iceil ();
+long lceil ();
+long long llceil ();
+int ifloor ();
+long lfloor ();
+long long llfloor ();
+int irintf ();
+long lrintf ();
+long long llrintf ();
+int iroundf ();
+long lroundf ();
+long long llroundf ();
+int iceilf ();
+long lceilf ();
+long long llceilf ();
+int ifloorf ();
+long lfloorf ();
+long long llfloorf ();
+int irintl ();
+long lrintl ();
+long long llrintl ();
+int iroundl ();
+long lroundl ();
+long long llroundl ();
+int iceill ();
+long lceill ();
+long long llceill ();
+int ifloorl ();
+long lfloorl ();
+long long llfloorl ();
+
+void
+foo (long long *p)
+{
+ int n = 0;
+#define T(f) p[n++] = f (1);
+ T (irint)
+ T (lrint)
+ T (llrint)
+ T (iround)
+ T (lround)
+ T (llround)
+ T (iceil)
+ T (lceil)
+ T (llceil)
+ T (ifloor)
+ T (lfloor)
+ T (llfloor)
+ T (irintf)
+ T (lrintf)
+ T (llrintf)
+ T (iroundf)
+ T (lroundf)
+ T (llroundf)
+ T (iceilf)
+ T (lceilf)
+ T (llceilf)
+ T (ifloorf)
+ T (lfloorf)
+ T (llfloorf)
+ T (irintl)
+ T (lrintl)
+ T (llrintl)
+ T (iroundl)
+ T (lroundl)
+ T (llroundl)
+ T (iceill)
+ T (lceill)
+ T (llceill)
+ T (ifloorl)
+ T (lfloorl)
+ T (llfloorl)
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89663-2.c b/gcc/testsuite/gcc.c-torture/compile/pr89663-2.c
new file mode 100644
index 00000000000..052fe69f40e
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89663-2.c
@@ -0,0 +1,82 @@
+/* PR middle-end/89663 */
+
+int irint (double);
+long lrint (double);
+long long llrint (double);
+int iround (double);
+long lround (double);
+long long llround (double);
+int iceil (double);
+long lceil (double);
+long long llceil (double);
+int ifloor (double);
+long lfloor (double);
+long long llfloor (double);
+int irintf (float);
+long lrintf (float);
+long long llrintf (float);
+int iroundf (float);
+long lroundf (float);
+long long llroundf (float);
+int iceilf (float);
+long lceilf (float);
+long long llceilf (float);
+int ifloorf (float);
+long lfloorf (float);
+long long llfloorf (float);
+int irintl (long double);
+long lrintl (long double);
+long long llrintl (long double);
+int iroundl (long double);
+long lroundl (long double);
+long long llroundl (long double);
+int iceill (long double);
+long lceill (long double);
+long long llceill (long double);
+int ifloorl (long double);
+long lfloorl (long double);
+long long llfloorl (long double);
+
+void
+foo (long long *p)
+{
+ int (*fn) (int);
+ int n = 0;
+#define T(f) fn = (int (*) (int)) f; p[n++] = fn (1);
+ T (irint)
+ T (lrint)
+ T (llrint)
+ T (iround)
+ T (lround)
+ T (llround)
+ T (iceil)
+ T (lceil)
+ T (llceil)
+ T (ifloor)
+ T (lfloor)
+ T (llfloor)
+ T (irintf)
+ T (lrintf)
+ T (llrintf)
+ T (iroundf)
+ T (lroundf)
+ T (llroundf)
+ T (iceilf)
+ T (lceilf)
+ T (llceilf)
+ T (ifloorf)
+ T (lfloorf)
+ T (llfloorf)
+ T (irintl)
+ T (lrintl)
+ T (llrintl)
+ T (iroundl)
+ T (lroundl)
+ T (llroundl)
+ T (iceill)
+ T (lceill)
+ T (llceill)
+ T (ifloorl)
+ T (lfloorl)
+ T (llfloorl)
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89703-1.c b/gcc/testsuite/gcc.c-torture/compile/pr89703-1.c
new file mode 100644
index 00000000000..958cc7744e1
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89703-1.c
@@ -0,0 +1,13 @@
+/* PR tree-optimization/89703 */
+
+typedef __SIZE_TYPE__ size_t;
+extern char *strlen (const char *);
+extern char *strnlen (const char *, size_t);
+extern char c[2];
+
+void
+foo (char **q)
+{
+ q[0] = strlen (c);
+ q[1] = strnlen (c, 2);
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89703-2.c b/gcc/testsuite/gcc.c-torture/compile/pr89703-2.c
new file mode 100644
index 00000000000..d2676ded0ca
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89703-2.c
@@ -0,0 +1,13 @@
+/* PR tree-optimization/89703 */
+
+typedef __SIZE_TYPE__ size_t;
+extern void *memcpy (void *, const void *, size_t);
+extern char *strlen (const char *);
+extern char c[2];
+
+void
+foo (char **q)
+{
+ memcpy (c, "a", 2);
+ q[0] = strlen (c);
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89998-1.c b/gcc/testsuite/gcc.c-torture/compile/pr89998-1.c
new file mode 100644
index 00000000000..87be00ce3ce
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89998-1.c
@@ -0,0 +1,42 @@
+/* PR tree-optimization/89998 */
+
+unsigned int sprintf (char *str, const char *fmt, ...);
+unsigned int snprintf (char *str, __SIZE_TYPE__ len, const char *fmt, ...);
+
+int
+f1 (char *s)
+{
+ return sprintf (s, "foo");
+}
+
+int
+f2 (char *s)
+{
+ return sprintf (s, "%d", 123);
+}
+
+int
+f3 (int *p, char *s)
+{
+ const char *t = "bar";
+ return sprintf (s, "%s", t);
+}
+
+int
+f4 (char *s)
+{
+ return snprintf (s, 8, "foo");
+}
+
+int
+f5 (char *s)
+{
+ return snprintf (s, 8, "%d", 123);
+}
+
+int
+f6 (int *p, char *s)
+{
+ const char *t = "bar";
+ return snprintf (s, 8, "%s", t);
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89998-2.c b/gcc/testsuite/gcc.c-torture/compile/pr89998-2.c
new file mode 100644
index 00000000000..19e318b8905
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89998-2.c
@@ -0,0 +1,4 @@
+/* PR tree-optimization/89998 */
+/* { dg-additional-options "-fno-printf-return-value" } */
+
+#include "pr89998-1.c"
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr90139.c b/gcc/testsuite/gcc.c-torture/compile/pr90139.c
new file mode 100644
index 00000000000..f3d99f04c86
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr90139.c
@@ -0,0 +1,20 @@
+/* PR middle-end/90139 */
+
+typedef float __attribute__((vector_size (sizeof (float)))) V;
+void bar (int, V *);
+int l;
+
+void
+foo (void)
+{
+ V n, b, o;
+ while (1)
+ switch (l)
+ {
+ case 0:
+ o = n;
+ n = b;
+ b = o;
+ bar (1, &o);
+ }
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20190820-1.c b/gcc/testsuite/gcc.c-torture/execute/20190820-1.c
new file mode 100644
index 00000000000..6a06eff7571
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20190820-1.c
@@ -0,0 +1,111 @@
+/* PR rtl-optimization/91347 */
+/* Reported by John David Anglin <danglin@gcc.gnu.org> */
+
+typedef unsigned short __u16;
+typedef __signed__ int __s32;
+typedef unsigned int __u32;
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;
+typedef __u16 u16;
+typedef __s32 s32;
+typedef __u32 u32;
+typedef __u64 u64;
+typedef _Bool bool;
+typedef s32 int32_t;
+typedef u32 uint32_t;
+typedef u64 uint64_t;
+
+char hex_asc_upper[16];
+u16 decpair[100];
+
+static __attribute__ ((noipa)) void
+put_dec_full4 (char *buf, unsigned r)
+{
+ unsigned q;
+ q = (r * 0x147b) >> 19;
+ *((u16 *)buf) = decpair[r - 100*q];
+ buf += 2;
+ *((u16 *)buf) = decpair[q];
+}
+
+static __attribute__ ((noipa)) unsigned
+put_dec_helper4 (char *buf, unsigned x)
+{
+ uint32_t q = (x * (uint64_t)0x346DC5D7) >> 43;
+ put_dec_full4(buf, x - q * 10000);
+ return q;
+}
+
+static __attribute__ ((noipa)) char *
+put_dec (char *buf, unsigned long long n)
+{
+ uint32_t d3, d2, d1, q, h;
+ d1 = ((uint32_t)n >> 16);
+ h = (n >> 32);
+ d2 = (h ) & 0xffff;
+ d3 = (h >> 16);
+ q = 656 * d3 + 7296 * d2 + 5536 * d1 + ((uint32_t)n & 0xffff);
+ q = put_dec_helper4(buf, q);
+ q += 7671 * d3 + 9496 * d2 + 6 * d1;
+ q = put_dec_helper4(buf+4, q);
+ q += 4749 * d3 + 42 * d2;
+ q = put_dec_helper4(buf+8, q);
+ return buf;
+}
+
+struct printf_spec {
+ unsigned int type:8;
+ signed int field_width:24;
+ unsigned int flags:8;
+ unsigned int base:8;
+ signed int precision:16;
+} __attribute__((__packed__));
+
+static __attribute__ ((noipa)) char *
+number (char *buf, char *end, unsigned long long num, struct printf_spec spec)
+{
+
+ char tmp[3 * sizeof(num)] __attribute__((__aligned__(2)));
+ char sign;
+ char locase;
+ int need_pfx = ((spec.flags & 64) && spec.base != 10);
+ int i;
+ bool is_zero = num == 0LL;
+ int field_width = spec.field_width;
+ int precision = spec.precision;
+
+ i = 0;
+ if (num < spec.base)
+ tmp[i++] = hex_asc_upper[num] | locase;
+ else if (spec.base != 10) {
+ int mask = spec.base - 1;
+ int shift = 3;
+ if (spec.base == 16)
+ shift = 4;
+ else
+ __builtin_abort ();
+ do {
+ tmp[i++] = (hex_asc_upper[((unsigned char)num) & mask] | locase);
+ num >>= shift;
+ } while (num);
+ } else {
+ i = put_dec(tmp, num) - tmp;
+ }
+ return buf;
+}
+
+static __attribute__ ((noipa)) char *
+pointer_string (char *buf, char *end, const void *ptr, struct printf_spec spec)
+{
+ spec.base = 16;
+ spec.flags = 0;
+ return number(buf, end, 100, spec);
+}
+
+int
+main (void)
+{
+ struct printf_spec spec;
+ char *s = pointer_string (0, 0, 0, spec);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20190901-1.c b/gcc/testsuite/gcc.c-torture/execute/20190901-1.c
new file mode 100644
index 00000000000..c78715ef2c1
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20190901-1.c
@@ -0,0 +1,36 @@
+/* PR target/91472 */
+/* Reported by John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> */
+
+typedef unsigned int gmp_uint_least32_t;
+
+union ieee_double_extract
+{
+ struct
+ {
+ gmp_uint_least32_t sig:1;
+ gmp_uint_least32_t exp:11;
+ gmp_uint_least32_t manh:20;
+ gmp_uint_least32_t manl:32;
+ } s;
+ double d;
+};
+
+double __attribute__((noipa))
+tests_infinity_d (void)
+{
+ union ieee_double_extract x;
+ x.s.exp = 2047;
+ x.s.manl = 0;
+ x.s.manh = 0;
+ x.s.sig = 0;
+ return x.d;
+}
+
+int
+main (void)
+{
+ double x = tests_infinity_d ();
+ if (x == 0.0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20191023-1.c b/gcc/testsuite/gcc.c-torture/execute/20191023-1.c
new file mode 100644
index 00000000000..3811ebca151
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20191023-1.c
@@ -0,0 +1,73 @@
+/* PR tree-optimization/92131 */
+/* Testcase by Armin Rigo <arigo@tunes.org> */
+
+long b, c, d, e, f, i;
+char g, h, j, k;
+int *aa;
+
+static void error (void) __attribute__((noipa));
+static void error (void) { __builtin_abort(); }
+
+static void see_me_here (void) __attribute__((noipa));
+static void see_me_here (void) {}
+
+static void aaa (void) __attribute__((noipa));
+static void aaa (void) {}
+
+static void a (void) __attribute__((noipa));
+static void a (void) {
+ long am, ao;
+ if (aa == 0) {
+ aaa();
+ if (j)
+ goto ay;
+ }
+ return;
+ay:
+ aaa();
+ if (k) {
+ aaa();
+ goto az;
+ }
+ return;
+az:
+ if (i)
+ if (g)
+ if (h)
+ if (e)
+ goto bd;
+ return;
+bd:
+ am = 0;
+ while (am < e) {
+ switch (c) {
+ case 8:
+ goto bh;
+ case 4:
+ return;
+ }
+ bh:
+ if (am >= 0)
+ b = -am;
+ ao = am + b;
+ f = ao & 7;
+ if (f == 0)
+ see_me_here();
+ if (ao >= 0)
+ am++;
+ else
+ error();
+ }
+}
+
+int main (void)
+{
+ j++;
+ k++;
+ i++;
+ g++;
+ h++;
+ e = 1;
+ a();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
index 9f0b24ad4ee..e8297e15f18 100644
--- a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
@@ -37,7 +37,7 @@ load_lib c-torture.exp
torture-init
set-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
-set additional_flags "-fno-tree-loop-distribute-patterns -fno-tracer"
+set additional_flags "-fno-tree-loop-distribute-patterns -fno-tracer -fno-ipa-ra"
if [istarget "powerpc-*-darwin*"] {
lappend additional_flags "-Wl,-multiply_defined,suppress"
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr90949.c b/gcc/testsuite/gcc.c-torture/execute/pr90949.c
new file mode 100644
index 00000000000..8c2ae3972d4
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr90949.c
@@ -0,0 +1,42 @@
+void __attribute__ ((noipa, noinline)) my_puts (const char *str) { }
+
+void __attribute__ ((noipa, noinline)) my_free (void *p) { }
+
+
+struct Node
+{
+ struct Node *child;
+};
+
+struct Node space[2] = { };
+
+struct Node * __attribute__ ((noipa, noinline)) my_malloc (int bytes)
+{
+ return &space[0];
+}
+
+void
+walk (struct Node *module, int cleanup)
+{
+ if (module == 0)
+ {
+ return;
+ }
+ if (!cleanup)
+ {
+ my_puts ("No cleanup");
+ }
+ walk (module->child, cleanup);
+ if (cleanup)
+ {
+ my_free (module);
+ }
+}
+
+int
+main ()
+{
+ struct Node *node = my_malloc (sizeof (struct Node));
+ node->child = 0;
+ walk (node, 1);
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr91137.c b/gcc/testsuite/gcc.c-torture/execute/pr91137.c
new file mode 100644
index 00000000000..aa6bb6ca021
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr91137.c
@@ -0,0 +1,34 @@
+long long a;
+unsigned b;
+int c[70];
+int d[70][70];
+int e;
+
+__attribute__ ((noinline)) void f(long long *g, int p2) {
+ *g = p2;
+}
+
+__attribute__ ((noinline)) void fn2() {
+ for (int j = 0; j < 70; j++) {
+ for (int i = 0; i < 70; i++) {
+ if (b)
+ c[i] = 0;
+ for (int l = 0; l < 70; l++)
+ d[i][1] = d[l][i];
+ }
+ for (int k = 0; k < 70; k++)
+ e = c[0];
+ }
+}
+
+int main() {
+ b = 5;
+ for (int j = 0; j < 70; ++j)
+ c[j] = 2075593088;
+ fn2();
+ f(&a, e);
+ if (a)
+ __builtin_abort();
+ return 0;
+}
+