Commit 6c07f448 by Kriang Lerdsuwanakij Committed by Kriang Lerdsuwanakij

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
parent 075ec276
2003-06-03 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/10940
* pt.c (check_explicit_specialization): Check for 'static'
earlier.
2003-05-31 Diego Novillo <dnovillo@redhat.com>
* class.c (dump_array): Call CONSTRUCTOR_ELTS to access
......
......@@ -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);
......
2003-06-03 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/10940
* g++.dg/template/spec10.C: New test.
2003-06-03 Roger Sayle <roger@eyesopen.com>
* gcc.dg/builtins-16.c: New test case.
......
// { dg-do run }
// Origin: Lynn Akers <lakers@peachtree.com>
// PR c++/10940: Problem handling parameter list for static member
// that is a specialization of a member template of a template class.
template<int b>
class o
{
public:
template<typename T> static void do_add(T* p, T v);
};
template<>
template<typename T>
inline void o<32>::do_add(T* p, T v)
{
*p += v;
}
int main()
{
int a = 0x1000;
o<32>().do_add<int>(&a, 0x2000);
return a;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment