* config/arm/arm.c (arm_override_options): Default to
-fstrict-volatile-bitfields.
testsuite/
* gcc.target/arm/volatile-bitfields-1.c: New test.
* gcc.target/arm/volatile-bitfields-2.c: New test.
* gcc.target/arm/volatile-bitfields-3.c: New test.
===================================================================
@@ -0,0 +1,17 @@
+/* { dg-do compile { target arm*-*-eabi* } } */
+/* { dg-options "-O2" } */
+
+typedef struct {
+ char a:1;
+ char b:7;
+ int c;
+} BitStruct;
+
+volatile BitStruct bits;
+
+int foo ()
+{
+ return bits.b;
+}
+
+/* { dg-final { scan-assembler "ldrb\[\\t \]+.*,\[\\t \]*\\\[.*\\\]" } } */
===================================================================
@@ -0,0 +1,17 @@
+/* { dg-do compile { target arm*-*-eabi* } } */
+/* { dg-options "-O2" } */
+
+typedef struct {
+ volatile unsigned long a:8;
+ volatile unsigned long b:8;
+ volatile unsigned long c:16;
+} BitStruct;
+
+BitStruct bits;
+
+unsigned long foo ()
+{
+ return bits.b;
+}
+
+/* { dg-final { scan-assembler "ldr\[\\t \]+.*,\[\\t \]*\\\[.*\\\]" } } */
===================================================================
@@ -0,0 +1,17 @@
+/* { dg-do compile { target arm*-*-eabi* } } */
+/* { dg-options "-O2" } */
+
+typedef struct {
+ volatile unsigned long a:8;
+ volatile unsigned long b:8;
+ volatile unsigned long c:16;
+} BitStruct;
+
+BitStruct bits;
+
+unsigned long foo ()
+{
+ return bits.c;
+}
+
+/* { dg-final { scan-assembler "ldr\[\\t \]+.*,\[\\t \]*\\\[.*\\\]" } } */
===================================================================
@@ -1916,6 +1916,10 @@ arm_override_options (void)
calculation, which is 2 instructions. */
set_param_value ("gcse-unrestricted-cost", 2);
+ /* ARM EABI defaults to strict volatile bitfields. */
+ if (TARGET_AAPCS_BASED && flag_strict_volatile_bitfields < 0)
+ flag_strict_volatile_bitfields = 1;
+
/* Register global variables with the garbage collector. */
arm_add_gc_roots ();
}