summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-7.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-7.c')
-rw-r--r--gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-7.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-7.c b/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-7.c
new file mode 100644
index 00000000000..eb7082d8d33
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-7.c
@@ -0,0 +1,34 @@
+/* Test we're able use __atomic_fetch_* where possible and verify
+ we generate correct code. */
+/* { dg-do run } */
+/* { dg-options "-std=c11 -pedantic-errors -fdump-tree-original" } */
+
+#include <stdatomic.h>
+#include <limits.h>
+
+extern void abort (void);
+
+#define TEST_TYPE(TYPE, MAX) \
+ do \
+ { \
+ struct S { char a[(MAX) + 1]; }; \
+ TYPE t = 1; \
+ struct S a[2][2]; \
+ struct S (*_Atomic p)[2] = &a[0]; \
+ p += t; \
+ if (p != &a[1]) \
+ abort (); \
+ p -= t; \
+ if (p != &a[0]) \
+ abort (); \
+ } \
+ while (0)
+
+int
+main (void)
+{
+ TEST_TYPE (signed char, UCHAR_MAX);
+ TEST_TYPE (signed short, USHRT_MAX);
+}
+
+/* { dg-final { scan-tree-dump-not "__atomic_compare_exchange" "original" } } */