diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-01-05 12:14:12 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-01-05 12:14:12 +0100 |
commit | 23141e52419417d34eab8a2976fe417a6041e15e (patch) | |
tree | 21f0ab12fe14cd100df4f2cdc94277ffc8c9cb28 /gcc/testsuite/gcc.dg/nested-func-12.c | |
parent | 4a3e7df872be0bb7198fed02746ff5e96ff1d584 (diff) | |
download | gcc-23141e52419417d34eab8a2976fe417a6041e15e.zip gcc-23141e52419417d34eab8a2976fe417a6041e15e.tar.gz gcc-23141e52419417d34eab8a2976fe417a6041e15e.tar.bz2 |
re PR middle-end/82564 (ICE at -O1 and above: in assign_stack_temp_for_type, at function.c:783)
PR middle-end/82564
PR target/88620
* expr.c (expand_assignment): For calls returning VLA structures
if to_rtx is not a MEM, force it into a stack temporary.
* gcc.dg/nested-func-12.c: New test.
* gcc.c-torture/compile/pr82564.c: New test.
From-SVN: r267595
Diffstat (limited to 'gcc/testsuite/gcc.dg/nested-func-12.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/nested-func-12.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/nested-func-12.c b/gcc/testsuite/gcc.dg/nested-func-12.c new file mode 100644 index 0000000..d617d7e --- /dev/null +++ b/gcc/testsuite/gcc.dg/nested-func-12.c @@ -0,0 +1,48 @@ +/* PR target/88620 */ +/* { dg-do run } */ +/* { dg-options "-Ofast --param ipa-cp-eval-threshold=0 -fno-guess-branch-probability -fno-inline-small-functions" } */ +/* { dg-require-effective-target alloca } */ + +void +foo (int n) +{ + struct S { int a[n]; }; + + struct S + fn (void) + { + struct S s; + s.a[0] = 42; + return s; + } + + auto struct S + fn2 (void) + { + return fn (); + } + + struct S x; + fn (); + fn2 (); + x = fn (); + + if (x.a[0] != 42) + __builtin_abort (); + + if (fn ().a[0] != 42) + __builtin_abort (); + + __typeof__ (fn ()) *p = &x; + if (p->a[0] != 42) + __builtin_abort (); + + if (fn2 ().a[0] != 42) + __builtin_abort (); +} + +int +main (void) +{ + foo (1); +} |