From c2d4332669d358041e7aa5037271bdb37d471941 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Sun, 2 Apr 2017 22:13:51 +0000 Subject: [PATCH] nested-3.c: New testcase. 2017-04-02 Andrew Pinski * 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 | 6 +++ .../gcc.c-torture/compile/nested-3.c | 18 +++++++ .../gcc.c-torture/execute/20170401-1.c | 53 +++++++++++++++++++ .../gcc.c-torture/execute/20170401-2.c | 29 ++++++++++ 4 files changed, 106 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/nested-3.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/20170401-1.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/20170401-2.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7f236ac742e..88f1e6508e7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-04-02 Andrew Pinski + + * 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 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 index 00000000000..c46d3f5ee08 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/nested-3.c @@ -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 index 00000000000..191ea6d47ba --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20170401-1.c @@ -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 index 00000000000..bb4325867ec --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20170401-2.c @@ -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; +} -- 2.30.2