150
|
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
|
|
2
|
|
3 void __attribute__((target("sse4.2"))) no_default(void);
|
|
4 void __attribute__((target("arch=sandybridge"))) no_default(void);
|
|
5
|
|
6 void use1(void){
|
|
7 // expected-error@+1 {{no matching function for call to 'no_default'}}
|
|
8 no_default();
|
|
9 }
|
|
10
|
|
11 void __attribute__((target("sse4.2"))) has_def(void);
|
|
12 void __attribute__((target("default"))) has_def(void);
|
|
13
|
|
14 void use2(void){
|
|
15 // expected-error@+2 {{reference to overloaded function could not be resolved; did you mean to call it?}}
|
|
16 // expected-note@-4 {{possible target for call}}
|
|
17 +has_def;
|
|
18 }
|
|
19
|
|
20 int __attribute__((target("sse4.2"))) no_proto();
|
|
21 // expected-error@-1 {{multiversioned function must have a prototype}}
|
|
22 // expected-note@+1 {{function multiversioning caused by this declaration}}
|
|
23 int __attribute__((target("arch=sandybridge"))) no_proto();
|
|
24
|
|
25 // The following should all be legal, since they are just redeclarations.
|
|
26 int __attribute__((target("sse4.2"))) redecl1(void);
|
|
27 int __attribute__((target("sse4.2"))) redecl1(void) { return 1; }
|
|
28 int __attribute__((target("arch=sandybridge"))) redecl1(void) { return 2; }
|
|
29
|
|
30 int __attribute__((target("sse4.2"))) redecl2(void) { return 1; }
|
|
31 int __attribute__((target("sse4.2"))) redecl2(void);
|
|
32 int __attribute__((target("arch=sandybridge"))) redecl2(void) { return 2; }
|
|
33
|
|
34 int __attribute__((target("sse4.2"))) redecl3(void) { return 0; }
|
|
35 int __attribute__((target("arch=ivybridge"))) redecl3(void) { return 1; }
|
|
36 int __attribute__((target("arch=sandybridge"))) redecl3(void);
|
|
37 int __attribute__((target("arch=sandybridge"))) redecl3(void) { return 2; }
|
|
38
|
|
39 int __attribute__((target("sse4.2"))) redecl4(void) { return 1; }
|
|
40 int __attribute__((target("arch=sandybridge"))) redecl4(void) { return 2; }
|
|
41 int __attribute__((target("arch=sandybridge"))) redecl4(void);
|
|
42
|
|
43 int __attribute__((target("sse4.2"))) redef(void) { return 1; }
|
|
44 int __attribute__((target("arch=ivybridge"))) redef(void) { return 1; }
|
|
45 int __attribute__((target("arch=sandybridge"))) redef(void) { return 2; }
|
|
46 // expected-error@+2 {{redefinition of 'redef'}}
|
|
47 // expected-note@-2 {{previous definition is here}}
|
|
48 int __attribute__((target("arch=sandybridge"))) redef(void) { return 2; }
|
|
49
|
|
50 int __attribute__((target("default"))) redef2(void) { return 1;}
|
|
51 // expected-error@+2 {{redefinition of 'redef2'}}
|
|
52 // expected-note@-2 {{previous definition is here}}
|
|
53 int __attribute__((target("default"))) redef2(void) { return 1;}
|
|
54
|
|
55 int __attribute__((target("sse4.2"))) mv_after_use(void) { return 1; }
|
|
56 int use3(void) {
|
|
57 return mv_after_use();
|
|
58 }
|
|
59
|
|
60 // expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
|
|
61 int __attribute__((target("arch=sandybridge"))) mv_after_use(void) { return 2; }
|
|
62
|
|
63 int __attribute__((target("sse4.2,arch=sandybridge"))) mangle(void) { return 1; }
|
|
64 //expected-error@+2 {{multiversioned function redeclarations require identical target attributes}}
|
|
65 //expected-note@-2 {{previous declaration is here}}
|
|
66 int __attribute__((target("arch=sandybridge,sse4.2"))) mangle(void) { return 2; }
|
|
67
|
|
68 // allow this, since we want to treat the 1st one as fwd-decl of the sandybridge version.
|
|
69 int prev_no_target(void);
|
|
70 int __attribute__((target("arch=sandybridge"))) prev_no_target(void) { return 2; }
|
|
71 int __attribute__((target("arch=ivybridge"))) prev_no_target(void) { return 2; }
|
|
72
|
|
73 int __attribute__((target("arch=sandybridge"))) prev_no_target2(void);
|
|
74 int prev_no_target2(void);
|
|
75 // expected-error@-1 {{function declaration is missing 'target' attribute in a multiversioned function}}
|
|
76 // expected-note@+1 {{function multiversioning caused by this declaration}}
|
|
77 int __attribute__((target("arch=ivybridge"))) prev_no_target2(void);
|
|
78
|
|
79 void __attribute__((target("sse4.2"))) addtl_attrs(void);
|
|
80 //expected-error@+1 {{attribute 'target' multiversioning cannot be combined}}
|
|
81 void __attribute__((used,target("arch=sandybridge"))) addtl_attrs(void);
|
|
82
|
|
83 //expected-error@+1 {{attribute 'target' multiversioning cannot be combined}}
|
|
84 void __attribute__((target("default"), used)) addtl_attrs2(void);
|
|
85
|
|
86 //expected-error@+2 {{attribute 'target' multiversioning cannot be combined}}
|
|
87 //expected-note@+2 {{function multiversioning caused by this declaration}}
|
|
88 void __attribute__((used,target("sse4.2"))) addtl_attrs3(void);
|
|
89 void __attribute__((target("arch=sandybridge"))) addtl_attrs3(void);
|
|
90
|
|
91 void __attribute__((target("sse4.2"))) addtl_attrs4(void);
|
|
92 void __attribute__((target("arch=sandybridge"))) addtl_attrs4(void);
|
|
93 //expected-error@+1 {{attribute 'target' multiversioning cannot be combined}}
|
|
94 void __attribute__((used,target("arch=ivybridge"))) addtl_attrs4(void);
|
|
95
|
|
96 int __attribute__((target("sse4.2"))) diff_cc(void);
|
|
97 // expected-error@+1 {{multiversioned function declaration has a different calling convention}}
|
|
98 __vectorcall int __attribute__((target("arch=sandybridge"))) diff_cc(void);
|
|
99
|
|
100 int __attribute__((target("sse4.2"))) diff_ret(void);
|
|
101 // expected-error@+1 {{multiversioned function declaration has a different return type}}
|
|
102 short __attribute__((target("arch=sandybridge"))) diff_ret(void);
|