1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
3 // expected-error@+1 {{'target_clones' multiversioning requires a default target}}
4 void __attribute__((target_clones("sse4.2", "arch=sandybridge")))
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")))
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")))
17 int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; }
19 int __attribute__((target_clones("sse4.2", "default"))) redecl2(void);
20 int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; }
22 int __attribute__((target_clones("sse4.2", "default"))) redecl3(void);
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; }
31 int __attribute__((target("sse4.2"))) redef2(void) { return 1; }
32 // expected-error@+2 {{multiversioning attributes cannot be combined}}
33 // expected-note@-2 {{previous declaration is here}}
34 int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; }
36 int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
37 // expected-error@+2 {{redefinition of 'redef3'}}
38 // expected-note@-2 {{previous definition is here}}
39 int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
41 int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
42 // expected-error@+2 {{redefinition of 'redef4'}}
43 // expected-note@-2 {{previous definition is here}}
44 int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
46 // Duplicates are allowed, however they alter name mangling.
47 // expected-warning@+2 {{mixing 'target_clones' specifier mechanisms is permitted for GCC compatibility}}
48 // expected-warning@+1 2 {{version list contains duplicate entries}}
49 int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default")))
50 dupes(void) { return 1; }
52 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
53 void __attribute__((target_clones("")))
55 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
56 void __attribute__((target_clones(",default")))
58 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
59 void __attribute__((target_clones("default,")))
61 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
62 void __attribute__((target_clones("default, ,avx2")))
65 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
66 void __attribute__((target_clones("default,avx2", "")))
69 // expected-warning@+1 {{version list contains duplicate entries}}
70 void __attribute__((target_clones("default", "default")))
73 // expected-warning@+1 {{version list contains duplicate entries}}
74 void __attribute__((target_clones("avx2,avx2,default")))
77 // expected-error@+2 {{attribute 'target_clones' cannot appear more than once on a declaration}}
78 // expected-note@+1 {{conflicting attribute is here}}
79 void __attribute__((target_clones("avx2,default"), target_clones("arch=atom,default")))
82 int mv_after_use(void);
84 return mv_after_use();
86 // expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
87 int __attribute__((target_clones("sse4.2", "default"))) mv_after_use(void) { return 1; }
89 void bad_overload1(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
90 void bad_overload1(int p
) {}
92 void bad_overload2(int p
) {}
93 // expected-error@+2 {{conflicting types for 'bad_overload2'}}
94 // expected-note@-2 {{previous definition is here}}
95 void bad_overload2(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
97 void bad_overload3(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
98 // expected-error@+2 {{conflicting types for 'bad_overload3'}}
99 // expected-note@-2 {{previous declaration is here}}
100 void bad_overload3(int) __attribute__((target_clones("mmx", "sse4.2", "default")));
102 void good_overload1(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
103 void __attribute__((__overloadable__
)) good_overload1(int p
) {}
105 // expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
106 void __attribute__((__overloadable__
)) good_overload2(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
107 void good_overload2(int p
) {}
109 // expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
110 void __attribute__((__overloadable__
)) good_overload3(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
111 // expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
112 void __attribute__((__overloadable__
)) good_overload3(int) __attribute__((target_clones("mmx", "sse4.2", "default")));
114 void good_overload4(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
115 // expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
116 void __attribute__((__overloadable__
)) good_overload4(int) __attribute__((target_clones("mmx", "sse4.2", "default")));
118 // expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
119 void __attribute__((__overloadable__
)) good_overload5(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
120 void good_overload5(int) __attribute__((target_clones("mmx", "sse4.2", "default")));