1 | // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s |
2 | |
3 | void __attribute__((cpu_specific(ivybridge))) no_default(void); |
4 | void __attribute__((cpu_specific(sandybridge))) no_default(void); |
5 | |
6 | void use1(void){ |
7 | // Should be OK, default not a problem. |
8 | no_default(); |
9 | } |
10 | |
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); |
14 | |
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; |
26 | } |
27 | |
28 | // expected-error@+1 {{multiversioned function must have a prototype}} |
29 | int __attribute__((cpu_specific(atom))) no_proto(); |
30 | |
31 | int __attribute__((cpu_specific(atom))) redecl1(void); |
32 | int __attribute__((cpu_specific(atom))) redecl1(void) { return 1; } |
33 | |
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) { } |
39 | |
40 | int allow_fwd_decl(void); |
41 | int __attribute__((cpu_dispatch(atom))) allow_fwd_decl(void) {} |
42 | |
43 | int allow_fwd_decl2(void); |
44 | void use_fwd_decl(void) { |
45 | allow_fwd_decl2(); |
46 | } |
47 | // expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}} |
48 | int __attribute__((cpu_dispatch(atom))) allow_fwd_decl2(void) {} |
49 | |
50 | |
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); |
54 | |
55 | // expected-warning@+1 {{CPU list contains duplicate entries; attribute ignored}} |
56 | int __attribute__((cpu_specific(atom, atom))) dup_procs(void); |
57 | |
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); |
62 | |
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); |
67 | |
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; } |
72 | |
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) {} |
77 | |
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) {} |
82 | |
83 | //expected-error@+1 {{attribute 'cpu_specific' multiversioning cannot be combined}} |
84 | void __attribute__((used,cpu_specific(sandybridge))) addtl_attrs(void); |
85 | |
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); |
90 | |
91 | // expected-error@+2 {{multiversioning attributes cannot be combined}} |
92 | void __attribute((cpu_specific(sandybridge), cpu_dispatch(atom, sandybridge))) |
93 | combine_attrs(void); |
94 | |
95 | int __attribute__((cpu_dispatch(ivybridge))) diff_cc(void){} |
96 | // expected-error@+1 {{multiversioned function declaration has a different calling convention}} |
97 | __vectorcall int __attribute__((cpu_specific(sandybridge))) diff_cc(void); |
98 | |
99 | // expected-warning@+2 {{body of cpu_dispatch function will be ignored}} |
100 | int __attribute__((cpu_dispatch(atom))) disp_with_body(void) { |
101 | return 5; |
102 | } |
103 | |
104 | // expected-error@+1 {{invalid option 'INVALID'}} |
105 | int __attribute__((cpu_specific(INVALID))) called_invalid_value(void){ return 1;} |
106 | // expected-warning@+3 {{attribute declaration must precede definition}} |
107 | // expected-note@-2 2 {{previous definition is here}} |
108 | // expected-error@+1 {{redefinition of}} |
109 | int __attribute__((cpu_specific(pentium_iii))) called_invalid_value(void){ return 2;} |
110 | int __attribute__((cpu_specific(pentium_4))) called_invalid_value(void){ return 3;} |
111 | |
112 | int use3(void) { |
113 | return called_invalid_value(); |
114 | } |
115 | |
116 | // expected-warning@+1 {{CPU list contains duplicate entries; attribute ignored}} |
117 | int __attribute__((cpu_dispatch(pentium_iii, pentium_iii_no_xmm_regs))) dupe_p3(void); |
118 | |