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 for c++/34094 (static data members in anon namespace)


We shouldn't be considering static data members with DECL_IN_AGGR_P set for writing out at end of file; that's how we indicate whether or not they have been defined outside the class.

Tested x86_64-pc-linux-gnu, applied to trunk.
2008-02-10  Jason Merrill  <jason@redhat.com>

	PR c++/34094
	* decl2.c (cp_write_global_declarations): Don't write out static 
	data members with DECL_IN_AGGR_P set.

Index: cp/decl2.c
===================================================================
*** cp/decl2.c	(revision 132216)
--- cp/decl2.c	(working copy)
*************** cp_write_global_declarations (void)
*** 3396,3402 ****
        /* Static data members are just like namespace-scope globals.  */
        for (i = 0; VEC_iterate (tree, pending_statics, i, decl); ++i)
  	{
! 	  if (var_finalized_p (decl) || DECL_REALLY_EXTERN (decl))
  	    continue;
  	  import_export_decl (decl);
  	  /* If this static data member is needed, provide it to the
--- 3396,3404 ----
        /* Static data members are just like namespace-scope globals.  */
        for (i = 0; VEC_iterate (tree, pending_statics, i, decl); ++i)
  	{
! 	  if (var_finalized_p (decl) || DECL_REALLY_EXTERN (decl)
! 	      /* Don't write it out if we haven't seen a definition.  */
! 	      || DECL_IN_AGGR_P (decl))
  	    continue;
  	  import_export_decl (decl);
  	  /* If this static data member is needed, provide it to the
Index: testsuite/g++.dg/other/anon5.C
===================================================================
*** testsuite/g++.dg/other/anon5.C	(revision 0)
--- testsuite/g++.dg/other/anon5.C	(revision 0)
***************
*** 0 ****
--- 1,21 ----
+ // PR c++/34094
+ // { dg-do link }
+ // { dg-options "-g" }
+ 
+ namespace {
+   struct c
+   {
+     static const bool t = 0;
+   };
+ }
+ 
+ const bool &f()
+ {
+   return c::t;			// { dg-error "undefined" }
+ }
+ 
+ int main(void)
+ {
+   return 0;
+ }
+ 

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