Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / aarch64-sme-func-attrs-without-target-feature.cpp
blobb59d67f7f57b8867ed70826077d9f045467bcad0
1 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsyntax-only -verify %s
3 // This test is testing the diagnostics that Clang emits when compiling without '+sme'.
5 void streaming_compatible_def() __arm_streaming_compatible {} // OK
6 void streaming_def() __arm_streaming { } // expected-error {{function executed in streaming-SVE mode requires 'sme'}}
7 void shared_za_def() __arm_shared_za { } // expected-error {{function using ZA state requires 'sme'}}
8 __arm_new_za void new_za_def() { } // expected-error {{function using ZA state requires 'sme'}}
9 __arm_locally_streaming void locally_streaming_def() { } // expected-error {{function executed in streaming-SVE mode requires 'sme'}}
10 void streaming_shared_za_def() __arm_streaming __arm_shared_za { } // expected-error {{function executed in streaming-SVE mode requires 'sme'}}
12 // It should work fine when we explicitly add the target("sme") attribute.
13 __attribute__((target("sme"))) void streaming_compatible_def_sme_attr() __arm_streaming_compatible {} // OK
14 __attribute__((target("sme"))) void streaming_def_sme_attr() __arm_streaming { } // OK
15 __attribute__((target("sme"))) void shared_za_def_sme_attr() __arm_shared_za { } // OK
16 __arm_new_za __attribute__((target("sme"))) void new_za_def_sme_attr() {} // OK
17 __arm_locally_streaming __attribute__((target("sme"))) void locally_streaming_def_sme_attr() {} // OK
19 // Test that it also works with the target("sme2") attribute.
20 __attribute__((target("sme2"))) void streaming_def_sme2_attr() __arm_streaming { } // OK
22 // No code is generated for declarations, so it should be fine to declare using the attribute.
23 void streaming_compatible_decl() __arm_streaming_compatible; // OK
24 void streaming_decl() __arm_streaming; // OK
25 void shared_za_decl() __arm_shared_za; // OK
27 void non_streaming_decl();
28 void non_streaming_def(void (*streaming_fn_ptr)(void) __arm_streaming,
29 void (*streaming_compatible_fn_ptr)(void) __arm_streaming_compatible) {
30 streaming_compatible_decl(); // OK
31 streaming_compatible_fn_ptr(); // OK
32 streaming_decl(); // expected-error {{call to a streaming function requires 'sme'}}
33 streaming_fn_ptr(); // expected-error {{call to a streaming function requires 'sme'}}
36 void streaming_compatible_def2(void (*streaming_fn_ptr)(void) __arm_streaming,
37 void (*streaming_compatible_fn_ptr)(void) __arm_streaming_compatible)
38 __arm_streaming_compatible {
39 non_streaming_decl(); // OK
40 streaming_compatible_decl(); // OK
41 streaming_compatible_fn_ptr(); // OK
42 streaming_decl(); // expected-error {{call to a streaming function requires 'sme'}}
43 streaming_fn_ptr(); // expected-error {{call to a streaming function requires 'sme'}}
46 // Also test when call-site is not a function.
47 int streaming_decl_ret_int() __arm_streaming;
48 int x = streaming_decl_ret_int(); // expected-error {{call to a streaming function requires 'sme'}}