diff options
| -rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/cp/pt.c | 5 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/template/spec9.C | 21 |
4 files changed, 35 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3071e2b..33ae807 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-05-31 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/10956 + * pt.c (instantiate_decl): Don't use full template arguments if + we are dealing with specializations. + 2003-05-29 Gabriel Dos Reis <gdr@integrable-solutions.net> * decl.c (ENABLE_SCOPE_CHECKING): Rename from DEBUG_BINDING_LEVELS. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f775346..2e163c8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10862,10 +10862,11 @@ instantiate_decl (d, defer_ok) td = template_for_substitution (d); code_pattern = DECL_TEMPLATE_RESULT (td); - if (DECL_NAMESPACE_SCOPE_P (d) && !DECL_INITIALIZED_IN_CLASS_P (d)) + if ((DECL_NAMESPACE_SCOPE_P (d) && !DECL_INITIALIZED_IN_CLASS_P (d)) + || DECL_TEMPLATE_SPECIALIZATION (td)) /* In the case of a friend template whose definition is provided outside the class, we may have too many arguments. Drop the - ones we don't need. */ + ones we don't need. The same is true for specializations. */ args = get_innermost_template_args (gen_args, TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (td))); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e61b148..628551e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-05-31 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/10956 + * g++.dg/template/spec9.C: New test. + 2003-05-29 Roger Sayle <roger@eyesopen.com> * gcc.dg/duff-4.c: New test case. diff --git a/gcc/testsuite/g++.dg/template/spec9.C b/gcc/testsuite/g++.dg/template/spec9.C new file mode 100644 index 0000000..013fa0d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec9.C @@ -0,0 +1,21 @@ +// { dg-do compile } + +// Origin: Lynn Akers <lakers@peachtree.com> +// Wolfgang Bangerth <bangerth@ticam.utexas.edu> + +// PR c++/10956: Incorrect template substitution for member template +// specialization inside template class. + +template <int> struct C { + template<typename T> void pre_add(T); +}; + +template<> +template<typename T> +void C<32>::pre_add(T) { + T pre; +} + +int main() { + C<32>().pre_add<int>(1); +} |
