re PR c++/24277 (Boost causes ICE in build_c_cast, at cp/typeck.c:5231)

PR c++/24277
	* pt.c (instantiate_decl): Call finish_static_data_member_decl for
	static data members.
	PR c++/24277
	* g++.dg/template/static20.C: New test.

From-SVN: r105228
This commit is contained in:
Mark Mitchell 2005-10-11 06:26:04 +00:00 committed by Mark Mitchell
parent eb2182e299
commit 4bff36d306
3 changed files with 28 additions and 5 deletions

View File

@ -11558,13 +11558,19 @@ instantiate_decl (tree d, int defer_ok,
&& !DECL_INITIAL (d)
&& DECL_INITIAL (code_pattern))
{
tree ns = decl_namespace_context (d);
tree ns;
tree init;
ns = decl_namespace_context (d);
push_nested_namespace (ns);
push_nested_class (DECL_CONTEXT (d));
DECL_INITIAL (d)
= tsubst_expr (DECL_INITIAL (code_pattern),
args,
tf_error | tf_warning, NULL_TREE);
init = tsubst_expr (DECL_INITIAL (code_pattern),
args,
tf_error | tf_warning, NULL_TREE);
DECL_INITIAL (d) = NULL_TREE;
finish_static_data_member_decl (d, init,
/*asmspec_tree=*/NULL_TREE,
LOOKUP_ONLYCONVERTING);
pop_nested_class ();
pop_nested_namespace (ns);
}

View File

@ -1,5 +1,8 @@
2005-10-10 Mark Mitchell <mark@codesourcery.com>
PR c++/24277
* g++.dg/template/static20.C: New test.
PR c++/24302
* g++.dg/warn/Wunused-12.C: New test.

View File

@ -0,0 +1,14 @@
// PR c++/24277
template< int Bits > struct uint_t {
typedef unsigned short fast;
};
template < int Bits > struct mask_uint_t {
typedef typename uint_t< Bits >::fast fast;
static const fast sig_bits = 1;
static const fast sig_bits_fast = fast(sig_bits);
};
template < int Bits> int checksum ( ) {
return 1 & mask_uint_t<Bits>::sig_bits_fast;
}
int i = checksum<1>();