aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-02-07 11:32:28 -0500
committerJason Merrill <jason@gcc.gnu.org>2013-02-07 11:32:28 -0500
commit702f9fe53516f574c149d7638b977d84b2861e9b (patch)
tree3469086715ba20d9a8b5ecd53f08edb601653419
parent54353978a4ba9b8c4d7c5b721b2daaca1b1c8975 (diff)
downloadgcc-702f9fe53516f574c149d7638b977d84b2861e9b.zip
gcc-702f9fe53516f574c149d7638b977d84b2861e9b.tar.gz
gcc-702f9fe53516f574c149d7638b977d84b2861e9b.tar.bz2
re PR c++/56235 (Bogus "error: invalid conversion from ‘unsigned char’ to ‘B::Mode’ [-fpermissive]")
PR c++/56235 * method.c (do_build_copy_constructor): Don't bother turning scalars from lvalues to xvalues. (do_build_copy_assign): Likewise. From-SVN: r195854
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/method.c8
-rw-r--r--gcc/testsuite/g++.dg/init/bitfield4.C24
3 files changed, 37 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f60735d..9665be4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2013-02-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/56235
+ * method.c (do_build_copy_constructor): Don't bother turning
+ scalars from lvalues to xvalues.
+ (do_build_copy_assign): Likewise.
+
2013-02-06 Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_enum_specifier): Check for error_mark_node.
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index d13a0cf..a1bab95 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -610,7 +610,9 @@ do_build_copy_constructor (tree fndecl)
}
init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE);
- if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE)
+ if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE
+ /* 'move' breaks bit-fields, and has no effect for scalars. */
+ && !scalarish_type_p (expr_type))
init = move (init);
init = build_tree_list (NULL_TREE, init);
@@ -724,7 +726,9 @@ do_build_copy_assign (tree fndecl)
expr_type = cp_build_qualified_type (expr_type, quals);
init = build3 (COMPONENT_REF, expr_type, init, field, NULL_TREE);
- if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE)
+ if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE
+ /* 'move' breaks bit-fields, and has no effect for scalars. */
+ && !scalarish_type_p (expr_type))
init = move (init);
if (DECL_NAME (field))
diff --git a/gcc/testsuite/g++.dg/init/bitfield4.C b/gcc/testsuite/g++.dg/init/bitfield4.C
new file mode 100644
index 0000000..30041c4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/bitfield4.C
@@ -0,0 +1,24 @@
+// PR c++/56235
+
+struct A
+{
+ A (const A &);
+};
+
+struct B
+{
+ A a;
+ enum Mode { };
+ Mode m:8;
+};
+
+struct C
+{
+ C();
+ B b;
+};
+
+C fn()
+{
+ return C();
+}