OSDN Git Service

PR c++/34094
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 10 Feb 2008 18:12:01 +0000 (18:12 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 10 Feb 2008 18:12:01 +0000 (18:12 +0000)
        * decl2.c (cp_write_global_declarations): Don't write out static
        data members with DECL_IN_AGGR_P set.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132218 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/g++.dg/other/anon5.C [new file with mode: 0644]

index da9668d..9dc4362 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2008-02-08  Jason Merrill  <jason@redhat.com>
 
        PR c++/35116
index d2d81fe..1832926 100644 (file)
@@ -3396,7 +3396,9 @@ cp_write_global_declarations (void)
       /* 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))
+         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
diff --git a/gcc/testsuite/g++.dg/other/anon5.C b/gcc/testsuite/g++.dg/other/anon5.C
new file mode 100644 (file)
index 0000000..68a0288
--- /dev/null
@@ -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;
+}
+