This patch fixes the PR23623 regression. In conjunction with part 2 of the series, it also fixes the new volatile-bitfields-3.c test case.

As I noted in previous discussion, there might be a better place to accomplish this effect, but hacking DECL_BIT_FIELD_REPRESENTATIVE can't work because the volatile-ness may be coming from a qualifier on the pointer or object from which the field is being extracted, rather than from a volatile qualifier on the bit field decl. I think the choices are to do it in get_bit_range (as in this patch), in the callers of get_bit_range, or at the places where the bit range information is being used.

-Sandra

2013-06-16  Sandra Loosemore  <san...@codesourcery.com>

	PR middle-end/23623

	gcc/
	* expr.c (get_bit_range): Handle flag_strict_volatile_bitfields.
Index: gcc/expr.c
===================================================================
--- gcc/expr.c	(revision 199963)
+++ gcc/expr.c	(working copy)
@@ -4508,6 +4508,16 @@ get_bit_range (unsigned HOST_WIDE_INT *b
 
   gcc_assert (TREE_CODE (exp) == COMPONENT_REF);
 
+  /* If -fstrict-volatile-bitfields was given and this is a volatile
+     access, then we must ignore any DECL_BIT_FIELD_REPRESENTATIVE and
+     do the access in the mode of the field.  */
+  if (TREE_THIS_VOLATILE (exp)
+      && flag_strict_volatile_bitfields > 0)
+    {
+      *bitstart = *bitend = 0;
+      return;
+    }
+
   field = TREE_OPERAND (exp, 1);
   repr = DECL_BIT_FIELD_REPRESENTATIVE (field);
   /* If we do not have a DECL_BIT_FIELD_REPRESENTATIVE there is no

Reply via email to