diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/g++.dg/opt/temp1.C | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/opt/temp1.C')
-rw-r--r-- | gcc-4.9/gcc/testsuite/g++.dg/opt/temp1.C | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/opt/temp1.C b/gcc-4.9/gcc/testsuite/g++.dg/opt/temp1.C new file mode 100644 index 000000000..dc13f5162 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/opt/temp1.C @@ -0,0 +1,50 @@ +// PR c++/16405 +// { dg-options "-O2" } +// { dg-do run } + +// There should be exactly one temporary generated for the code in "f" +// below when optimizing -- for the result of "b + c". We have no +// easy way of checking that directly, so we count the number of calls +// to "memcpy", which is used on (some?) targets to copy temporaries. +// If there is more than two calls (one for coping "*this" to "t", and +// one for copying the temporary to "a"), then there are too many +// temporaries. + +int i; + +extern "C" +void *memcpy (void *dest, const void *src, __SIZE_TYPE__ n) +{ + char *d = (char *) dest; + const char *s = (const char *) src; + while (n--) + d[n] = s[n]; + ++i; + return dest; +} + +struct T { +#ifdef __SPU__ + /* SPU returns aggregates up to 1172 bytes in registers. */ + int a[300]; +#else + int a[128]; +#endif + T &operator+=(T const &v) __attribute__((noinline)); + T operator+(T const &v) const { T t = *this; t += v; return t; } +}; + +T &T::operator+=(T const &v) { + return *this; +} + +T a, b, c; + +void f() { a = b + c; } + +int main () { + i = 0; + f(); + if (i > 2) + return 1; +} |