| 1 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s |
| 2 |
|
| 3 |
// expected-error@+1 {{'target_clones' multiversioning requires a default target}} |
| 4 |
void __attribute__((target_clones("sse4.2", "arch=sandybridge"))) |
| 5 |
no_default(void); |
| 6 |
|
| 7 |
// expected-error@+2 {{'target_clones' and 'target' attributes are not compatible}} |
| 8 |
// expected-note@+1 {{conflicting attribute is here}} |
| 9 |
void __attribute__((target("sse4.2"), target_clones("arch=sandybridge"))) |
| 10 |
ignored_attr(void); |
| 11 |
// expected-error@+2 {{'target' and 'target_clones' attributes are not compatible}} |
| 12 |
// expected-note@+1 {{conflicting attribute is here}} |
| 13 |
void __attribute__((target_clones("arch=sandybridge,default"), target("sse4.2"))) |
| 14 |
ignored_attr2(void); |
| 15 |
|
| 16 |
int redecl(void); |
| 17 |
int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; } |
| 18 |
|
| 19 |
int __attribute__((target_clones("sse4.2", "default"))) redecl2(void); |
| 20 |
int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; } |
| 21 |
|
| 22 |
int __attribute__((target_clones("sse4.2", "default"))) redecl3(void); |
| 23 |
int redecl3(void); |
| 24 |
|
| 25 |
int __attribute__((target_clones("sse4.2", "arch=atom", "default"))) redecl4(void); |
| 26 |
// expected-error@+3 {{'target_clones' attribute does not match previous declaration}} |
| 27 |
// expected-note@-2 {{previous declaration is here}} |
| 28 |
int __attribute__((target_clones("sse4.2", "arch=sandybridge", "default"))) |
| 29 |
redecl4(void) { return 1; } |
| 30 |
|
| 31 |
int __attribute__((target_clones("sse4.2", "default"))) redecl5(void); |
| 32 |
int redecl5(void) { return 1; } |
| 33 |
|
| 34 |
int redecl6(void); |
| 35 |
int __attribute__((target_clones("sse4.2", "default"))) redecl6(void) { return 1; } |
| 36 |
|
| 37 |
int __attribute__((target_clones("sse4.2", "default"))) redecl7(void); |
| 38 |
// expected-error@+2 {{multiversioning attributes cannot be combined}} |
| 39 |
// expected-note@-2 {{previous declaration is here}} |
| 40 |
int __attribute__((target("sse4.2"))) redecl7(void) { return 1; } |
| 41 |
|
| 42 |
int __attribute__((target("sse4.2"))) redef2(void) { return 1; } |
| 43 |
// expected-error@+2 {{multiversioning attributes cannot be combined}} |
| 44 |
// expected-note@-2 {{previous declaration is here}} |
| 45 |
int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; } |
| 46 |
|
| 47 |
int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; } |
| 48 |
// expected-error@+2 {{redefinition of 'redef3'}} |
| 49 |
// expected-note@-2 {{previous definition is here}} |
| 50 |
int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; } |
| 51 |
|
| 52 |
int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; } |
| 53 |
// expected-error@+2 {{redefinition of 'redef4'}} |
| 54 |
// expected-note@-2 {{previous definition is here}} |
| 55 |
int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; } |
| 56 |
|
| 57 |
// Duplicates are allowed, however they alter name mangling. |
| 58 |
// expected-warning@+2 {{mixing 'target_clones' specifier mechanisms is permitted for GCC compatibility}} |
| 59 |
// expected-warning@+1 2 {{version list contains duplicate entries}} |
| 60 |
int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default"))) |
| 61 |
dupes(void) { return 1; } |
| 62 |
|
| 63 |
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}} |
| 64 |
void __attribute__((target_clones(""))) |
| 65 |
empty_target_1(void); |
| 66 |
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}} |
| 67 |
void __attribute__((target_clones(",default"))) |
| 68 |
empty_target_2(void); |
| 69 |
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}} |
| 70 |
void __attribute__((target_clones("default,"))) |
| 71 |
empty_target_3(void); |
| 72 |
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}} |
| 73 |
void __attribute__((target_clones("default, ,avx2"))) |
| 74 |
empty_target_4(void); |
| 75 |
|
| 76 |
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}} |
| 77 |
void __attribute__((target_clones("default,avx2", ""))) |
| 78 |
empty_target_5(void); |
| 79 |
|
| 80 |
// expected-warning@+1 {{version list contains duplicate entries}} |
| 81 |
void __attribute__((target_clones("default", "default"))) |
| 82 |
dupe_default(void); |
| 83 |
|
| 84 |
// expected-warning@+1 {{version list contains duplicate entries}} |
| 85 |
void __attribute__((target_clones("avx2,avx2,default"))) |
| 86 |
dupe_normal(void); |
| 87 |
|
| 88 |
// expected-error@+2 {{attribute 'target_clones' cannot appear more than once on a declaration}} |
| 89 |
// expected-note@+1 {{conflicting attribute is here}} |
| 90 |
void __attribute__((target_clones("avx2,default"), target_clones("arch=atom,default"))) |
| 91 |
dupe_normal2(void); |
| 92 |
|
| 93 |
int mv_after_use(void); |
| 94 |
int useage(void) { |
| 95 |
return mv_after_use(); |
| 96 |
} |
| 97 |
// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}} |
| 98 |
int __attribute__((target_clones("sse4.2", "default"))) mv_after_use(void) { return 1; } |
| 99 |
|
| 100 |
void bad_overload1(void) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 101 |
// expected-error@+2 {{conflicting types for 'bad_overload1'}} |
| 102 |
// expected-note@-2 {{previous declaration is here}} |
| 103 |
void bad_overload1(int p) {} |
| 104 |
|
| 105 |
void bad_overload2(int p) {} |
| 106 |
// expected-error@+2 {{conflicting types for 'bad_overload2'}} |
| 107 |
// expected-note@-2 {{previous definition is here}} |
| 108 |
void bad_overload2(void) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 109 |
|
| 110 |
void bad_overload3(void) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 111 |
// expected-error@+2 {{conflicting types for 'bad_overload3'}} |
| 112 |
// expected-note@-2 {{previous declaration is here}} |
| 113 |
void bad_overload3(int) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 114 |
|
| 115 |
void good_overload1(void) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 116 |
void __attribute__((__overloadable__)) good_overload1(int p) {} |
| 117 |
|
| 118 |
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}} |
| 119 |
void __attribute__((__overloadable__)) good_overload2(void) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 120 |
void good_overload2(int p) {} |
| 121 |
|
| 122 |
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}} |
| 123 |
void __attribute__((__overloadable__)) good_overload3(void) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 124 |
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}} |
| 125 |
void __attribute__((__overloadable__)) good_overload3(int) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 126 |
|
| 127 |
void good_overload4(void) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 128 |
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}} |
| 129 |
void __attribute__((__overloadable__)) good_overload4(int) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 130 |
|
| 131 |
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}} |
| 132 |
void __attribute__((__overloadable__)) good_overload5(void) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 133 |
void good_overload5(int) __attribute__((target_clones("mmx", "sse4.2", "default"))); |
| 134 |
|
| 135 |
void good_isa_level(int) __attribute__((target_clones("default", "arch=x86-64", "arch=x86-64-v2", "arch=x86-64-v3", "arch=x86-64-v4"))); |
| 136 |
// expected-warning@+1 {{unsupported CPU 'x86-64-v5' in the 'target_clones' attribute string; 'target_clones' attribute ignored}} |
| 137 |
void bad_isa_level(int) __attribute__((target_clones("default", "arch=x86-64-v5"))); |
| 138 |
|
| 139 |
// expected-warning@+1 {{unsupported 'sha' in the 'target_clones' attribute string; 'target_clones' attribute ignored}} |
| 140 |
void bad_feature(void) __attribute__((target_clones("default", "sse4.2", "sha"))); |
| 141 |
|
| 142 |
// expected-error@+1 {{'target_clones' multiversioning requires a default target}} |
| 143 |
void __attribute__((target_clones())) |
| 144 |
gh173684_empty_attribute_args(void); |
| 145 |
|
| 146 |
// expected-error@+1 {{'target_clones' multiversioning requires a default target}} |
| 147 |
void __attribute__((target_clones)) |
| 148 |
gh173684_empty_attribute_args_2(void); |