pt.c (tsubst_expr, DECL_STMT): Instantiate decl's type.
authorNathan Sidwell <nathan@codesourcery.com>
Fri, 17 Nov 2000 10:24:05 +0000 (10:24 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 17 Nov 2000 10:24:05 +0000 (10:24 +0000)
cp:
* pt.c (tsubst_expr, DECL_STMT): Instantiate decl's type.

testsuite:
* g++.old-deja/g++.pt/instantiate8.C: New test.

From-SVN: r37518

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.pt/instantiate8.C [new file with mode: 0644]

index 1cbeac8055a76c89264e06707979c89c4328f2ac..63f97f4219900c990ad91a8a2e8aebf31e1bd841 100644 (file)
@@ -1,3 +1,7 @@
+2000-11-17  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * pt.c (tsubst_expr, DECL_STMT): Instantiate decl's type.
+
 2000-11-17  Nathan Sidwell  <nathan@codesourcery.com>
 
        * cp-tree.h (PARMLIST_ELLIPSIS_P): New macro.
index dd190ea4bbe8f8627ba1e8f110b2c58abf3743c4..c281636286f51df78785b97faf6689102c0002c1 100644 (file)
@@ -7150,6 +7150,9 @@ tsubst_expr (t, args, complain, in_decl)
            init = tsubst_expr (init, args, complain, in_decl);
            if (decl != error_mark_node)
              {
+                if (TREE_CODE (decl) != TYPE_DECL)
+                  /* Make sure the type is instantiated now. */
+                  complete_type (type);
                if (init)
                  DECL_INITIAL (decl) = error_mark_node;
                /* By marking the declaration as instantiated, we avoid
index b6acd130c183c3c77e8eff7c22755a482aa6c3f3..382b5196762bb07044b0eb2eec9c4fe1da4ea16e 100644 (file)
@@ -1,3 +1,7 @@
+2000-11-17  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.pt/instantiate8.C: New test.
+
 2000-11-17  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.old-deja/g++.other/incomplete.C: Add more tests.
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate8.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate8.C
new file mode 100644 (file)
index 0000000..beffa02
--- /dev/null
@@ -0,0 +1,40 @@
+// Build don't link:
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com>
+
+// bug 616. We failed to complete the type of decls in templates, leading to
+// bogus errors.
+
+struct Z;
+struct Y
+{
+  Y (int i = 1);
+};
+void g ()
+{
+  const Y y;
+  Z z;          // ERROR - incomplete
+}
+
+template <int dim>
+struct X
+{
+  X (int i=1);
+};
+
+void h ()
+{
+  const X<2> z;
+  Z z1;         // ERROR - incomplete
+}
+
+template <int dim>
+void f()
+{
+  const X<dim> x;
+  const X<dim+1> y[3];
+  Z z2;           // ERROR - incomplete
+  typedef Z z3;   // ok
+};
+
+template void f<3> ();