Debian Codegraph @

gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-6.c

raw
1 /* Test we do correct thing for adding to / subtracting from a pointer,
2 i.e. that the multiplication by the size of the pointer target type
3 still occurs. */
4 /* { dg-do run } */
5 /* { dg-options "-std=c11 -pedantic-errors" } */
6 /* { dg-xfail-run-if "PR97444: stack atomics" { nvptx*-*-* } }*/
7
8 #define TEST_POINTER_ADD_SUB(TYPE) \
9 do \
10 { \
11 TYPE a[3][3]; \
12 TYPE (*_Atomic q)[3] = &a[0]; \
13 ++q; \
14 if (q != &a[1]) \
15 __builtin_abort (); \
16 q++; \
17 if (q != &a[2]) \
18 __builtin_abort (); \
19 --q; \
20 if (q != &a[1]) \
21 __builtin_abort (); \
22 q--; \
23 if (q != &a[0]) \
24 __builtin_abort (); \
25 q += 2; \
26 if (q != &a[2]) \
27 __builtin_abort (); \
28 q -= 2; \
29 if (q != &a[0]) \
30 __builtin_abort (); \
31 } \
32 while (0)
33
34 int
35 main (void)
36 {
37 TEST_POINTER_ADD_SUB (_Bool);
38 TEST_POINTER_ADD_SUB (char);
39 TEST_POINTER_ADD_SUB (signed char);
40 TEST_POINTER_ADD_SUB (unsigned char);
41 TEST_POINTER_ADD_SUB (signed short);
42 TEST_POINTER_ADD_SUB (unsigned short);
43 TEST_POINTER_ADD_SUB (signed int);
44 TEST_POINTER_ADD_SUB (unsigned int);
45 TEST_POINTER_ADD_SUB (signed long);
46 TEST_POINTER_ADD_SUB (unsigned long);
47 TEST_POINTER_ADD_SUB (signed long long);
48 TEST_POINTER_ADD_SUB (unsigned long long);
49 TEST_POINTER_ADD_SUB (float);
50 TEST_POINTER_ADD_SUB (double);
51 TEST_POINTER_ADD_SUB (long double);
52 TEST_POINTER_ADD_SUB (_Complex float);
53 TEST_POINTER_ADD_SUB (_Complex double);
54 TEST_POINTER_ADD_SUB (_Complex long double);
55 }