From bced83044966b9fdeef85a5207b94170bd83b2ba Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Tue, 27 May 2008 05:48:02 +0000 Subject: [PATCH] re PR c++/35909 (ICE with bit-field and const references) 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. From-SVN: r135969 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/call.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/conversion/bitfield9.C | 17 +++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/conversion/bitfield9.C 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 + + PR c++/35909 + * call.c (convert_like_real): Convert bitfield to desired type + before creating temporary. + 2008-05-26 Daniel Franke * 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 + + PR c++/35909 + * g++.dg/conversion/bitfield9.C: New. + 2008-05-26 Arnaud Charlet * 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); +} + -- 2.30.2