diff options
Diffstat (limited to 'clang/test/Sema')
-rw-r--r-- | clang/test/Sema/arm64-inline-asm.c | 8 | ||||
-rw-r--r-- | clang/test/Sema/arm64-neon-args.c | 13 | ||||
-rw-r--r-- | clang/test/Sema/builtins-arm64-exclusive.c | 59 | ||||
-rw-r--r-- | clang/test/Sema/builtins-arm64.c | 18 | ||||
-rw-r--r-- | clang/test/Sema/inline-asm-validate.c | 8 | ||||
-rw-r--r-- | clang/test/Sema/neon-vector-types.c | 3 |
6 files changed, 107 insertions, 2 deletions
diff --git a/clang/test/Sema/arm64-inline-asm.c b/clang/test/Sema/arm64-inline-asm.c new file mode 100644 index 00000000000..2d936214be6 --- /dev/null +++ b/clang/test/Sema/arm64-inline-asm.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios7.1 -fsyntax-only -verify %s +void foo() { + asm volatile("USE(%0)" :: "z"(0LL)); + asm volatile("USE(%x0)" :: "z"(0LL)); + asm volatile("USE(%w0)" :: "z"(0)); + + asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not match register size specified by the constraint and modifier}} +} diff --git a/clang/test/Sema/arm64-neon-args.c b/clang/test/Sema/arm64-neon-args.c new file mode 100644 index 00000000000..5ee653ddd27 --- /dev/null +++ b/clang/test/Sema/arm64-neon-args.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -ffreestanding -verify %s + +#include <arm_neon.h> + +// rdar://13527900 +void vcopy_reject(float32x4_t vOut0, float32x4_t vAlpha, int t) { + vcopyq_laneq_f32(vOut0, 1, vAlpha, t); // expected-error {{argument to '__builtin_neon_vgetq_lane_f32' must be a constant integer}} expected-error {{initializing 'float32_t' (aka 'float') with an expression of incompatible type 'void'}} +} + +// rdar://problem/15256199 +float32x4_t test_vmlsq_lane(float32x4_t accum, float32x4_t lhs, float32x2_t rhs) { + return vmlsq_lane_f32(accum, lhs, rhs, 1); +} diff --git a/clang/test/Sema/builtins-arm64-exclusive.c b/clang/test/Sema/builtins-arm64-exclusive.c new file mode 100644 index 00000000000..0be9c1753f7 --- /dev/null +++ b/clang/test/Sema/builtins-arm64-exclusive.c @@ -0,0 +1,59 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios7.0 -fsyntax-only -verify %s + +struct Simple { + char a, b; +}; + +int test_ldrex(char *addr) { + int sum = 0; + sum += __builtin_arm_ldrex(addr); + sum += __builtin_arm_ldrex((short *)addr); + sum += __builtin_arm_ldrex((int *)addr); + sum += __builtin_arm_ldrex((long long *)addr); + sum += __builtin_arm_ldrex((__int128 *)addr); + sum += __builtin_arm_ldrex((float *)addr); + sum += __builtin_arm_ldrex((double *)addr); + sum += *__builtin_arm_ldrex((int **)addr); + sum += __builtin_arm_ldrex((struct Simple **)addr)->a; + sum += __builtin_arm_ldrex((volatile char *)addr); + sum += __builtin_arm_ldrex((const volatile char *)addr); + + // In principle this might be valid, but stick to ints and floats for scalar + // types at the moment. + sum += __builtin_arm_ldrex((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}} + + __builtin_arm_ldrex(); // expected-error {{too few arguments to function call}} + __builtin_arm_ldrex(1, 2); // expected-error {{too many arguments to function call}} + return sum; +} + +int test_strex(char *addr) { + int res = 0; + struct Simple var = {0}; + res |= __builtin_arm_strex(4, addr); + res |= __builtin_arm_strex(42, (short *)addr); + res |= __builtin_arm_strex(42, (int *)addr); + res |= __builtin_arm_strex(42, (long long *)addr); + res |= __builtin_arm_strex(42, (__int128 *)addr); + res |= __builtin_arm_strex(2.71828f, (float *)addr); + res |= __builtin_arm_strex(3.14159, (double *)addr); + res |= __builtin_arm_strex(&var, (struct Simple **)addr); + + res |= __builtin_arm_strex(42, (volatile char *)addr); + res |= __builtin_arm_strex(42, (char *const)addr); + res |= __builtin_arm_strex(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}} + + + res |= __builtin_arm_strex(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}} + res |= __builtin_arm_strex(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}} + res |= __builtin_arm_strex(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}} + + __builtin_arm_strex(1); // expected-error {{too few arguments to function call}} + __builtin_arm_strex(1, 2, 3); // expected-error {{too many arguments to function call}} + return res; +} + +void test_clrex() { + __builtin_arm_clrex(); + __builtin_arm_clrex(1); // expected-error {{too many arguments to function call}} +} diff --git a/clang/test/Sema/builtins-arm64.c b/clang/test/Sema/builtins-arm64.c new file mode 100644 index 00000000000..f2bdc9dea2b --- /dev/null +++ b/clang/test/Sema/builtins-arm64.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple arm64-apple-ios -DTEST1 -fsyntax-only -verify %s + +#ifdef TEST1 +void __clear_cache(void *start, void *end); +#endif + +void test_clear_cache_chars(char *start, char *end) { + __clear_cache(start, end); +} + +void test_clear_cache_voids(void *start, void *end) { + __clear_cache(start, end); +} + +void test_clear_cache_no_args() { + __clear_cache(); // expected-error {{too few arguments to function call}} +} diff --git a/clang/test/Sema/inline-asm-validate.c b/clang/test/Sema/inline-asm-validate.c new file mode 100644 index 00000000000..cfe4972d5af --- /dev/null +++ b/clang/test/Sema/inline-asm-validate.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -triple arm64-apple-macosx10.8.0 -fsyntax-only -verify %s + +unsigned t, r, *p; + +int foo (void) { + __asm__ __volatile__( "stxr %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); // expected-warning {{value size does not match register size specified by the constraint and modifier}} + return 1; +} diff --git a/clang/test/Sema/neon-vector-types.c b/clang/test/Sema/neon-vector-types.c index d8dd41225a3..03f669eb841 100644 --- a/clang/test/Sema/neon-vector-types.c +++ b/clang/test/Sema/neon-vector-types.c @@ -4,7 +4,7 @@ typedef float float32_t; typedef signed char poly8_t; typedef short poly16_t; -typedef unsigned long long uint64_t; +typedef unsigned __INT64_TYPE__ uint64_t; // Define some valid Neon types. typedef __attribute__((neon_vector_type(2))) int int32x2_t; @@ -23,7 +23,6 @@ typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-er typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{'neon_vector_type' attribute requires an integer constant}} // Only certain element types are allowed. -typedef __attribute__((neon_vector_type(2))) double double_elt; // expected-error{{invalid vector element type}} typedef __attribute__((neon_vector_type(4))) void* ptr_elt; // expected-error{{invalid vector element type}} typedef __attribute__((neon_polyvector_type(4))) float32_t bad_poly_elt; // expected-error{{invalid vector element type}} struct aggr { signed char c; }; |