1// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +neon -fsyntax-only -verify
2// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +neon -DUSE_LONG -fsyntax-only -verify
3// RUN: %clang_cc1 %s -triple arm64-none-linux-gnu -target-feature +neon -fsyntax-only -verify
4// RUN: %clang_cc1 %s -triple arm64-none-linux-gnu -target-feature +neon -DUSE_LONG -fsyntax-only -verify
5
6typedef float float32_t;
7typedef unsigned char poly8_t;
8typedef unsigned short poly16_t;
9
10// Both "long" and "long long" should work for 64-bit arch like aarch64.
11// stdint.h in gnu libc is using "long" for 64-bit arch.
12#if USE_LONG
13typedef long int64_t;
14typedef unsigned long uint64_t;
15#else
16typedef long long int64_t;
17typedef unsigned long long uint64_t;
18#endif
19typedef uint64_t poly64_t;
20
21// Define some valid Neon types.
22typedef __attribute__((neon_vector_type(2))) int int32x2_t;
23typedef __attribute__((neon_vector_type(4))) int int32x4_t;
24typedef __attribute__((neon_vector_type(1))) int64_t int64x1_t;
25typedef __attribute__((neon_vector_type(2))) int64_t int64x2_t;
26typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
27typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
28typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t;
29typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
30typedef __attribute__((neon_polyvector_type(16))) poly8_t  poly8x16_t;
31typedef __attribute__((neon_polyvector_type(8)))  poly16_t poly16x8_t;
32typedef __attribute__((neon_polyvector_type(1)))  poly64_t poly64x1_t;
33typedef __attribute__((neon_polyvector_type(2)))  poly64_t poly64x2_t;
34
35// The attributes must have a single argument.
36typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{attribute takes one argument}}
37
38// The number of elements must be an ICE.
39typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{attribute requires an integer constant}}
40
41// Only certain element types are allowed.
42typedef __attribute__((neon_vector_type(2))) double double_elt;
43typedef __attribute__((neon_vector_type(4))) void* ptr_elt; // expected-error{{invalid vector element type}}
44typedef __attribute__((neon_polyvector_type(4))) float32_t bad_poly_elt; // expected-error{{invalid vector element type}}
45struct aggr { signed char c; };
46typedef __attribute__((neon_vector_type(8))) struct aggr aggregate_elt; // expected-error{{invalid vector element type}}
47
48// The total vector size must be 64 or 128 bits.
49typedef __attribute__((neon_vector_type(1))) int int32x1_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
50typedef __attribute__((neon_vector_type(3))) int int32x3_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
51