2008-01-25 Douglas Gregor <doug.gregor@gmail.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / sync-1.c
blobf8cabe47a9904b51a7fdebc646ddc70268bfbf63
1 /* Validate that the __sync builtins are overloaded properly. */
2 /* { dg-do compile } */
3 /* { dg-options "-Werror" } */
5 #define TEST1(TYPE, BUILTIN) \
6 void t_##TYPE##BUILTIN(TYPE *p) \
7 { \
8 __typeof(BUILTIN(p, 1)) *pp; \
9 pp = p; \
12 #define TEST2(BUILTIN) \
13 TEST1(int, BUILTIN) \
14 TEST1(long, BUILTIN)
16 TEST2(__sync_fetch_and_add)
17 TEST2(__sync_fetch_and_sub)
18 TEST2(__sync_fetch_and_or)
19 TEST2(__sync_fetch_and_and)
20 TEST2(__sync_fetch_and_xor)
21 TEST2(__sync_fetch_and_nand)
23 TEST2(__sync_add_and_fetch)
24 TEST2(__sync_sub_and_fetch)
25 TEST2(__sync_or_and_fetch)
26 TEST2(__sync_and_and_fetch)
27 TEST2(__sync_xor_and_fetch)
28 TEST2(__sync_nand_and_fetch)
30 TEST2(__sync_lock_test_and_set)
32 #define TEST3(TYPE) \
33 void t_##TYPE##__sync_val_compare_and_swap(TYPE *p) \
34 { \
35 __typeof(__sync_val_compare_and_swap(p, 1, 2)) *pp; \
36 pp = p; \
39 TEST3(int)
40 TEST3(long)