aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/simulate-thread/strict-align-global.c
diff options
context:
space:
mode:
authorAndrew Macleod <amacleod@gcc.gnu.org>2011-11-06 14:55:48 +0000
committerAndrew Macleod <amacleod@gcc.gnu.org>2011-11-06 14:55:48 +0000
commit86951993f8a4cae2fb26bf8705e2f248a8d6f21e (patch)
treec0f499483e35c60c1b9f065f10a630e6fa4345bc /gcc/testsuite/gcc.dg/simulate-thread/strict-align-global.c
parenta8a058f6523f1e0f7b69ec1837848e55cf9f0856 (diff)
downloadgcc-86951993f8a4cae2fb26bf8705e2f248a8d6f21e.zip
gcc-86951993f8a4cae2fb26bf8705e2f248a8d6f21e.tar.gz
gcc-86951993f8a4cae2fb26bf8705e2f248a8d6f21e.tar.bz2
Check in patch/merge from cxx-mem-model Branch
From-SVN: r181031
Diffstat (limited to 'gcc/testsuite/gcc.dg/simulate-thread/strict-align-global.c')
-rw-r--r--gcc/testsuite/gcc.dg/simulate-thread/strict-align-global.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/simulate-thread/strict-align-global.c b/gcc/testsuite/gcc.dg/simulate-thread/strict-align-global.c
new file mode 100644
index 0000000..fdcd7f4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/simulate-thread/strict-align-global.c
@@ -0,0 +1,52 @@
+/* { dg-do link } */
+/* { dg-options "--param allow-packed-store-data-races=0" } */
+/* { dg-final { simulate-thread } } */
+
+#include <stdio.h>
+#include "simulate-thread.h"
+
+/* This test verifies writes to globals do not write to adjacent
+ globals. This mostly happens on strict-align targets that are not
+ byte addressable (old Alphas, etc). */
+
+char a = 0;
+char b = 77;
+
+void simulate_thread_other_threads()
+{
+}
+
+int simulate_thread_step_verify()
+{
+ if (b != 77)
+ {
+ printf("FAIL: Unexpected value. <b> is %d, should be 77\n", b);
+ return 1;
+ }
+ return 0;
+}
+
+/* Verify that every variable has the correct value. */
+int simulate_thread_final_verify()
+{
+ int ret = simulate_thread_step_verify ();
+ if (a != 66)
+ {
+ printf("FAIL: Unexpected value. <a> is %d, should be 66\n", a);
+ return 1;
+ }
+ return ret;
+}
+
+__attribute__((noinline))
+void simulate_thread_main()
+{
+ a = 66;
+}
+
+int main ()
+{
+ simulate_thread_main();
+ simulate_thread_done();
+ return 0;
+}