Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/gcc.dg/nested-func-8.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/gcc.dg/nested-func-8.c Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,57 @@ +/* { dg-do run } */ +/* { dg-options "-O -fno-inline" } */ + +extern void abort (void); + +/* Return 0 and clobber the static chain. */ + +int +zero (int n) +{ + int + nested (int m) + { + return m - n; + } + + return nested (n); +} + +/* Return the triple of ARG in a convoluted manner. */ + +int +triple (int arg) +{ + int + read_arg (void) + { + return arg; + } + + int + parent (int nested_arg) + { + int + child1 (void) + { + return parent (zero (5)); + } + + int + child2 (void) + { + return nested_arg + read_arg (); + } + + return (nested_arg == 0 ? 0 : child1 ()) + child2 (); + } + + return parent (arg); +} + +int main(void) +{ + if (triple (13) != 3 * 13) + abort (); + return 0; +}