diff options
author | Seongbae Park <seongbae.park@gmail.com> | 2007-03-20 15:42:37 +0000 |
---|---|---|
committer | Seongbae Park <spark@gcc.gnu.org> | 2007-03-20 15:42:37 +0000 |
commit | 77eb5950766876da857481b3dafc7ccd13b4b722 (patch) | |
tree | 95a82fc829b709d0982639ee3934d07aba52e89a | |
parent | caaf5345bbdad6db838640bc77ddc7a7aeb87df4 (diff) | |
download | gcc-77eb5950766876da857481b3dafc7ccd13b4b722.zip gcc-77eb5950766876da857481b3dafc7ccd13b4b722.tar.gz gcc-77eb5950766876da857481b3dafc7ccd13b4b722.tar.bz2 |
re PR tree-optimization/30590 (tree-nrv optimization clobbers return variable)
2007-03-19 Seongbae Park <seongbae.park@gmail.com>
PR tree-optimization/30590
* g++.dg/opt/pr30590.C: New testcase.
From-SVN: r123087
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/pr30590.C | 40 |
2 files changed, 45 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0e772e4..147dd30 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-03-19 Seongbae Park <seongbae.park@gmail.com> + + PR tree-optimization/30590 + * g++.dg/opt/pr30590.C: New testcase. + 2007-03-20 Jakub Jelinek <jakub@redhat.com> PR c/30762 diff --git a/gcc/testsuite/g++.dg/opt/pr30590.C b/gcc/testsuite/g++.dg/opt/pr30590.C new file mode 100644 index 0000000..42ae046 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr30590.C @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ +struct test +{ + int type; + char buffer[4242]; /* should trigger pass-by-reference */ +}; + +int flag = 0; + +struct test +reset (void) +{ + struct test retval; + retval.type = 1; + return retval; +} + +struct test +test (void) +{ + struct test result; + result.type = 0; + + for (int i = 0; i < 2; ++i) + { + struct test candidate = reset (); + if (flag) + result = candidate; + } + + return result; +} + +int +main (void) +{ + struct test result = test (); + return result.type; +} |