From 7f6851f9e44e25a3ddb77bf09b6e138a9c39bbf0 Mon Sep 17 00:00:00 2001 From: jakub Date: Sun, 22 May 2011 19:02:59 +0000 Subject: [PATCH] PR middle-end/49029 * expmed.c (extract_fixed_bit_field): Test whether target can be used only after deciding which mode to use. * gcc.c-torture/compile/pr49029.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174036 138bc75d-0d04-0410-961f-82ee72b054a4 index 6c35f8e..0d44b2b 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -1875,8 +1875,6 @@ extract_fixed_bit_field (enum machine_mode tmode, rtx op0, /* To extract a signed bit-field, first shift its msb to the msb of the word, then arithmetic-shift its lsb to the lsb of the word. */ op0 = force_reg (mode, op0); - if (mode != tmode) - target = 0; /* Find the narrowest integer mode that contains the field. */ @@ -1888,6 +1886,9 @@ extract_fixed_bit_field (enum machine_mode tmode, rtx op0, break; } + if (mode != tmode) + target = 0; + if (GET_MODE_BITSIZE (mode) != (bitsize + bitpos)) { tree amount new file mode 100644 index 0000000..ebe81b3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr49029.c @@ -0,0 +1,10 @@ +/* PR middle-end/49029 */ +struct S { volatile unsigned f : 11; signed g : 30; } __attribute__((packed)); +struct T { volatile struct S h; } __attribute__((packed)) a; +void foo (int); + +void +bar () +{ + foo (a.h.g); +} -- 1.7.0.4