From: Kriang Lerdsuwanakij Date: Tue, 3 Jun 2003 13:01:44 +0000 (+0000) Subject: re PR c++/10940 (Bad code with explicit specialization) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6c07f44866d52ab85205439ee2319f24c8a596f5;p=gcc.git re PR c++/10940 (Bad code with explicit specialization) PR c++/10940 * pt.c (check_explicit_specialization): Check for 'static' earlier. * g++.dg/template/spec10.C: New test. From-SVN: r67373 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 85c5062451d..158db739a84 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-06-03 Kriang Lerdsuwanakij + + PR c++/10940 + * pt.c (check_explicit_specialization): Check for 'static' + earlier. + 2003-05-31 Diego Novillo * class.c (dump_array): Call CONSTRUCTOR_ELTS to access diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2e163c840a9..52bbc51990f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1849,6 +1849,18 @@ check_explicit_specialization (declarator, decl, template_count, flags) return instantiate_template (tmpl, targs, tf_error); } + /* If we thought that the DECL was a member function, but it + turns out to be specializing a static member function, + make DECL a static member function as well. We also have + to adjust last_function_parms to avoid confusing + start_function later. */ + if (DECL_STATIC_FUNCTION_P (tmpl) + && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)) + { + revert_static_member_fn (decl); + last_function_parms = TREE_CHAIN (last_function_parms); + } + /* If this is a specialization of a member template of a template class. In we want to return the TEMPLATE_DECL, not the specialization of it. */ @@ -1865,16 +1877,6 @@ check_explicit_specialization (declarator, decl, template_count, flags) return tmpl; } - /* If we thought that the DECL was a member function, but it - turns out to be specializing a static member function, - make DECL a static member function as well. */ - if (DECL_STATIC_FUNCTION_P (tmpl) - && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)) - { - revert_static_member_fn (decl); - last_function_parms = TREE_CHAIN (last_function_parms); - } - /* Set up the DECL_TEMPLATE_INFO for DECL. */ DECL_TEMPLATE_INFO (decl) = tree_cons (tmpl, targs, NULL_TREE); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a7da74f4c8c..a5602f2f4e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-06-03 Kriang Lerdsuwanakij + + PR c++/10940 + * g++.dg/template/spec10.C: New test. + 2003-06-03 Roger Sayle * gcc.dg/builtins-16.c: New test case. diff --git a/gcc/testsuite/g++.dg/template/spec10.C b/gcc/testsuite/g++.dg/template/spec10.C new file mode 100644 index 00000000000..f790155dce2 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec10.C @@ -0,0 +1,27 @@ +// { dg-do run } + +// Origin: Lynn Akers + +// PR c++/10940: Problem handling parameter list for static member +// that is a specialization of a member template of a template class. + +template +class o +{ +public: + template static void do_add(T* p, T v); +}; + +template<> +template +inline void o<32>::do_add(T* p, T v) +{ + *p += v; +} + +int main() +{ + int a = 0x1000; + o<32>().do_add(&a, 0x2000); + return a; +}