|
1 | 1 | // RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s |
2 | 2 |
|
3 | | -// General tests of __builtin_arm_ldrex and __builtin_arm_strex error checking. |
| 3 | +// General tests of __builtin_arm_ldrex[d] and __builtin_arm_strex[d] error checking. |
4 | 4 | // |
5 | 5 | // This test is compiled for Armv7-A, which provides exclusive load/store |
6 | 6 | // instructions for 1-, 2-, 4- and 8-byte quantities. Other Arm architecture |
@@ -63,6 +63,57 @@ int test_strex(char *addr) { |
63 | 63 | return res; |
64 | 64 | } |
65 | 65 |
|
| 66 | +int test_ldrexd(char *addr) { |
| 67 | + int sum = 0; |
| 68 | + sum += __builtin_arm_ldrexd(addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} |
| 69 | + sum += __builtin_arm_ldrexd((short *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} |
| 70 | + sum += __builtin_arm_ldrexd((int *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} |
| 71 | + sum += __builtin_arm_ldrexd((long long *)addr); |
| 72 | + sum += __builtin_arm_ldrexd((float *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} |
| 73 | + sum += __builtin_arm_ldrexd((double *)addr); |
| 74 | + sum += *__builtin_arm_ldrexd((int **)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} |
| 75 | + 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}} |
| 76 | + 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}} |
| 77 | + 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}} |
| 78 | + |
| 79 | + // In principle this might be valid, but stick to ints and floats for scalar |
| 80 | + // types at the moment. |
| 81 | + sum += __builtin_arm_ldrexd((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}} |
| 82 | + |
| 83 | + 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}} |
| 84 | + |
| 85 | + __builtin_arm_ldrexd(); // expected-error {{too few arguments to function call}} |
| 86 | + __builtin_arm_ldrexd(1, 2); // expected-error {{too many arguments to function call}} |
| 87 | + return sum; |
| 88 | +} |
| 89 | + |
| 90 | +int test_strexd(char *addr) { |
| 91 | + int res = 0; |
| 92 | + struct Simple var = {0}; |
| 93 | + res |= __builtin_arm_strexd(4, addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 8 byte type}} |
| 94 | + 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}} |
| 95 | + 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}} |
| 96 | + res |= __builtin_arm_strexd(42, (long long *)addr); |
| 97 | + 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}} |
| 98 | + res |= __builtin_arm_strexd(3.14159, (double *)addr); |
| 99 | + 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}} |
| 100 | + |
| 101 | + 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}} |
| 102 | + 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}} |
| 103 | + 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}} |
| 104 | + |
| 105 | + |
| 106 | + res |= __builtin_arm_strexd(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}} |
| 107 | + 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}} |
| 108 | + 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}} |
| 109 | + |
| 110 | + 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}} |
| 111 | + |
| 112 | + __builtin_arm_strexd(1); // expected-error {{too few arguments to function call}} |
| 113 | + __builtin_arm_strexd(1, 2, 3); // expected-error {{too many arguments to function call}} |
| 114 | + return res; |
| 115 | +} |
| 116 | + |
66 | 117 | int test_ldaex(char *addr) { |
67 | 118 | int sum = 0; |
68 | 119 | sum += __builtin_arm_ldaex(addr); |
|
0 commit comments