| Tim Northover | 6aacd49 | 2013-07-16 09:47:53 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s |
| 2 | |
| 3 | struct Simple { |
| 4 | char a, b; |
| 5 | }; |
| 6 | |
| 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((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); |
| 19 | |
| 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}} |
| 23 | |
| 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}} |
| 25 | |
| 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}} |
| 28 | return sum; |
| 29 | } |
| 30 | |
| 31 | int test_strex(char *addr) { |
| 32 | int res = 0; |
| 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); |
| 41 | |
| 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}} |
| 45 | |
| 46 | |
| 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}} |
| 50 | |
| 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}} |
| 52 | |
| 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}} |
| 55 | return res; |
| 56 | } |
| 57 | |
| 58 | void test_clrex() { |
| 59 | __builtin_arm_clrex(); |
| 60 | __builtin_arm_clrex(1); // expected-error {{too many arguments to function call}} |
| 61 | } |