aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2008-02-10 18:12:01 +0000
committerJason Merrill <jason@redhat.com>2008-02-10 18:12:01 +0000
commit7cd07e8c41c0b38d7cf86ba89b112020f6769240 (patch)
tree72ca3c96995df6c26b09f40f3d259094de8e1de9
parent44c964e111cc620e1950b9ec98b09829ada21fdb (diff)
PR c++/34094
* decl2.c (cp_write_global_declarations): Don't write out static data members with DECL_IN_AGGR_P set. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@132218 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c4
-rw-r--r--gcc/testsuite/g++.dg/other/anon5.C21
3 files changed, 30 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index da9668da2ad..9dc4362acc3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index d2d81feae44..1832926eb31 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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
index 00000000000..68a02880b21
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/anon5.C
@@ -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;
+}
+