42 lines
1.1 KiB
Diff
42 lines
1.1 KiB
Diff
2008-04-24 Alexandre Oliva <aoliva@redhat.com>
|
|
|
|
PR c++/35909
|
|
* call.c (convert_like_real): Convert bitfield to desired type
|
|
before creating temporary.
|
|
|
|
* g++.dg/conversion/bitfield9.C: New.
|
|
|
|
--- gcc/cp/call.c.orig 2008-04-22 03:26:25.000000000 -0300
|
|
+++ gcc/cp/call.c 2008-04-22 03:26:27.000000000 -0300
|
|
@@ -4580,7 +4580,10 @@ convert_like_real (conversion *convs, tr
|
|
return error_mark_node;
|
|
}
|
|
if (lvalue & clk_bitfield)
|
|
- expr = convert_bitfield_to_declared_type (expr);
|
|
+ {
|
|
+ expr = convert_bitfield_to_declared_type (expr);
|
|
+ expr = fold_convert (type, expr);
|
|
+ }
|
|
expr = build_target_expr_with_type (expr, type);
|
|
}
|
|
|
|
--- gcc/testsuite/g++.dg/conversion/bitfield9.C 1970-01-01 00:00:00.000000000 +0000
|
|
+++ gcc/testsuite/g++.dg/conversion/bitfield9.C 2008-04-22 03:26:27.000000000 -0300
|
|
@@ -0,0 +1,16 @@
|
|
+// PR c++/35909
|
|
+// { dg-do compile }
|
|
+
|
|
+struct MidiCommand
|
|
+{
|
|
+ unsigned data1 : 8;
|
|
+};
|
|
+
|
|
+void g(const unsigned char &);
|
|
+void h(const unsigned int &);
|
|
+
|
|
+void f(MidiCommand mc)
|
|
+{
|
|
+ g(mc.data1);
|
|
+ h(mc.data1);
|
|
+}
|