| Tim Northover | a2ee433 | 2014-03-29 15:09:45 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple arm64-apple-ios7.0 -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((__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); | 
|  | 20 |  | 
|  | 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}} | 
|  | 24 |  | 
|  | 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; | 
|  | 28 | } | 
|  | 29 |  | 
|  | 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); | 
|  | 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 | __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; | 
|  | 54 | } | 
|  | 55 |  | 
|  | 56 | void test_clrex() { | 
|  | 57 | __builtin_arm_clrex(); | 
|  | 58 | __builtin_arm_clrex(1); // expected-error {{too many arguments to function call}} | 
|  | 59 | } |