diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.old-deja/g++.mike/p646.C | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.mike/p646.C')
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.mike/p646.C | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p646.C b/gcc/testsuite/g++.old-deja/g++.mike/p646.C new file mode 100644 index 000000000..4f7807d11 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p646.C @@ -0,0 +1,163 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated -Wreturn-type" } +// GROUPS passed i960 +/* + Bug Id: bnr + PMRS Id: p0000646 + Bug is: Urgent Code Generation Problem in gcc-i960 V 1.95 +*/ + + + +extern "C" +{ + int printf (const char *, ...); + void abort (); +} + +struct foo +{ + static int si; + int i; + foo (); + foo (const foo&); + ~foo (); +}; + +int +foo_parm_returns_i (foo foo_arg) +{ + return foo_arg.i; +} + +int foo::si = 0; + +foo::foo () +{ + si++; + printf ("new foo @ 0x%x; now %d foos\n", this, si); +} + +foo::foo (const foo &other) +{ + si++; + printf ("another foo @ 0x%x; now %d foos\n", this, si); + *this = other; +} + +foo::~foo () +{ + si--; + printf ("deleted foo @ 0x%x; now %d foos\n", this, si); +} + +int +return_1 () +{ + foo f; + printf ("returning 1\n"); + return 1; +} + +int +return_arg (int arg) +{ + foo f; + printf ("returning %d\n", arg); + return arg; +} + +int +return_sum (int x, int y) +{ + foo f; + printf ("returning %d+%d\n", x, y); + return x + y; +} + +foo +return_foo () +{ + foo f; + printf ("returning foo\n"); + return f; +} + +foo +foo_parm_returns_foo (foo f) +{ + return f; +} + +void +abort_because (const char *str) +{ + printf ("aborting because %s\n", str); + abort (); +} + +int +warn_return_1 () +{ + foo f; + printf ("returning 1\n"); +} // { dg-warning "" } control reaches end + +int +warn_return_arg (int arg) +{ + foo f; + printf ("returning %d\n", arg); + arg; +} // { dg-warning "" } control reaches end + +int +warn_return_sum (int x, int y) +{ + foo f; + printf ("returning %d+%d\n", x, y); + x + y; +} // { dg-warning "" } control reaches end + +foo +warn_return_foo () +{ + foo f; + printf ("returning foo\n"); +} // { dg-warning "" } control reaches end + +foo +warn_foo_parm_returns_foo (foo f) +{ + f; +} // { dg-warning "" } control reaches end + +main () // { dg-warning "" } no type +{ + int ii = return_1 (); + if (ii != 1) + abort_because ("wrong value returned"); + int j = return_arg (42); + if (j != 42) + abort_because ("wrong value returned"); + int k = return_sum (-69, 69); + if (k != 0) + abort_because ("wrong value returned"); + foo f1 = return_foo (); + if (foo::si != 1) + abort_because ("wrong number of foos"); + f1.i = 5; + int l = foo_parm_returns_i (f1); + if (l != 5) + abort_because ("l != 5"); + foo f2 = foo_parm_returns_foo (f1); + if (foo::si != 2) + abort_because ("wrong number of foos"); + if (f2.i != 5) + abort_because ("f2.i != 5"); + foo f3 = return_foo (); + if (foo::si != 3) + abort_because ("wrong number of foos"); + printf("PASS\n"); + return 0; +} |