This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 24277


OK, I'm really starting to wish I'd never fixed that original static
data member bug...

This patch fixes a thinko; I had forgotten to call
finish_static_data_member_decl, which is the piece of code responsible
for converting from the type of the initializer to the type of the
variable.  Tested on x86_64-unknown-linux-gnu, applied on the mainline
and on the 4.0 branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-10-10  Mark Mitchell  <mark@codesourcery.com>

	PR c++/24277
	* pt.c (instantiate_decl): Call finish_static_data_member_decl for
	static data members.

2005-10-10  Mark Mitchell  <mark@codesourcery.com>

	PR c++/24277
	* g++.dg/template/static20.C: New test.

Index: gcc/cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.1042
diff -c -5 -p -r1.1042 pt.c
*** gcc/cp/pt.c	10 Oct 2005 14:42:13 -0000	1.1042
--- gcc/cp/pt.c	11 Oct 2005 06:15:53 -0000
*************** instantiate_decl (tree d, int defer_ok, 
*** 11556,11572 ****
  	 we must substitute the initializer.  */
        if (TREE_CODE (d) == VAR_DECL
  	  && !DECL_INITIAL (d) 
  	  && DECL_INITIAL (code_pattern))
  	{
! 	  tree 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);
  	  pop_nested_class ();
  	  pop_nested_namespace (ns);
  	}
  
        /* We restore the source position here because it's used by
--- 11556,11578 ----
  	 we must substitute the initializer.  */
        if (TREE_CODE (d) == VAR_DECL
  	  && !DECL_INITIAL (d) 
  	  && DECL_INITIAL (code_pattern))
  	{
! 	  tree ns;
! 	  tree init;
! 
! 	  ns = decl_namespace_context (d);
  	  push_nested_namespace (ns);
  	  push_nested_class (DECL_CONTEXT (d));
! 	  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);
  	}
  
        /* We restore the source position here because it's used by
Index: gcc/testsuite/g++.dg/template/static20.C
===================================================================
RCS file: gcc/testsuite/g++.dg/template/static20.C
diff -N gcc/testsuite/g++.dg/template/static20.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/g++.dg/template/static20.C	11 Oct 2005 06:18:10 -0000
***************
*** 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>();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]