• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11 -Watomic-implicit-seq-cst -Wno-sync-fetch-and-nand-semantics-changed
2 
3 // __sync_* operations are implicitly sequentially-consistent. Some codebases
4 // want to force explicit usage of memory order instead.
5 
fetch_and_add(int * ptr,int val)6 void fetch_and_add(int *ptr, int val) { __sync_fetch_and_add(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
fetch_and_sub(int * ptr,int val)7 void fetch_and_sub(int *ptr, int val) { __sync_fetch_and_sub(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
fetch_and_or(int * ptr,int val)8 void fetch_and_or(int *ptr, int val) { __sync_fetch_and_or(ptr, val); }     // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
fetch_and_and(int * ptr,int val)9 void fetch_and_and(int *ptr, int val) { __sync_fetch_and_and(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
fetch_and_xor(int * ptr,int val)10 void fetch_and_xor(int *ptr, int val) { __sync_fetch_and_xor(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
fetch_and_nand(int * ptr,int val)11 void fetch_and_nand(int *ptr, int val) { __sync_fetch_and_nand(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
12 
add_and_fetch(int * ptr,int val)13 void add_and_fetch(int *ptr, int val) { __sync_add_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
sub_and_fetch(int * ptr,int val)14 void sub_and_fetch(int *ptr, int val) { __sync_sub_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
or_and_fetch(int * ptr,int val)15 void or_and_fetch(int *ptr, int val) { __sync_or_and_fetch(ptr, val); }     // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
and_and_fetch(int * ptr,int val)16 void and_and_fetch(int *ptr, int val) { __sync_and_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
xor_and_fetch(int * ptr,int val)17 void xor_and_fetch(int *ptr, int val) { __sync_xor_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
nand_and_fetch(int * ptr,int val)18 void nand_and_fetch(int *ptr, int val) { __sync_nand_and_fetch(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
19 
bool_compare_and_swap(int * ptr,int oldval,int newval)20 void bool_compare_and_swap(int *ptr, int oldval, int newval) { __sync_bool_compare_and_swap(ptr, oldval, newval); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
val_compare_and_swap(int * ptr,int oldval,int newval)21 void val_compare_and_swap(int *ptr, int oldval, int newval) { __sync_val_compare_and_swap(ptr, oldval, newval); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
22 
synchronize(void)23 void synchronize(void) { __sync_synchronize(); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
24 
lock_test_and_set(int * ptr,int val)25 void lock_test_and_set(int *ptr, int val) { __sync_lock_test_and_set(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
lock_release(int * ptr)26 void lock_release(int *ptr) { __sync_lock_release(ptr); }                         // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
27