OSDN Git Service

gcc/cp/ChangeLog:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 May 2008 05:48:02 +0000 (05:48 +0000)
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 May 2008 05:48:02 +0000 (05:48 +0000)
PR c++/35909
* call.c (convert_like_real): Convert bitfield to desired type
before creating temporary.
gcc/testsuite/ChangeLog:
PR c++/35909
* g++.dg/conversion/bitfield9.C: New.

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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/bitfield9.C [new file with mode: 0644]

index 4b1c7db..3c54503 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-27  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR c++/35909
+       * call.c (convert_like_real): Convert bitfield to desired type
+       before creating temporary.
+
 2008-05-26  Daniel Franke  <franke.daniel@gmail.com>
 
        * Makefile.in: Adjusted dependencies on c-incpath.o.
index b83ad3a..fe78f9c 100644 (file)
@@ -4580,7 +4580,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
                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);
          }
 
index 8a5e58f..bf57f50 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-27  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR c++/35909
+       * g++.dg/conversion/bitfield9.C: New.
+
 2008-05-26  Arnaud Charlet  <charlet@adacore.com>
 
        * gnat.dg/specs/array_no_def_init.ads: New test.
diff --git a/gcc/testsuite/g++.dg/conversion/bitfield9.C b/gcc/testsuite/g++.dg/conversion/bitfield9.C
new file mode 100644 (file)
index 0000000..998dd48
--- /dev/null
@@ -0,0 +1,17 @@
+// 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);
+}
+