OSDN Git Service

PR c++/34180
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 6 Nov 2009 04:32:13 +0000 (04:32 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 6 Nov 2009 04:32:13 +0000 (04:32 +0000)
* method.c (do_build_copy_constructor): Don't drop cv-quals from
the field type.

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

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

index 98cca71..e909ba2 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 f13d99d..47f9e42 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 6d1786a..2aba607 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" }
+}