| 1 |
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify %s |
| 2 |
|
| 3 |
int __attribute__((target_version("crc"))) dup(void) { return 3; } |
| 4 |
int __attribute__((target_version("default"))) dup(void) { return 1; } |
| 5 |
//expected-error@+2 {{redefinition of 'dup'}} |
| 6 |
//expected-note@-2 {{previous definition is here}} |
| 7 |
int __attribute__((target_version("default"))) dup(void) { return 2; } |
| 8 |
|
| 9 |
int __attribute__((target_version("default"))) dup1(void) { return 1; } |
| 10 |
//expected-error@+2 {{redefinition of 'dup1'}} |
| 11 |
//expected-note@-2 {{previous definition is here}} |
| 12 |
int dup1(void) { return 2; } |
| 13 |
|
| 14 |
int __attribute__((target_version("aes"))) foo(void) { return 1; } |
| 15 |
//expected-note@+1 {{previous definition is here}} |
| 16 |
int __attribute__((target_version("default"))) foo(void) { return 2; } |
| 17 |
|
| 18 |
//expected-note@+1 {{previous definition is here}} |
| 19 |
int __attribute__((target_version("sha3 + aes "))) foo(void) { return 1; } |
| 20 |
//expected-note@-1 {{previous definition is here}} |
| 21 |
|
| 22 |
//expected-error@+1 {{redefinition of 'foo'}} |
| 23 |
int __attribute__((target("dotprod"))) foo(void) { return -1; } |
| 24 |
//expected-warning@-1 {{attribute declaration must precede definition}} |
| 25 |
|
| 26 |
//expected-error@+1 {{redefinition of 'foo'}} |
| 27 |
int foo(void) { return 2; } |
| 28 |
|
| 29 |
//expected-note@+1 {{previous definition is here}} |
| 30 |
__attribute__ ((target("bf16,sve,sve2,dotprod"))) int func(void) { return 1; } |
| 31 |
//expected-error@+1 {{redefinition of 'func'}} |
| 32 |
__attribute__ ((target("default"))) int func(void) { return 0; } |
| 33 |
|
| 34 |
//expected-note@+1 {{previous declaration is here}} |
| 35 |
void __attribute__((target_version("bti+flagm2"))) one(void) {} |
| 36 |
//expected-error@+1 {{multiversioned function redeclarations require identical target attributes}} |
| 37 |
void __attribute__((target_version("flagm2+bti"))) one(void) {} |
| 38 |
|
| 39 |
void __attribute__((target_version("ssbs+sha2"))) two(void) {} |
| 40 |
void __attribute__((target_version("ssbs+fp16fml"))) two(void) {} |
| 41 |
|
| 42 |
//expected-error@+1 {{'main' cannot be a multiversioned function}} |
| 43 |
int __attribute__((target_version("lse"))) main(void) { return 1; } |
| 44 |
|
| 45 |
// It is ok for the default version to appear first. |
| 46 |
int default_first(void) { return 1; } |
| 47 |
int __attribute__((target_version("dit"))) default_first(void) { return 2; } |
| 48 |
int __attribute__((target_version("mops"))) default_first(void) { return 3; } |
| 49 |
|
| 50 |
// It is ok if the default version is between other versions. |
| 51 |
int __attribute__((target_version("simd"))) default_middle(void) {return 0; } |
| 52 |
int __attribute__((target_version("default"))) default_middle(void) { return 1; } |
| 53 |
int __attribute__((target_version("aes"))) default_middle(void) { return 2; } |
| 54 |
|
| 55 |
// It is ok for the default version to be the last one. |
| 56 |
int __attribute__((target_version("rdm"))) default_last(void) {return 0; } |
| 57 |
int __attribute__((target_version("lse+aes"))) default_last(void) { return 1; } |
| 58 |
int __attribute__((target_version("default"))) default_last(void) { return 2; } |
| 59 |
|
| 60 |
// It is also ok to forward declare the default. |
| 61 |
int __attribute__((target_version("default"))) default_fwd_declare(void); |
| 62 |
int __attribute__((target_version("sve"))) default_fwd_declare(void) { return 0; } |
| 63 |
int default_fwd_declare(void) { return 1; } |
| 64 |
|
| 65 |
//expected-warning@+1 {{unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored}} |
| 66 |
int __attribute__((target_version(""))) unsup1(void) { return 1; } |
| 67 |
//expected-warning@+1 {{unsupported 'crc32' in the 'target_version' attribute string; 'target_version' attribute ignored}} |
| 68 |
void __attribute__((target_version("crc32"))) unsup2(void) {} |
| 69 |
|
| 70 |
void __attribute__((target_version("default+fp16"))) koo(void) {} |
| 71 |
//expected-error@-1 {{function multiversioning doesn't support feature 'default'}} |
| 72 |
void __attribute__((target_version("default+default+default"))) loo(void) {} |
| 73 |
//expected-error@-1 {{function multiversioning doesn't support feature 'default'}} |
| 74 |
void __attribute__((target_version("rdm+rng+crc"))) redef(void) {} |
| 75 |
//expected-error@+2 {{redefinition of 'redef'}} |
| 76 |
//expected-note@-2 {{previous definition is here}} |
| 77 |
void __attribute__((target_version("rdm+rng+crc"))) redef(void) {} |
| 78 |
|
| 79 |
int def(void); |
| 80 |
void __attribute__((target_version("dit"))) nodef(void); |
| 81 |
void __attribute__((target_version("wfxt"))) nodef(void); |
| 82 |
void __attribute__((target_version("aes"))) ovl(void); |
| 83 |
void __attribute__((target_version("default"))) ovl(void); |
| 84 |
int bar() { |
| 85 |
// expected-error@+2 {{reference to overloaded function could not be resolved; did you mean to call it?}} |
| 86 |
// expected-note@-3 {{possible target for call}} |
| 87 |
ovl++; |
| 88 |
nodef(); |
| 89 |
return def(); |
| 90 |
} |
| 91 |
// expected-error@+2 {{function declaration cannot become a multiversioned function after first usage}} |
| 92 |
// expected-note@-13 {{previous declaration is here}} |
| 93 |
int __attribute__((target_version("sha2"))) def(void) { return 1; } |
| 94 |
|
| 95 |
int __attribute__((target_version("sve"))) prot(); |
| 96 |
// expected-error@-1 {{multiversioned function must have a prototype}} |
| 97 |
|
| 98 |
int __attribute__((target_version("aes"))) rtype(int); |
| 99 |
// expected-error@+1 {{multiversioned function declaration has a different return type}} |
| 100 |
float __attribute__((target_version("rdm"))) rtype(int); |
| 101 |
|
| 102 |
int __attribute__((target_version("sha2"))) combine(void) { return 1; } |
| 103 |
// expected-error@+1 {{multiversioned function declaration has a different calling convention}} |
| 104 |
int __attribute__((aarch64_vector_pcs, target_version("sha3"))) combine(void) { return 2; } |
| 105 |
|
| 106 |
// expected-error@+1 {{multiversioned function must have a prototype}} |
| 107 |
int __attribute__((target_version("fp+aes+rcpc"))) unspec_args() { return -1; } |
| 108 |
// expected-error@-1 {{multiversioned function must have a prototype}} |
| 109 |
// expected-note@+1 {{function multiversioning caused by this declaration}} |
| 110 |
int __attribute__((target_version("default"))) unspec_args() { return 0; } |
| 111 |
int cargs() { return unspec_args(); } |
| 112 |
|
| 113 |
// expected-error@+1 {{multiversioned function must have a prototype}} |
| 114 |
int unspec_args_implicit_default_first(); |
| 115 |
// expected-error@-1 {{multiversioned function must have a prototype}} |
| 116 |
// expected-note@+1 {{function multiversioning caused by this declaration}} |
| 117 |
int __attribute__((target_version("aes"))) unspec_args_implicit_default_first() { return -1; } |
| 118 |
// expected-note@+1 {{function multiversioning caused by this declaration}} |
| 119 |
int __attribute__((target_version("default"))) unspec_args_implicit_default_first() { return 0; } |
| 120 |
|
| 121 |
int __attribute__((target_version("aes + sve2 ; priority=100"))) priority_whitespace(void) { return 0; } |
| 122 |
|
| 123 |
//expected-warning@+1 {{unsupported 'priority=10' in the 'target_version' attribute string; 'target_version' attribute ignored}} |
| 124 |
int __attribute__((target_version("priority=10;aes"))) priority_before_features(void) { return 0; } |
| 125 |
|
| 126 |
//expected-warning@+1 {{version priority '256' is outside the allowed range [1-255]; ignoring priority}} |
| 127 |
int __attribute__((target_version("aes;priority=256"))) priority_out_of_range(void) { return 0; } |
| 128 |
|
| 129 |
//expected-warning@+1 {{priority of default version cannot be overridden; ignoring priority}} |
| 130 |
int __attribute__((target_version("default;priority=10"))) priority_default_version(void) { return 0; } |