diff options
Diffstat (limited to 'clang/test/Sema/builtins-arm-exclusive.c')
| -rw-r--r-- | clang/test/Sema/builtins-arm-exclusive.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/clang/test/Sema/builtins-arm-exclusive.c b/clang/test/Sema/builtins-arm-exclusive.c index 49aea15..dbb3de5 100644 --- a/clang/test/Sema/builtins-arm-exclusive.c +++ b/clang/test/Sema/builtins-arm-exclusive.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s -// General tests of __builtin_arm_ldrex and __builtin_arm_strex error checking. +// General tests of __builtin_arm_ldrex[d] and __builtin_arm_strex[d] error checking. // // This test is compiled for Armv7-A, which provides exclusive load/store // instructions for 1-, 2-, 4- and 8-byte quantities. Other Arm architecture @@ -63,6 +63,57 @@ int test_strex(char *addr) { return res; } +int test_ldrexd(char *addr) { + int sum = 0; + sum += __builtin_arm_ldrexd(addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + sum += __builtin_arm_ldrexd((short *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + sum += __builtin_arm_ldrexd((int *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + sum += __builtin_arm_ldrexd((long long *)addr); + sum += __builtin_arm_ldrexd((float *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + sum += __builtin_arm_ldrexd((double *)addr); + sum += *__builtin_arm_ldrexd((int **)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + sum += __builtin_arm_ldrexd((struct Simple **)addr)->a; // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + sum += __builtin_arm_ldrexd((volatile char *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + sum += __builtin_arm_ldrexd((const volatile char *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + + // In principle this might be valid, but stick to ints and floats for scalar + // types at the moment. + sum += __builtin_arm_ldrexd((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}} + + sum += __builtin_arm_ldrexd((__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 8 byte type}} + + __builtin_arm_ldrexd(); // expected-error {{too few arguments to function call}} + __builtin_arm_ldrexd(1, 2); // expected-error {{too many arguments to function call}} + return sum; +} + +int test_strexd(char *addr) { + int res = 0; + struct Simple var = {0}; + res |= __builtin_arm_strexd(4, addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + res |= __builtin_arm_strexd(42, (short *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + res |= __builtin_arm_strexd(42, (int *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + res |= __builtin_arm_strexd(42, (long long *)addr); + res |= __builtin_arm_strexd(2.71828f, (float *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + res |= __builtin_arm_strexd(3.14159, (double *)addr); + res |= __builtin_arm_strexd(&var, (struct Simple **)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + + res |= __builtin_arm_strexd(42, (volatile char *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + res |= __builtin_arm_strexd(42, (char *const)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + res |= __builtin_arm_strexd(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + + + res |= __builtin_arm_strexd(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}} + res |= __builtin_arm_strexd(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + res |= __builtin_arm_strexd(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} + + res |= __builtin_arm_strexd(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 8 byte type}} + + __builtin_arm_strexd(1); // expected-error {{too few arguments to function call}} + __builtin_arm_strexd(1, 2, 3); // expected-error {{too many arguments to function call}} + return res; +} + int test_ldaex(char *addr) { int sum = 0; sum += __builtin_arm_ldaex(addr); |
