aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/nested-func-12.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/nested-func-12.c')
-rw-r--r--gcc/testsuite/gcc.dg/nested-func-12.c48
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);
+}