From: Jason Merrill Date: Tue, 12 Feb 2008 06:37:34 +0000 (-0500) Subject: re PR c++/34094 (Undefined static data member in anonymous namespace can acquire... X-Git-Tag: prereleases/gcc-4.2.4-rc1~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d700d4de87ba63a7e1f837146c011bc601112784;p=thirdparty%2Fgcc.git 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. PR c++/33916 * Revert: 2006-10-17 Mark Mitchell PR c++/29039 * typeck2.c (build_functional_cast): Don't zero-initialize non-PODs; instead, call their constructors. From-SVN: r132254 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 408126bea378..8069b3f5d594 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,16 @@ +2008-02-12 Jason Merrill + + PR c++/34094 + * decl2.c (cp_write_global_declarations): Don't write out static + data members with DECL_IN_AGGR_P set. + + PR c++/33916 + * Revert: + 2006-10-17 Mark Mitchell + PR c++/29039 + * typeck2.c (build_functional_cast): Don't zero-initialize + non-PODs; instead, call their constructors. + 2008-02-05 Richard Guenther Backport from mainline: diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 131e2dcf7514..0f1841f52c2b 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3280,7 +3280,9 @@ cp_finish_file (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/cp/typeck2.c b/gcc/cp/typeck2.c index 9dcb47c80cc3..9ab0c65e88bd 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1342,9 +1342,9 @@ build_functional_cast (tree exp, tree parms) if (parms && TREE_CHAIN (parms) == NULL_TREE) return build_c_cast (type, TREE_VALUE (parms)); - /* We need to zero-initialize POD types. */ - if (parms == NULL_TREE - && !CLASSTYPE_NON_POD_P (type) + /* We need to zero-initialize POD types. Let's do that for everything + that doesn't need a constructor. */ + if (parms == NULL_TREE && !TYPE_NEEDS_CONSTRUCTING (type) && TYPE_HAS_DEFAULT_CONSTRUCTOR (type)) { exp = build_zero_init (type, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5a3e80602a15..800296931150 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-02-12 Jason Merrill + + * g++.dg/init/ctor8.C: Remove. + 2008-02-06 John David Anglin * g++.dg/tree-ssa/ivopts-1.C: Remove xfails for hppa*-*-*. diff --git a/gcc/testsuite/g++.dg/init/ctor8.C b/gcc/testsuite/g++.dg/init/ctor8.C deleted file mode 100644 index 9723892f91ca..000000000000 --- a/gcc/testsuite/g++.dg/init/ctor8.C +++ /dev/null @@ -1,11 +0,0 @@ -// PR c++/29039 - -typedef struct S { // { dg-error "reference" } - int &r; -}; - -S f () { - return S (); // { dg-error "synthesized" } -} - -