[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / attr-target-clones.c
blobe9ddecad5727f36747df4b2ae27bf68c5e0a35a1
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")))
5 no_default(void);
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);
16 int redecl(void);
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);
23 int 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("")))
54 empty_target_1(void);
55 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
56 void __attribute__((target_clones(",default")))
57 empty_target_2(void);
58 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
59 void __attribute__((target_clones("default,")))
60 empty_target_3(void);
61 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
62 void __attribute__((target_clones("default, ,avx2")))
63 empty_target_4(void);
65 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
66 void __attribute__((target_clones("default,avx2", "")))
67 empty_target_5(void);
69 // expected-warning@+1 {{version list contains duplicate entries}}
70 void __attribute__((target_clones("default", "default")))
71 dupe_default(void);
73 // expected-warning@+1 {{version list contains duplicate entries}}
74 void __attribute__((target_clones("avx2,avx2,default")))
75 dupe_normal(void);
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")))
80 dupe_normal2(void);
82 int mv_after_use(void);
83 int useage(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")));