Erich Keane | 281d20b | 2018-01-08 21:34:17 +0000 | [diff] [blame] | 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 | int prev_no_target(void); |
| 69 | int __attribute__((target("arch=sandybridge"))) prev_no_target(void) { return 2; } |
| 70 | // expected-error@-2 {{function declaration is missing 'target' attribute in a multiversioned function}} |
| 71 | // expected-note@+1 {{function multiversioning caused by this declaration}} |
| 72 | int __attribute__((target("arch=ivybridge"))) prev_no_target(void) { return 2; } |
| 73 | |
| 74 | int __attribute__((target("arch=sandybridge"))) prev_no_target2(void); |
| 75 | int prev_no_target2(void); |
| 76 | // expected-error@-1 {{function declaration is missing 'target' attribute in a multiversioned function}} |
| 77 | // expected-note@+1 {{function multiversioning caused by this declaration}} |
| 78 | int __attribute__((target("arch=ivybridge"))) prev_no_target2(void); |
| 79 | |
| 80 | void __attribute__((target("sse4.2"))) addtl_attrs(void); |
| 81 | //expected-error@+1 {{attribute 'target' multiversioning cannot be combined}} |
| 82 | void __attribute__((used,target("arch=sandybridge"))) addtl_attrs(void); |
| 83 | |
| 84 | //expected-error@+1 {{attribute 'target' multiversioning cannot be combined}} |
| 85 | void __attribute__((target("default"), used)) addtl_attrs2(void); |
| 86 | |
| 87 | //expected-error@+2 {{attribute 'target' multiversioning cannot be combined}} |
| 88 | //expected-note@+2 {{function multiversioning caused by this declaration}} |
| 89 | void __attribute__((used,target("sse4.2"))) addtl_attrs3(void); |
| 90 | void __attribute__((target("arch=sandybridge"))) addtl_attrs3(void); |
| 91 | |
| 92 | void __attribute__((target("sse4.2"))) addtl_attrs4(void); |
| 93 | void __attribute__((target("arch=sandybridge"))) addtl_attrs4(void); |
| 94 | //expected-error@+1 {{attribute 'target' multiversioning cannot be combined}} |
| 95 | void __attribute__((used,target("arch=ivybridge"))) addtl_attrs4(void); |
| 96 | |
| 97 | int __attribute__((target("sse4.2"))) diff_cc(void); |
Michael Kruse | 41dd6ce | 2018-06-25 20:06:13 +0000 | [diff] [blame] | 98 | // expected-error@+1 {{multiversioned function declaration has a different calling convention}} |
Erich Keane | 281d20b | 2018-01-08 21:34:17 +0000 | [diff] [blame] | 99 | __vectorcall int __attribute__((target("arch=sandybridge"))) diff_cc(void); |
| 100 | |
| 101 | int __attribute__((target("sse4.2"))) diff_ret(void); |
| 102 | // expected-error@+1 {{multiversioned function declaration has a different return type}} |
| 103 | short __attribute__((target("arch=sandybridge"))) diff_ret(void); |