From 24eb59165f7cc002fa79fd28f54d3840584354f6 Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 10 Feb 2008 18:12:01 +0000 Subject: [PATCH] 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: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132218 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl2.c | 4 +++- gcc/testsuite/g++.dg/other/anon5.C | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/other/anon5.C 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 + + 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 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; +} + -- 2.11.0