[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / attr-cpuspecific.c
blobf3d46cf8f1801a37a82e89122aeefbf8fd1ef399
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -Wno-strict-prototypes -fsyntax-only -verify %s -Wnonnull
3 void __attribute__((cpu_specific(ivybridge))) no_default(void);
4 void __attribute__((cpu_specific(sandybridge))) no_default(void);
6 void use1(void){
7 // Should be OK, default not a problem.
8 no_default();
11 int __attribute__((cpu_specific(atom))) addr_of(void);
12 int __attribute__((cpu_specific(ivybridge))) addr_of(void);
13 int __attribute__((cpu_specific(ivybridge))) addr_of2(void);
15 void use2(void){
16 addr_of();
17 addr_of2();
18 // expected-error@+1{{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}}
19 (void)+addr_of;
20 // expected-error@+1{{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}}
21 (void)+addr_of2;
22 // expected-error@+1{{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}}
23 (void)&addr_of;
24 // expected-error@+1{{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}}
25 (void)&addr_of2;
28 // expected-error@+1 {{multiversioned function must have a prototype}}
29 int __attribute__((cpu_specific(atom))) no_proto();
31 int __attribute__((cpu_specific(atom))) redecl1(void);
32 int __attribute__((cpu_specific(atom))) redecl1(void) { return 1; }
34 int __attribute__((cpu_dispatch(atom))) redecl2(void);
35 int __attribute__((cpu_dispatch(atom))) redecl2(void) { }
36 // expected-error@+2 {{redefinition of 'redecl2'}}
37 // expected-note@-2 {{previous definition is here}}
38 int __attribute__((cpu_dispatch(atom))) redecl2(void) { }
40 int allow_fwd_decl(void);
41 int __attribute__((cpu_dispatch(atom))) allow_fwd_decl(void) {}
43 int allow_fwd_decl2(void);
44 void use_fwd_decl(void) {
45 allow_fwd_decl2();
47 // expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
48 int __attribute__((cpu_dispatch(atom))) allow_fwd_decl2(void) {}
51 int __attribute__((cpu_specific(atom))) redecl4(void);
52 // expected-error@+1 {{function declaration is missing 'cpu_specific' or 'cpu_dispatch' attribute in a multiversioned function}}
53 int redecl4(void);
55 // expected-warning@+1 {{CPU list contains duplicate entries; attribute ignored}}
56 int __attribute__((cpu_specific(atom, atom))) dup_procs(void);
58 int __attribute__((cpu_specific(ivybridge, atom))) dup_procs2(void);
59 // expected-error@+2 {{multiple 'cpu_specific' functions cannot specify the same CPU: 'atom'}}
60 // expected-note@-2 {{previous declaration is here}}
61 int __attribute__((cpu_specific(atom))) dup_procs2(void);
63 int __attribute__((cpu_specific(ivybridge, atom))) dup_procs3(void);
64 // expected-error@+2 {{multiple 'cpu_specific' functions cannot specify the same CPU: 'ivybridge'}}
65 // expected-note@-2 {{previous declaration is here}}
66 int __attribute__((cpu_specific(atom, ivybridge))) dup_procs3(void);
68 int __attribute__((cpu_specific(atom))) redef(void) { return 1; }
69 // expected-error@+2 {{redefinition of 'redef'}}
70 // expected-note@-2 {{previous definition is here}}
71 int __attribute__((cpu_specific(atom))) redef(void) { return 2; }
73 int __attribute((cpu_dispatch(atom))) mult_dispatch(void) {}
74 // expected-error@+2 {{'cpu_dispatch' function redeclared with different CPUs}}
75 // expected-note@-2 {{previous declaration is here}}
76 int __attribute((cpu_dispatch(ivybridge))) mult_dispatch(void) {}
78 // expected-error@+1 {{'cpu_dispatch' attribute takes at least 1 argument}}
79 int __attribute((cpu_dispatch())) no_dispatch(void) {}
80 // expected-error@+1 {{'cpu_specific' attribute takes at least 1 argument}}
81 int __attribute((cpu_specific())) no_specific(void) {}
83 //expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'used'}}
84 void __attribute__((used,cpu_specific(sandybridge))) addtl_attrs(void);
86 void __attribute__((target("default"))) addtl_attrs2(void);
87 // expected-error@+2 {{multiversioning attributes cannot be combined}}
88 // expected-note@-2 {{previous declaration is here}}
89 void __attribute__((cpu_specific(sandybridge))) addtl_attrs2(void);
91 // expected-error@+2 {{'cpu_dispatch' and 'cpu_specific' attributes are not compatible}}
92 // expected-note@+1 {{conflicting attribute is here}}
93 void __attribute((cpu_specific(sandybridge), cpu_dispatch(atom, sandybridge)))
94 combine_attrs(void);
96 int __attribute__((cpu_dispatch(ivybridge))) diff_cc(void){}
97 // expected-error@+1 {{multiversioned function declaration has a different calling convention}}
98 __vectorcall int __attribute__((cpu_specific(sandybridge))) diff_cc(void);
100 // expected-warning@+2 {{body of cpu_dispatch function will be ignored}}
101 int __attribute__((cpu_dispatch(atom))) disp_with_body(void) {
102 return 5;
105 // expected-error@+1 {{invalid option 'INVALID'}}
106 int __attribute__((cpu_specific(INVALID))) called_invalid_value(void){ return 1;}
107 // expected-warning@+3 {{attribute declaration must precede definition}}
108 // expected-note@-2 2 {{previous definition is here}}
109 // expected-error@+1 {{redefinition of}}
110 int __attribute__((cpu_specific(pentium_iii))) called_invalid_value(void){ return 2;}
111 int __attribute__((cpu_specific(pentium_4))) called_invalid_value(void){ return 3;}
113 int use3(void) {
114 return called_invalid_value();
117 // expected-warning@+1 {{CPU list contains duplicate entries; attribute ignored}}
118 int __attribute__((cpu_dispatch(pentium_iii, pentium_iii_no_xmm_regs))) dupe_p3(void);
120 void __attribute__((cpu_specific(atom), nothrow, nonnull(1))) addtl_attrs(int*);
122 int __attribute__((cpu_specific(atom))) bad_overload1(void);
123 int __attribute__((cpu_specific(ivybridge))) bad_overload1(void);
124 // expected-error@+1 {{function declaration is missing 'cpu_specific' or 'cpu_dispatch' attribute in a multiversioned function}}
125 int bad_overload1(int);
127 int bad_overload2(int);
128 // expected-error@+2 {{conflicting types for 'bad_overload2'}}
129 // expected-note@-2 {{previous declaration is here}}
130 int __attribute__((cpu_specific(atom))) bad_overload2(void);
131 int __attribute__((cpu_specific(ivybridge))) bad_overload2(void);
133 int __attribute__((cpu_dispatch(generic))) bad_overload3(void);
134 int __attribute__((cpu_specific(ivybridge))) bad_overload3(void);
135 // expected-error@+1 {{function declaration is missing 'cpu_specific' or 'cpu_dispatch' attribute in a multiversioned function}}
136 int bad_overload3(int);
138 int bad_overload4(int);
139 // expected-error@+2 {{conflicting types for 'bad_overload4'}}
140 // expected-note@-2 {{previous declaration is here}}
141 int __attribute__((cpu_dispatch(generic))) bad_overload4(void);
142 int __attribute__((cpu_specific(ivybridge))) bad_overload4(void);
144 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
145 int __attribute__((__overloadable__)) __attribute__((cpu_specific(generic))) bad_overload5(void);
146 int __attribute__((cpu_specific(ivybridge))) bad_overload5(void);
148 int __attribute__((cpu_specific(generic))) bad_overload6(void);
149 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
150 int __attribute__((__overloadable__)) __attribute__((cpu_specific(ivybridge))) bad_overload6(void);
152 int __attribute__((cpu_specific(atom))) good_overload1(void);
153 int __attribute__((cpu_specific(ivybridge))) good_overload1(void);
154 int __attribute__((__overloadable__)) good_overload1(int);
156 int __attribute__((__overloadable__)) good_overload2(int);
157 int __attribute__((cpu_specific(atom))) good_overload2(void);
158 int __attribute__((cpu_specific(ivybridge))) good_overload2(void);
160 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
161 int __attribute__((__overloadable__)) __attribute__((cpu_specific(atom))) good_overload3(void);
162 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
163 int __attribute__((__overloadable__)) __attribute__((cpu_specific(ivybridge))) good_overload3(void);
164 int good_overload3(int);
166 int good_overload4(int);
167 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
168 int __attribute__((__overloadable__)) __attribute__((cpu_specific(atom))) good_overload4(void);
169 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
170 int __attribute__((__overloadable__)) __attribute__((cpu_specific(ivybridge))) good_overload4(void);
172 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
173 int __attribute__((__overloadable__)) __attribute__((cpu_specific(atom))) good_overload5(void);
174 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
175 int __attribute__((__overloadable__)) __attribute__((cpu_specific(ivybridge))) good_overload5(int);
177 int __attribute__((cpu_specific(atom))) good_overload6(void);
178 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
179 int __attribute__((__overloadable__)) __attribute__((cpu_specific(ivybridge))) good_overload6(int);
181 // expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined with attribute 'overloadable'}}
182 int __attribute__((__overloadable__)) __attribute__((cpu_specific(atom))) good_overload7(void);
183 int __attribute__((cpu_specific(ivybridge))) good_overload7(int);