[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / aarch64-sve-lax-vector-conversions.c
blob99c5f1d07f806b4a2f7ddbcf3abe0ab0530eb5cd
1 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
3 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
5 // lax-vector-all-no-diagnostics
7 // REQUIRES: aarch64-registered-target || arm-registered-target
9 #include <arm_sve.h>
11 #define N __ARM_FEATURE_SVE_BITS
12 #define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
13 #define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
15 typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
16 typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
17 typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
18 typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
20 void sve_allowed_with_integer_lax_conversions() {
21 sve_fixed_int32_t fi32;
22 svint64_t si64;
24 // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
25 // -flax-vector-conversions={integer,all}.
26 fi32 = si64;
27 // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
28 si64 = fi32;
29 // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
32 void sve_allowed_with_all_lax_conversions() {
33 sve_fixed_float32_t ff32;
34 svfloat64_t sf64;
36 // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
37 // -flax-vector-conversions=all.
38 ff32 = sf64;
39 // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
40 // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
41 sf64 = ff32;
42 // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
43 // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
46 void gnu_allowed_with_integer_lax_conversions() {
47 gnu_fixed_int32_t fi32;
48 svint64_t si64;
50 // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
51 // -flax-vector-conversions={integer,all}.
52 fi32 = si64;
53 // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
54 si64 = fi32;
55 // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
58 void gnu_allowed_with_all_lax_conversions() {
59 gnu_fixed_float32_t ff32;
60 svfloat64_t sf64;
62 // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
63 // -flax-vector-conversions=all.
64 ff32 = sf64;
65 // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
66 // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
67 sf64 = ff32;
68 // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
69 // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}