[C++ PATCH] Fix finish_static_data_member_decl (PR c++/28370)

Jakub Jelinek jakub@redhat.com
Thu Jul 13 21:33:00 GMT 2006


Hi!

Even for !TREE_PUBLIC (decl) static data member decls we want them to be
added to pending_statics vector, which ensures they will be emitted.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2006-07-13  Jakub Jelinek  <jakub@redhat.com>

	PR c++/28370
	* decl2.c (finish_static_data_member_decl): Call note_vague_linkage_var
	even for non-public decls.

	* g++.dg/template/anon3.C: New test.

--- gcc/cp/decl2.c.jj	2006-07-11 11:21:20.000000000 +0200
+++ gcc/cp/decl2.c	2006-07-13 18:39:59.000000000 +0200
@@ -761,7 +761,7 @@ finish_static_data_member_decl (tree dec
   if (!asmspec_tree && current_class_type)
     DECL_INITIAL (decl) = error_mark_node;
 
-  if (! processing_template_decl && TREE_PUBLIC (decl))
+  if (! processing_template_decl)
     note_vague_linkage_var (decl);
 
   if (LOCAL_CLASS_P (current_class_type))
--- gcc/testsuite/g++.dg/template/anon3.C.jj	2006-07-13 15:36:40.709347500 +0200
+++ gcc/testsuite/g++.dg/template/anon3.C	2006-07-13 18:47:58.000000000 +0200
@@ -0,0 +1,20 @@
+// PR c++/28370
+// { dg-do run }
+
+namespace
+{
+  template<typename T> struct A { static int *a; };
+  template<typename T> int *A<T>::a = 0;
+}
+
+int *
+foo ()
+{
+  return A<int>::a;
+}
+
+int
+main ()
+{
+  return foo() != 0;
+}

	Jakub



More information about the Gcc-patches mailing list