]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/34180 (Default copy constructor copies const auto_ptr members)
authorJason Merrill <jason@redhat.com>
Fri, 6 Nov 2009 04:32:13 +0000 (23:32 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 6 Nov 2009 04:32:13 +0000 (23:32 -0500)
PR c++/34180
* method.c (do_build_copy_constructor): Don't drop cv-quals from
the field type.

From-SVN: r153960

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

index 98cca71b56c09b151df5c0783ea7ae2371db7989..e909ba22396af1aee6ec8e2ed6c38485c7abe961 100644 (file)
@@ -1,5 +1,9 @@
 2009-11-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/34180
+       * method.c (do_build_copy_constructor): Don't drop cv-quals from
+       the field type.
+
        PR c++/7046
        * class.c (finish_struct): Store maximum_field_alignment in
        TYPE_PRECISION.
index f13d99df20f7c8039e77d52ff1463bc43585cb8d..47f9e424dbde36d22d6632ca91e8d2b10395c705 100644 (file)
@@ -622,6 +622,7 @@ do_build_copy_constructor (tree fndecl)
 
              if (DECL_MUTABLE_P (field))
                quals &= ~TYPE_QUAL_CONST;
+             quals |= TYPE_QUALS (expr_type);
              expr_type = cp_build_qualified_type (expr_type, quals);
            }
 
index 6d1786aa17b299fe3ad59d9bd750af30d09d6eff..2aba6077d226e053a0c191d1a96348c56ccb12b2 100644 (file)
@@ -1,5 +1,8 @@
 2009-11-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/34180
+       * g++.dg/init/synth2.C: New.
+
        PR c++/7046
        * g++.dg/abi/pragma-pack1.C: New.
 
diff --git a/gcc/testsuite/g++.dg/init/synth2.C b/gcc/testsuite/g++.dg/init/synth2.C
new file mode 100644 (file)
index 0000000..795ce42
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/34180
+
+struct G {
+  G();                         // { dg-message "" "candidate" }
+  G(G&);                       // { dg-message "" "candidate" }
+};
+
+class A
+{                              // { dg-error "no match" }
+  const G g;
+};
+
+int main()
+{
+  A a;
+  A b = a;                     // { dg-message "required here" }
+}
This page took 0.070867 seconds and 5 git commands to generate.