From 35728a80fc263329299d40fc81ed3dfffd164cf0 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 17 Nov 2000 10:24:05 +0000 Subject: [PATCH] pt.c (tsubst_expr, DECL_STMT): Instantiate decl's type. 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 | 4 ++ gcc/cp/pt.c | 3 ++ gcc/testsuite/ChangeLog | 4 ++ .../g++.old-deja/g++.pt/instantiate8.C | 40 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/instantiate8.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1cbeac8055a..63f97f42199 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2000-11-17 Nathan Sidwell + + * pt.c (tsubst_expr, DECL_STMT): Instantiate decl's type. + 2000-11-17 Nathan Sidwell * cp-tree.h (PARMLIST_ELLIPSIS_P): New macro. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index dd190ea4bbe..c281636286f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b6acd130c18..382b5196762 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-11-17 Nathan Sidwell + + * g++.old-deja/g++.pt/instantiate8.C: New test. + 2000-11-17 Nathan Sidwell * 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 index 00000000000..beffa02477f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate8.C @@ -0,0 +1,40 @@ +// Build don't link: +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 2000 + +// 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 +struct X +{ + X (int i=1); +}; + +void h () +{ + const X<2> z; + Z z1; // ERROR - incomplete +} + +template +void f() +{ + const X x; + const X y[3]; + Z z2; // ERROR - incomplete + typedef Z z3; // ok +}; + +template void f<3> ();