OSDN Git Service

cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Nov 2000 10:24:05 +0000 (10:24 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Nov 2000 10:24:05 +0000 (10:24 +0000)
* 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

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 1cbeac8..63f97f4 100644 (file)
@@ -1,5 +1,9 @@
 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
index dd190ea..c281636 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 b6acd13..382b519 100644 (file)
@@ -1,5 +1,9 @@
 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.
 
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> ();