* pt.c (tsubst_expr, DECL_STMT): Instantiate decl's type.
testsuite:
* g++.old-deja/g++.pt/instantiate8.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37518
138bc75d-0d04-0410-961f-
82ee72b054a4
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.
* decl.c (grokdeclarator): Don't reject void parms here.
(require_complete_types_for_parms): Simplify, use
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
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.
* g++.old-deja/g++.pt/crash9.C: Mark new expected error.
--- /dev/null
+// 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> ();