re PR c++/14429 (valid template template argument rejected)

PR c++/14429
	* pt.c (coerce_template_template_parms) <PARM_DECL case>: Only check
	when the type of ARG is not dependent.

	* g++.dg/template/ttp11.C: New test.

From-SVN: r85222
This commit is contained in:
Kriang Lerdsuwanakij 2004-07-27 15:47:10 +00:00 committed by Kriang Lerdsuwanakij
parent 18d7916e39
commit 00bdb87f8e
5 changed files with 53 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2004-07-27 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/14429
* pt.c (coerce_template_template_parms) <PARM_DECL case>: Only check
when the type of ARG is not dependent.
2004-07-26 Geoffrey Keating <geoffk@apple.com>
* g++spec.c (LIBSTDCXX_PROFILE): Default to LIBSTDCXX.

View File

@ -3639,11 +3639,16 @@ coerce_template_template_parms (tree parm_parms,
case PARM_DECL:
/* The tsubst call is used to handle cases such as
template <class T, template <T> class TT> class D;
template <int> class C {};
template <class T, template <T> class TT> class D {};
D<int, C> d;
i.e. the parameter list of TT depends on earlier parameters. */
if (!same_type_p
(tsubst (TREE_TYPE (parm), outer_args, complain, in_decl),
TREE_TYPE (arg)))
if (!dependent_type_p (TREE_TYPE (arg))
&& !same_type_p
(tsubst (TREE_TYPE (parm), outer_args, complain, in_decl),
TREE_TYPE (arg)))
return 0;
break;

View File

@ -1,3 +1,8 @@
2004-07-27 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/14429
* g++.dg/template/ttp11.C: New test.
2004-07-27 Diego Novillo <dnovillo@redhat.com>
* gcc.c-torture/compile/20040727-1.c: New test.

View File

@ -0,0 +1,14 @@
// { dg-do compile }
// Origin: heinlein@informatik.uni-ulm.de
// PR c++/14429: Matching of template template parameter containing
// non-type parameter with type that depends on earlier parameter.
template <template <typename U, U* p> class T>
struct X {};
template <template <typename U, U* p> class T>
struct Y {
X<T> x;
};

View File

@ -0,0 +1,19 @@
// Copyright (C) 2004 Free Software Foundation
// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
// { dg-do compile }
// Check the type of non-type parameter in template template parameter
// only if it is dependent.
template <template <int* p> class T>
struct X {};
template <typename U, template <U* p> class T>
struct Y {
X<T> x;
};
template <int* p> struct Z {};
Y<int, Z> y1;
Y<char, Z> y2; // { dg-error "mismatch|expected|invalid" }