aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2008-02-10 13:12:01 -0500
committerJason Merrill <jason@gcc.gnu.org>2008-02-10 13:12:01 -0500
commit6c5613b043641d7be059718d9037a6ff17ab94ac (patch)
tree72ca3c96995df6c26b09f40f3d259094de8e1de9
parentef4195d63d08c669014ec5330f1b4eacd9778736 (diff)
downloadgcc-6c5613b043641d7be059718d9037a6ff17ab94ac.zip
gcc-6c5613b043641d7be059718d9037a6ff17ab94ac.tar.gz
gcc-6c5613b043641d7be059718d9037a6ff17ab94ac.tar.bz2
re PR c++/34094 (Undefined static data member in anonymous namespace can acquire a definition anyway)
PR c++/34094 * decl2.c (cp_write_global_declarations): Don't write out static data members with DECL_IN_AGGR_P set. From-SVN: r132218
-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 da9668d..9dc4362 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 d2d81fe..1832926 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 0000000..68a02880
--- /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;
+}
+