summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr56997-4.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr56997-4.c')
-rw-r--r--gcc/testsuite/gcc.dg/pr56997-4.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr56997-4.c b/gcc/testsuite/gcc.dg/pr56997-4.c
new file mode 100644
index 0000000000..38f6248d2e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr56997-4.c
@@ -0,0 +1,23 @@
+/* Test volatile access to unaligned field. */
+/* { dg-do compile } */
+/* { dg-options "-fno-strict-volatile-bitfields -fdump-rtl-final" } */
+
+#define test_type unsigned short
+
+typedef struct s{
+ unsigned char Prefix[1];
+ volatile test_type Type;
+}__attribute((__packed__,__aligned__(4))) ss;
+
+extern volatile ss v;
+
+void
+foo (test_type u)
+{
+ v.Type = u;
+}
+
+/* The C++ memory model forbids data store race conditions outside the
+ unaligned data member, therefore only QI or HI access is allowed, no SI. */
+/* { dg-final { scan-rtl-dump-not "mem/v(/.)*:SI" "final" } } */
+/* { dg-final { cleanup-rtl-dump "final" } } */