summaryrefslogtreecommitdiff
path: root/libvtv/testsuite/libvtv.cc/dup_name.cc
blob: d9d02512630da10ea6e7ca14dd8df691c367ca0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// { dg-do run }

#include <assert.h>

extern "C" int printf(const char *, ...);

class Subscriptor
{
  public:

  Subscriptor()
    { counter = 1;}

  virtual ~Subscriptor()
  {
    counter--;
    assert(counter == 0);
  }

  private:
    static int counter;
};

int Subscriptor::counter;

template <typename number>
class Polynomial : public Subscriptor
{
};

class LagrangeEquidistant: public Polynomial<double>
{
};

template <int value>
class A
{
 public:
  class Nested: public LagrangeEquidistant
  {
  };
  A() { n = new Nested; }
  ~A() { delete n; }
  Subscriptor * n;
};

template<typename _Tp>
inline void
_MyDestroy(_Tp* __pointer)
  { __pointer->~_Tp(); }

int main()
{
  Subscriptor * s1 =  new  LagrangeEquidistant;
  _MyDestroy(s1);
  A<1> * a1 = new A<1>;
  _MyDestroy(a1);
  A<2> * a2 = new A<2>;
  _MyDestroy(a2);

  return 0;
}