PR c++/10956
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 31 May 2003 12:13:30 +0000 (12:13 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 31 May 2003 12:13:30 +0000 (12:13 +0000)
* pt.c (instantiate_decl): Don't use full template arguments if
we are dealing with specializations.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@67268 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/spec9.C [new file with mode: 0644]

index 3071e2b..33ae807 100644 (file)
@@ -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.
index f775346..2e163c8 100644 (file)
@@ -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
index e61b148..628551e 100644 (file)
@@ -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 (file)
index 0000000..013fa0d
--- /dev/null
@@ -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);
+}