[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / builtins-arm64-exclusive.c
blobce01f79767fa865dd65533cf4d600cd2374b0e13
1 // RUN: %clang_cc1 -triple arm64-apple-ios7.0 -fsyntax-only -verify %s
3 struct Simple {
4 char a, b;
5 };
7 int test_ldrex(char *addr) {
8 int sum = 0;
9 sum += __builtin_arm_ldrex(addr);
10 sum += __builtin_arm_ldrex((short *)addr);
11 sum += __builtin_arm_ldrex((int *)addr);
12 sum += __builtin_arm_ldrex((long long *)addr);
13 sum += __builtin_arm_ldrex((__int128 *)addr);
14 sum += __builtin_arm_ldrex((float *)addr);
15 sum += __builtin_arm_ldrex((double *)addr);
16 sum += *__builtin_arm_ldrex((int **)addr);
17 sum += __builtin_arm_ldrex((struct Simple **)addr)->a;
18 sum += __builtin_arm_ldrex((volatile char *)addr);
19 sum += __builtin_arm_ldrex((const volatile char *)addr);
21 // In principle this might be valid, but stick to ints and floats for scalar
22 // types at the moment.
23 sum += __builtin_arm_ldrex((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}}
25 __builtin_arm_ldrex(); // expected-error {{too few arguments to function call}}
26 __builtin_arm_ldrex(1, 2); // expected-error {{too many arguments to function call}}
27 return sum;
30 int test_strex(char *addr) {
31 int res = 0;
32 struct Simple var = {0};
33 res |= __builtin_arm_strex(4, addr);
34 res |= __builtin_arm_strex(42, (short *)addr);
35 res |= __builtin_arm_strex(42, (int *)addr);
36 res |= __builtin_arm_strex(42, (long long *)addr);
37 res |= __builtin_arm_strex(42, (__int128 *)addr);
38 res |= __builtin_arm_strex(2.71828f, (float *)addr);
39 res |= __builtin_arm_strex(3.14159, (double *)addr);
40 res |= __builtin_arm_strex(&var, (struct Simple **)addr);
42 res |= __builtin_arm_strex(42, (volatile char *)addr);
43 res |= __builtin_arm_strex(42, (char *const)addr);
44 res |= __builtin_arm_strex(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}}
47 res |= __builtin_arm_strex(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}}
48 res |= __builtin_arm_strex(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}}
49 res |= __builtin_arm_strex(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}}
51 __builtin_arm_strex(1); // expected-error {{too few arguments to function call}}
52 __builtin_arm_strex(1, 2, 3); // expected-error {{too many arguments to function call}}
53 return res;
56 int test_ldaex(char *addr) {
57 int sum = 0;
58 sum += __builtin_arm_ldaex(addr);
59 sum += __builtin_arm_ldaex((short *)addr);
60 sum += __builtin_arm_ldaex((int *)addr);
61 sum += __builtin_arm_ldaex((long long *)addr);
62 sum += __builtin_arm_ldaex((__int128 *)addr);
63 sum += __builtin_arm_ldaex((float *)addr);
64 sum += __builtin_arm_ldaex((double *)addr);
65 sum += *__builtin_arm_ldaex((int **)addr);
66 sum += __builtin_arm_ldaex((struct Simple **)addr)->a;
67 sum += __builtin_arm_ldaex((volatile char *)addr);
68 sum += __builtin_arm_ldaex((const volatile char *)addr);
70 // In principle this might be valid, but stick to ints and floats for scalar
71 // types at the moment.
72 sum += __builtin_arm_ldaex((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}}
74 __builtin_arm_ldaex(); // expected-error {{too few arguments to function call}}
75 __builtin_arm_ldaex(1, 2); // expected-error {{too many arguments to function call}}
76 return sum;
79 int test_stlex(char *addr) {
80 int res = 0;
81 struct Simple var = {0};
82 res |= __builtin_arm_stlex(4, addr);
83 res |= __builtin_arm_stlex(42, (short *)addr);
84 res |= __builtin_arm_stlex(42, (int *)addr);
85 res |= __builtin_arm_stlex(42, (long long *)addr);
86 res |= __builtin_arm_stlex(42, (__int128 *)addr);
87 res |= __builtin_arm_stlex(2.71828f, (float *)addr);
88 res |= __builtin_arm_stlex(3.14159, (double *)addr);
89 res |= __builtin_arm_stlex(&var, (struct Simple **)addr);
91 res |= __builtin_arm_stlex(42, (volatile char *)addr);
92 res |= __builtin_arm_stlex(42, (char *const)addr);
93 res |= __builtin_arm_stlex(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}}
96 res |= __builtin_arm_stlex(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}}
97 res |= __builtin_arm_stlex(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}}
98 res |= __builtin_arm_stlex(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}}
100 __builtin_arm_stlex(1); // expected-error {{too few arguments to function call}}
101 __builtin_arm_stlex(1, 2, 3); // expected-error {{too many arguments to function call}}
102 return res;
105 void test_clrex(void) {
106 __builtin_arm_clrex();
107 __builtin_arm_clrex(1); // expected-error {{too many arguments to function call}}