OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [opt/] [temp1.C] - Blame information for rev 149

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
// PR c++/16405
2
// { dg-options "-O2" }
3
// { dg-do run }
4
 
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.
12
 
13
int i;
14
 
15
extern "C"
16
void *memcpy (void *dest, const void *src, __SIZE_TYPE__ n)
17
{
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;
24
}
25
 
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; }
30
};
31
 
32
T &T::operator+=(T const &v) {
33
  return *this;
34
}
35
 
36
T a, b, c;
37
 
38
void f() { a = b + c; }
39
 
40
int main () {
41
  i = 0;
42
  f();
43
  if (i > 2)
44
    return 1;
45
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.