diff options
author | Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> | 2003-05-11 09:45:30 +0000 |
---|---|---|
committer | Kriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org> | 2003-05-11 09:45:30 +0000 |
commit | fcea74011f2d59f310379d393799c353b7c54293 (patch) | |
tree | fafd1d159294e40e041c9c430a0138c23d9ef377 /gcc | |
parent | cdc958d823386608ae27e2cda751711595dd838d (diff) | |
download | gcc-fcea74011f2d59f310379d393799c353b7c54293.zip gcc-fcea74011f2d59f310379d393799c353b7c54293.tar.gz gcc-fcea74011f2d59f310379d393799c353b7c54293.tar.bz2 |
re PR c++/10552 (Small sample using nested templates causes internal compiler error.)
PR c++/10552
* pt.c (tsubst_copy): Handle TEMPLATE_DECL that is a member class
template and has dependent context.
* g++.dg/template/ttp6.C: New test.
From-SVN: r66682
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/ttp6.C | 21 |
4 files changed, 54 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 77cfaac..9aa822b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-05-11 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/10552 + * pt.c (tsubst_copy): Handle TEMPLATE_DECL that is a member class + template and has dependent context. + 2003-05-10 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> * pt.c (instantiate_decl): Call push/pop_deferring_access_checks. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b4a9729..efc3774 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7294,7 +7294,29 @@ tsubst_copy (t, args, complain, in_decl) args, complain, in_decl); else if (is_member_template (t)) return tsubst (t, args, complain, in_decl); + else if (DECL_CLASS_SCOPE_P (t) + && uses_template_parms (DECL_CONTEXT (t))) + { + /* Template template argument like the following example need + special treatment: + + template <template <class> class TT> struct C {}; + template <class T> struct D { + template <class U> struct E {}; + C<E> c; // #1 + }; + D<int> d; // #2 + + We are processing the template argument `E' in #1 for + the template instantiation #2. Originally, `E' is a + TEMPLATE_DECL with `D<T>' as its DECL_CONTEXT. Now we + have to substitute this with one having context `D<int>'. */ + + tree context = tsubst (DECL_CONTEXT (t), args, complain, in_decl); + return lookup_field (context, DECL_NAME(t), 0, false); + } else + /* Ordinary template template argument. */ return t; case LOOKUP_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7493ddf..ade2507 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-05-11 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/10552 + * g++.dg/template/ttp6.C: New test. + 2003-05-11 Richard Sandiford <rsandifo@redhat.com> * gcc.c-torture/execute/builtins: New directory. diff --git a/gcc/testsuite/g++.dg/template/ttp6.C b/gcc/testsuite/g++.dg/template/ttp6.C new file mode 100644 index 0000000..a4c6ab0 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ttp6.C @@ -0,0 +1,21 @@ +// { dg-do compile } + +// Origin: Eelis van der Weegen <gccbugs@contacts.eelis.net> + +// PR c++/10552: Member class template as template template argument +// substitution issue. + +template <template <typename> class A, typename> +struct B +{ + typedef typename A<int>::t t; +}; + +template <typename D> +struct E +{ + template <typename> struct F { typedef int t; }; + typedef typename B<F, D>::t t; +}; + +typedef E<int>::t t; |