Skip to content

Commit 593f070

Browse files
committed
Re-add condition and add tests
1 parent e8aa8ab commit 593f070

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

clang/lib/AST/Decl.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5988,9 +5988,11 @@ bool clang::IsArmStreamingFunction(const FunctionDecl *FD,
59885988
if (FD->hasAttr<ArmLocallyStreamingAttr>())
59895989
return true;
59905990

5991-
if (const auto *FPT = FD->getType()->getAs<FunctionProtoType>())
5992-
if (FPT->getAArch64SMEAttributes() & FunctionType::SME_PStateSMEnabledMask)
5993-
return true;
5991+
if (const Type *Ty = FD->getType().getTypePtrOrNull())
5992+
if (const auto *FPT = Ty->getAs<FunctionProtoType>())
5993+
if (FPT->getAArch64SMEAttributes() &
5994+
FunctionType::SME_PStateSMEnabledMask)
5995+
return true;
59945996

59955997
return false;
59965998
}

clang/test/Sema/aarch64-sme-attrs-without-sve.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void test_non_streaming(svint32_t *out, svint32_t *in) {
1313

1414
// This previously led to a diagnostic that '&a' could not be used in a non-streaming function,
1515
// even though all functions are streaming.
16-
void test_both_streaming(int32_t *out) __arm_streaming{
16+
void test_both_streaming(int32_t *out) __arm_streaming {
1717
svint32_t a;
1818
[&a, &out]() __arm_streaming {
1919
a = svdup_s32(1);
@@ -29,3 +29,26 @@ void test_lambda_streaming(int32_t *out) {
2929
}();
3030
}
3131

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

Comments
 (0)