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
This commit is contained in:
Jason Merrill 2008-02-10 13:12:01 -05:00 committed by Jason Merrill
parent ef4195d63d
commit 6c5613b043
3 changed files with 30 additions and 1 deletions

View 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

View 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

View File

@ -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;
}