nested-3.c: New testcase.
authorAndrew Pinski <apinski@cavium.com>
Sun, 2 Apr 2017 22:13:51 +0000 (22:13 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sun, 2 Apr 2017 22:13:51 +0000 (15:13 -0700)
2017-04-02  Andrew Pinski  <apinski@cavium.com>

        * 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.

From-SVN: r246639

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/nested-3.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/20170401-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/20170401-2.c [new file with mode: 0644]

index 7f236ac742e551b955a20887dec9b104a5e09d79..88f1e6508e7f2439fe1361b5496e47ab62a2fd02 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-02  Andrew Pinski  <apinski@cavium.com>
+
+       * 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.
+
 2017-03-31  Segher Boessenkool  <segher@kernel.crashing.org>
 
        PR rtl-optimization/79405
diff --git a/gcc/testsuite/gcc.c-torture/compile/nested-3.c b/gcc/testsuite/gcc.c-torture/compile/nested-3.c
new file mode 100644 (file)
index 0000000..c46d3f5
--- /dev/null
@@ -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();
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20170401-1.c b/gcc/testsuite/gcc.c-torture/execute/20170401-1.c
new file mode 100644 (file)
index 0000000..191ea6d
--- /dev/null
@@ -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;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20170401-2.c b/gcc/testsuite/gcc.c-torture/execute/20170401-2.c
new file mode 100644 (file)
index 0000000..bb43258
--- /dev/null
@@ -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;
+}