|
| 1 | +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -fsyntax-only -verify %s |
| 2 | + |
| 3 | +#include <arm_sme.h> |
| 4 | + |
| 5 | +void test_streaming(svint32_t *out, svint32_t *in) __arm_streaming { |
| 6 | + *out = *in; |
| 7 | +} |
| 8 | + |
| 9 | +void test_non_streaming(svint32_t *out, svint32_t *in) { |
| 10 | + *out = *in; // expected-error {{SVE vector type 'svint32_t' (aka '__SVInt32_t') cannot be used in a non-streaming function}} \ |
| 11 | + expected-error {{SVE vector type 'svint32_t' (aka '__SVInt32_t') cannot be used in a non-streaming function}} |
| 12 | +} |
| 13 | + |
| 14 | +// This previously led to a diagnostic that '&a' could not be used in a non-streaming function, |
| 15 | +// even though all functions are streaming. |
| 16 | +void test_both_streaming(int32_t *out) __arm_streaming { |
| 17 | + svint32_t a; |
| 18 | + [&a, &out]() __arm_streaming { |
| 19 | + a = svdup_s32(1); |
| 20 | + svst1(svptrue_b32(), out, a); |
| 21 | + }(); |
| 22 | +} |
| 23 | + |
| 24 | +void test_lambda_streaming(int32_t *out) { |
| 25 | + svint32_t a; // expected-error {{SVE vector type 'svint32_t' (aka '__SVInt32_t') cannot be used in a non-streaming function}} |
| 26 | + [&a, &out]() __arm_streaming { |
| 27 | + a = 1; |
| 28 | + svst1(svptrue_b32(), out, a); |
| 29 | + }(); |
| 30 | +} |
| 31 | + |
| 32 | +void test_lambda_non_streaming_capture_do_nothing() __arm_streaming { |
| 33 | + svint32_t a; |
| 34 | + [&a] { |
| 35 | + // Do nothing. |
| 36 | + }(); |
| 37 | +} |
| 38 | + |
| 39 | +// Error: Non-streaming function attempts to dereference capture: |
| 40 | +void test_lambda_non_streaming_capture_return_vector() __arm_streaming { |
| 41 | + svint32_t a; |
| 42 | + [&a] { |
| 43 | + return a; // expected-error {{SVE vector type 'svint32_t' (aka '__SVInt32_t') cannot be used in a non-streaming function}} |
| 44 | + }(); |
| 45 | +} |
| 46 | + |
| 47 | +// By reference capture, only records and uses the address of `a`: |
| 48 | +// FIXME: This should be okay. |
| 49 | +void test_lambda_non_streaming_capture_return_address() __arm_streaming { |
| 50 | + svint32_t a; |
| 51 | + [&a] { |
| 52 | + return &a; // expected-error {{SVE vector type 'svint32_t' (aka '__SVInt32_t') cannot be used in a non-streaming function}} |
| 53 | + }(); |
| 54 | +} |
0 commit comments