semantics.c (setup_vtbl_ptr): Always build a CTOR_INITIALIZER if we're in a template.
authorJason Merrill <jason@gcc.gnu.org>
Fri, 18 Jan 2002 13:25:27 +0000 (08:25 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 18 Jan 2002 13:25:27 +0000 (08:25 -0500)
        * semantics.c (setup_vtbl_ptr): Always build a CTOR_INITIALIZER
        if we're in a template.

From-SVN: r48985

gcc/testsuite/g++.dg/template/vtable1.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/template/vtable1.C b/gcc/testsuite/g++.dg/template/vtable1.C
new file mode 100644 (file)
index 0000000..c5f122a
--- /dev/null
@@ -0,0 +1,23 @@
+// Test that vtables are set up properly for constructors and destructors
+// of template classes.
+
+// { dg-do run }
+
+int r;
+
+template <class T>
+struct A {
+  virtual void f () { }
+  A() { f (); }
+  ~A() { f (); }
+};
+
+struct B : public A<int> {
+  virtual void f () { ++r; }
+};
+
+int main ()
+{
+  { B b; }
+  return r;
+}