diff mbox

[Committed] Add a few testcases

Message ID CA+=Sn1mUmEREJjNPLJs+TE_YwzLwJvDVFti6svjEdp3ftmO5fw@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski April 2, 2017, 10:13 p.m. UTC
Hi,
  While working on an out of tree optimization pass, I ran into a few
failures which was not represented by the testsuite so I am adding
them now.

Committed after a bootstrap/test on aarch64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

testsuite/ChangeLog:
* gcc.c-torture/compile/nested-3.c: New testcase.
* gcc.c-torture/execute/20170401-1.c: New testcase.
* gcc.c-torture/execute/20170401-2.c: New testcase.
diff mbox

Patch

Index: gcc.c-torture/compile/nested-3.c
===================================================================
--- gcc.c-torture/compile/nested-3.c	(nonexistent)
+++ gcc.c-torture/compile/nested-3.c	(working copy)
@@ -0,0 +1,18 @@ 
+struct a
+{
+  int t;
+  int t1;
+};
+
+int f(int i, int j)
+{
+  struct a *t;
+  struct a t1 = {i, j};
+  t = &t1;
+  auto int g(void) __attribute__((noinline));
+  int g(void)
+  {
+    return t->t + t->t1;
+  }
+  return g();
+}
Index: gcc.c-torture/execute/20170401-1.c
===================================================================
--- gcc.c-torture/execute/20170401-1.c	(nonexistent)
+++ gcc.c-torture/execute/20170401-1.c	(working copy)
@@ -0,0 +1,53 @@ 
+/* PR45070 */
+extern void abort(void);
+
+struct packed_ushort {
+    unsigned short ucs;
+} __attribute__((packed));
+
+struct source {
+    int pos, length;
+};
+
+static int flag;
+
+static void __attribute__((noinline)) fetch(struct source *p)
+{
+    p->length = 128;
+}
+    
+static struct packed_ushort __attribute__((noinline)) next(struct source *p)
+{
+    struct packed_ushort rv;
+
+    if (p->pos >= p->length) {
+	if (flag) {
+	    flag = 0;
+	    fetch(p);
+	    return next(p);
+	}
+	flag = 1;
+	rv.ucs = 0xffff;
+	return rv;
+    }
+    rv.ucs = 0;
+    return rv;
+}
+
+int main(void)
+{
+    struct source s;
+    int i;
+
+    s.pos = 0;
+    s.length = 0;
+    flag = 0;
+
+    for (i = 0; i < 16; i++) {
+	struct packed_ushort rv = next(&s);
+	if ((i == 0 && rv.ucs != 0xffff)
+	    || (i > 0 && rv.ucs != 0))
+	    abort();
+    }
+    return 0;
+}
Index: gcc.c-torture/execute/20170401-2.c
===================================================================
--- gcc.c-torture/execute/20170401-2.c	(nonexistent)
+++ gcc.c-torture/execute/20170401-2.c	(working copy)
@@ -0,0 +1,29 @@ 
+void adjust_xy (short *, short *);
+
+struct adjust_template
+{
+  short kx_x;
+  short kx_y;
+};
+
+static struct adjust_template adjust = {1, 1};
+
+main ()
+{
+  short x = 1, y = 1;
+
+  adjust_xy (&x, &y);
+
+  if (x != 2)
+    abort ();
+
+  exit (0);
+}
+
+void
+adjust_xy (x, y)
+     short  *x;
+     short  *y;
+{
+  *x = adjust.kx_x * *x + adjust.kx_y * *y;
+}