diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-27 05:48:02 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-27 05:48:02 +0000 |
commit | 8e4fb8d24fe56e58f1cf08a38b4f69b754d3d852 (patch) | |
tree | 3984c0b7cc29a396df3b6c7be3025ff0ca606abd | |
parent | a61124669c81cc50a4f2c135390a1c7d293af23a (diff) | |
download | gcc-8e4fb8d24fe56e58f1cf08a38b4f69b754d3d852.tar.gz |
gcc/cp/ChangeLog:
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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/conversion/bitfield9.C | 17 |
4 files changed, 32 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4b1c7dbc32c..3c54503608b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b83ad3a2eef..fe78f9cdf29 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8a5e58fd969..bf57f50ddd3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 00000000000..998dd4873c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/bitfield9.C @@ -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); +} + |