aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc')
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc62
1 files changed, 62 insertions, 0 deletions
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc
new file mode 100644
index 000000000..d9d025126
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc
@@ -0,0 +1,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;
+}