PR c++/29039
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 Oct 2006 22:35:29 +0000 (22:35 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 Oct 2006 22:35:29 +0000 (22:35 +0000)
* typeck2.c (build_functional_cast): Don't zero-initialize
non-PODs; instead, call their constructors.
* method.c (synthesize_method): Always build mem-initializers, if
we're synthesizing the default constructor.
PR c++/29039
* g++.dg/init/ctor8.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117834 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/ctor8.C [new file with mode: 0644]

index 4728586..b759ba4 100644 (file)
@@ -1,5 +1,13 @@
 2006-10-17  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/29039
+       * typeck2.c (build_functional_cast): Don't zero-initialize
+       non-PODs; instead, call their constructors.
+       * method.c (synthesize_method): Always build mem-initializers, if
+       we're synthesizing the default constructor.
+
+2006-10-17  Mark Mitchell  <mark@codesourcery.com>
+
        PR c++/27270
        * decl.c (reshape_init_class): Move check for designated
        to ...
index e2106ff..ded0af0 100644 (file)
@@ -784,7 +784,7 @@ synthesize_method (tree fndecl)
       tree arg_chain = FUNCTION_FIRST_USER_PARMTYPE (fndecl);
       if (arg_chain != void_list_node)
        do_build_copy_constructor (fndecl);
-      else if (TYPE_NEEDS_CONSTRUCTING (current_class_type))
+      else
        finish_mem_initializers (NULL_TREE);
     }
 
index 725c85f..12987cf 100644 (file)
@@ -1333,9 +1333,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.  Let's do that for everything
-     that doesn't need a constructor.  */
-  if (parms == NULL_TREE && !TYPE_NEEDS_CONSTRUCTING (type)
+  /* We need to zero-initialize POD types.  */
+  if (parms == NULL_TREE 
+      && !CLASSTYPE_NON_POD_P (type)
       && TYPE_HAS_DEFAULT_CONSTRUCTOR (type))
     {
       exp = build_constructor (type, NULL);
index 4fed928..57ec350 100644 (file)
@@ -1,5 +1,10 @@
 2006-10-17  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/29039
+       * g++.dg/init/ctor8.C: New test.
+       
+2006-10-17  Mark Mitchell  <mark@codesourcery.com>
+
        PR c++/27270
        * g++.dg/ext/complit8.C: Tweak error markers.
        * g++.dg/template/complit1.C: Add error marker.
diff --git a/gcc/testsuite/g++.dg/init/ctor8.C b/gcc/testsuite/g++.dg/init/ctor8.C
new file mode 100644 (file)
index 0000000..9723892
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/29039
+
+typedef struct S { // { dg-error "reference" }
+  int &r; 
+};
+
+S f () {
+  return S (); // { dg-error "synthesized" }
+}
+
+