1 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -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 -msve-vector-bits=512 -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 -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
4 
5 // lax-vector-all-no-diagnostics
6 
7 #include <arm_sve.h>
8 
9 #define N __ARM_FEATURE_SVE_BITS
10 #define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
11 #define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
12 
13 typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
14 typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
15 typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
16 typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
17 
sve_allowed_with_integer_lax_conversions()18 void sve_allowed_with_integer_lax_conversions() {
19   sve_fixed_int32_t fi32;
20   svint64_t si64;
21 
22   // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
23   // -flax-vector-conversions={integer,all}.
24   fi32 = si64;
25   // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
26   si64 = fi32;
27   // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
28 }
29 
sve_allowed_with_all_lax_conversions()30 void sve_allowed_with_all_lax_conversions() {
31   sve_fixed_float32_t ff32;
32   svfloat64_t sf64;
33 
34   // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
35   // -flax-vector-conversions=all.
36   ff32 = sf64;
37   // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
38   // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
39   sf64 = ff32;
40   // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
41   // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
42 }
43 
gnu_allowed_with_integer_lax_conversions()44 void gnu_allowed_with_integer_lax_conversions() {
45   gnu_fixed_int32_t fi32;
46   svint64_t si64;
47 
48   // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
49   // -flax-vector-conversions={integer,all}.
50   fi32 = si64;
51   // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
52   si64 = fi32;
53   // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
54 }
55 
gnu_allowed_with_all_lax_conversions()56 void gnu_allowed_with_all_lax_conversions() {
57   gnu_fixed_float32_t ff32;
58   svfloat64_t sf64;
59 
60   // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
61   // -flax-vector-conversions=all.
62   ff32 = sf64;
63   // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
64   // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
65   sf64 = ff32;
66   // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
67   // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
68 }
69