Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / g++.dg / opt / temp1.C
blobb822dc464fe19ebdbbd5148b4fe6ce421919b694
1 // PR c++/16405
2 // { dg-options "-O2" } 
3 // { dg-do run }
5 // There should be exactly one temporary generated for the code in "f"
6 // below when optimizing -- for the result of "b + c".  We have no
7 // easy way of checking that directly, so we count the number of calls
8 // to "memcpy", which is used on (some?) targets to copy temporaries.
9 // If there is more than two calls (one for coping "*this" to "t", and
10 // one for copying the temporary to "a"), then there are too many
11 // temporaries. 
13 int i;
15 extern "C"
16 void *memcpy (void *dest, const void *src, __SIZE_TYPE__ n)
18   char *d = (char *) dest;
19   const char *s = (const char *) src;
20   while (n--)
21     d[n] = s[n];
22   ++i;
23   return dest;
26 struct T {
27   int a[128];
28   T &operator+=(T const &v) __attribute__((noinline));
29   T operator+(T const &v) const { T t = *this; t += v; return t; }
32 T &T::operator+=(T const &v) {
33   return *this;
36 T a, b, c;
38 void f() { a = b + c; }
40 int main () {
41   i = 0;
42   f();
43   if (i > 2)
44     return 1;