re PR c++/31513 (Miscompilation of Function Passing Bit Field Value to Function)

PR c++/31513
	* call.c (convert_for_arg_passing): Convert bitfields to their
	declared types.

	PR c++/31513
	* g++.dg/expr/bitfield8.C: New test.

From-SVN: r123939
This commit is contained in:
Mark Mitchell 2007-04-18 03:36:18 +00:00 committed by Mark Mitchell
parent 50f324bbbe
commit 431ed7a131
4 changed files with 36 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2007-04-17 Mark Mitchell <mark@codesourcery.com>
PR c++/31513
* call.c (convert_for_arg_passing): Convert bitfields to their
declared types.
2007-04-17 Simon Martin <simartin@users.sourceforge.net>
PR c++/31517

View File

@ -4713,6 +4713,7 @@ type_passed_as (tree type)
tree
convert_for_arg_passing (tree type, tree val)
{
val = convert_bitfield_to_declared_type (val);
if (val == error_mark_node)
;
/* Pass classes with copy ctors by invisible reference. */

View File

@ -1,3 +1,8 @@
2007-04-17 Mark Mitchell <mark@codesourcery.com>
PR c++/31513
* g++.dg/expr/bitfield8.C: New test.
2007-04-17 Joseph Myers <joseph@codesourcery.com>
Richard Sandiford <richard@codesourcery.com>

View File

@ -0,0 +1,24 @@
// PR c++/31513
// { dg-do run }
extern "C" void abort();
struct tree_type {
unsigned int precision : 9;
};
void bork(unsigned int i) {
if (i != 7)
abort();
}
void foo(struct tree_type *t)
{
bork(t->precision);
}
int main() {
tree_type t;
t.precision = 7;
foo(&t);
}