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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [opt/] [temp2.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do run }
2
 
3
// Copyright (C) 2006 Free Software Foundation, Inc.
4
 
5
// Originally from PR 16681, found also in init/array15.C
6
// This variant of the testcase verifies that we do not create
7
// a temporary on the stack, which is PR 27620.
8
 
9
int i;
10
 
11
extern "C"
12
void *memcpy (void *dest, const void *src, __SIZE_TYPE__ n)
13
{
14
  char *d = (char *) dest;
15
  const char *s = (const char *) src;
16
  while (n--)
17
    d[n] = s[n];
18
  ++i;
19
  return dest;
20
}
21
 
22
struct foo {
23
  unsigned char buffer[41112];
24
  foo() ;
25
  bool check () const;
26
};
27
 
28
foo::foo ()
29
  : buffer()
30
{}
31
 
32
bool foo::check () const
33
{
34
  for (unsigned ix = sizeof (buffer); ix--;)
35
    if (buffer[ix])
36
      return false;
37
  return true;
38
}
39
 
40
void *operator new (__SIZE_TYPE__ size, void *p)
41
{
42
  return p;
43
}
44
 
45
char heap[50000];
46
 
47
int main ()
48
{
49
  for (unsigned ix = sizeof (heap); ix--;)
50
    heap[ix] = ix;
51
 
52
  i = 0;
53
  foo *f = new (heap) foo ();
54
 
55
  if (i != 0)
56
    return 1;
57
  if (!f->check ())
58
    return 1;
59
  return 0;
60
}
61
 
62
 

powered by: WebSVN 2.1.0

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