1 // RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s
7 int test_ldrex(char *addr
) {
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((float *)addr
);
14 sum
+= __builtin_arm_ldrex((double *)addr
);
15 sum
+= *__builtin_arm_ldrex((int **)addr
);
16 sum
+= __builtin_arm_ldrex((struct Simple
**)addr
)->a
;
17 sum
+= __builtin_arm_ldrex((volatile char *)addr
);
18 sum
+= __builtin_arm_ldrex((const volatile char *)addr
);
20 // In principle this might be valid, but stick to ints and floats for scalar
21 // types at the moment.
22 sum
+= __builtin_arm_ldrex((struct Simple
*)addr
).a
; // expected-error {{address argument to atomic builtin must be a pointer to}}
24 sum
+= __builtin_arm_ldrex((__int128
*)addr
); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
26 __builtin_arm_ldrex(); // expected-error {{too few arguments to function call}}
27 __builtin_arm_ldrex(1, 2); // expected-error {{too many arguments to function call}}
31 int test_strex(char *addr
) {
33 struct Simple var
= {0};
34 res
|= __builtin_arm_strex(4, addr
);
35 res
|= __builtin_arm_strex(42, (short *)addr
);
36 res
|= __builtin_arm_strex(42, (int *)addr
);
37 res
|= __builtin_arm_strex(42, (long long *)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 res
|= __builtin_arm_strex(1, (__int128
*)addr
); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
53 __builtin_arm_strex(1); // expected-error {{too few arguments to function call}}
54 __builtin_arm_strex(1, 2, 3); // expected-error {{too many arguments to function call}}
58 int test_ldaex(char *addr
) {
60 sum
+= __builtin_arm_ldaex(addr
);
61 sum
+= __builtin_arm_ldaex((short *)addr
);
62 sum
+= __builtin_arm_ldaex((int *)addr
);
63 sum
+= __builtin_arm_ldaex((long long *)addr
);
64 sum
+= __builtin_arm_ldaex((float *)addr
);
65 sum
+= __builtin_arm_ldaex((double *)addr
);
66 sum
+= *__builtin_arm_ldaex((int **)addr
);
67 sum
+= __builtin_arm_ldaex((struct Simple
**)addr
)->a
;
68 sum
+= __builtin_arm_ldaex((volatile char *)addr
);
69 sum
+= __builtin_arm_ldaex((const volatile char *)addr
);
71 // In principle this might be valid, but stick to ints and floats for scalar
72 // types at the moment.
73 sum
+= __builtin_arm_ldaex((struct Simple
*)addr
).a
; // expected-error {{address argument to atomic builtin must be a pointer to}}
75 sum
+= __builtin_arm_ldaex((__int128
*)addr
); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
77 __builtin_arm_ldaex(); // expected-error {{too few arguments to function call}}
78 __builtin_arm_ldaex(1, 2); // expected-error {{too many arguments to function call}}
82 int test_stlex(char *addr
) {
84 struct Simple var
= {0};
85 res
|= __builtin_arm_stlex(4, addr
);
86 res
|= __builtin_arm_stlex(42, (short *)addr
);
87 res
|= __builtin_arm_stlex(42, (int *)addr
);
88 res
|= __builtin_arm_stlex(42, (long long *)addr
);
89 res
|= __builtin_arm_stlex(2.71828f
, (float *)addr
);
90 res
|= __builtin_arm_stlex(3.14159, (double *)addr
);
91 res
|= __builtin_arm_stlex(&var
, (struct Simple
**)addr
);
93 res
|= __builtin_arm_stlex(42, (volatile char *)addr
);
94 res
|= __builtin_arm_stlex(42, (char *const)addr
);
95 res
|= __builtin_arm_stlex(42, (const char *)addr
); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}}
98 res
|= __builtin_arm_stlex(var
, (struct Simple
*)addr
); // expected-error {{address argument to atomic builtin must be a pointer to}}
99 res
|= __builtin_arm_stlex(var
, (struct Simple
**)addr
); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}}
100 res
|= __builtin_arm_stlex(&var
, (struct Simple
**)addr
).a
; // expected-error {{is not a structure or union}}
102 res
|= __builtin_arm_stlex(1, (__int128
*)addr
); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
104 __builtin_arm_stlex(1); // expected-error {{too few arguments to function call}}
105 __builtin_arm_stlex(1, 2, 3); // expected-error {{too many arguments to function call}}
109 void test_clrex(void) {
110 __builtin_arm_clrex();
111 __builtin_arm_clrex(1); // expected-error {{too many arguments to function call}}