71 lines · c
1// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify=lax-vector-none %s2// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=integer -ffreestanding -fsyntax-only -verify=lax-vector-integer %s3// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=all -ffreestanding -fsyntax-only -verify=lax-vector-all %s4 5// lax-vector-all-no-diagnostics6 7// REQUIRES: aarch64-registered-target || arm-registered-target8 9#include <arm_sve.h>10 11#define N __ARM_FEATURE_SVE_BITS12#define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))13#define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))14 15typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;16typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;17typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;18typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;19 20void sve_allowed_with_integer_lax_conversions() {21 sve_fixed_int32_t fi32;22 svint64_t si64;23 24 // The implicit cast here should fail if -flax-vector-conversions=none, but pass if25 // -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}}30}31 32void sve_allowed_with_all_lax_conversions() {33 sve_fixed_float32_t ff32;34 svfloat64_t sf64;35 36 // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if37 // -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}}44}45 46void gnu_allowed_with_integer_lax_conversions() {47 gnu_fixed_int32_t fi32;48 svint64_t si64;49 50 // The implicit cast here should fail if -flax-vector-conversions=none, but pass if51 // -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}}56}57 58void gnu_allowed_with_all_lax_conversions() {59 gnu_fixed_float32_t ff32;60 svfloat64_t sf64;61 62 // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if63 // -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}}70}71