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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [optimize2.C] - Blame information for rev 305

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

Line No. Rev Author Line
1 305 jeremybenn
// { dg-do run  }
2
// { dg-options "-O2" }
3
//
4
// Copyright (C) 2001 Free Software Foundation, Inc.
5
// Contributed by Nathan Sidwell 26 May 2001 
6
 
7
// Bug 2823. Inlineing the body of a thunk broke things. But that's
8
// rarely a sensible thing to do anyway.
9
 
10
#include 
11
#include 
12
 
13
int objCount = 0;
14
 
15
struct Thing
16
{
17
  int count;
18
 
19
  Thing ();
20
  Thing (Thing const &src);
21
 
22
  ~Thing ();
23
 
24
};
25
 
26
Thing::Thing ()
27
  :count (0)
28
{
29
  objCount++;
30
  std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__);
31
}
32
 
33
Thing::Thing (Thing const &src)
34
  :count (0)
35
{
36
  objCount++;
37
  std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
38
}
39
 
40
Thing::~Thing ()
41
{
42
  std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
43
  if (count)
44
    std::abort ();
45
  count--;
46
  objCount--;
47
}
48
 
49
void x(Thing name)
50
{
51
  // destruct name here
52
}
53
 
54
class Base
55
{
56
  public:
57
  virtual void test(const Thing& s) = 0;
58
};
59
 
60
class Impl : virtual public Base
61
{
62
  public:
63
  virtual void test(const Thing& s)
64
  {
65
    x(s); // copy construct temporary
66
  }
67
};
68
 
69
int main()
70
{
71
  Impl *impl = new Impl();
72
 
73
  impl->test( Thing ());        // This will use a thunk
74
  return objCount != 0;
75
}

powered by: WebSVN 2.1.0

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